diff --git a/utils/haddock/.github/mergify.yml b/utils/haddock/.github/mergify.yml
new file mode 100644
index 0000000000000000000000000000000000000000..de362dd2a36aef215b20a8e8c091b306d76dfe73
--- /dev/null
+++ b/utils/haddock/.github/mergify.yml
@@ -0,0 +1,29 @@
+pull_request_rules:
+  # rebase+merge strategy
+  - actions:
+      queue:
+        name: default
+        # Merge into master with a merge commit
+        method: merge
+        # Update the pr branch with rebase, so the history is clean
+        update_method: rebase
+    name: Put pull requests in the rebase+merge queue
+    conditions:
+      - label=merge me
+      - '#approved-reviews-by>=1'
+  # merge+squash strategy
+  - actions:
+      queue:
+        name: default
+        method: squash
+        # both update methods get absorbed by the squash, so we use the most
+        # reliable
+        update_method: merge
+    name: Put pull requests in the squash+merge queue
+    conditions:
+      - label=squash+merge me
+      - '#approved-reviews-by>=1'
+
+queue_rules:
+  - name: default
+    conditions: []
diff --git a/utils/haddock/.github/workflows/ci.yml b/utils/haddock/.github/workflows/ci.yml
new file mode 100644
index 0000000000000000000000000000000000000000..4c3c94ebdb2ec04010e23275252df775996d27ce
--- /dev/null
+++ b/utils/haddock/.github/workflows/ci.yml
@@ -0,0 +1,56 @@
+name: CI
+
+# Trigger the workflow on push or pull request, but only for the master branch
+on:
+  pull_request:
+  push:
+    branches: ["ghc-head"]
+
+jobs:
+  cabal:
+    name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ubuntu-latest]
+        cabal: ["3.6"]
+        ghc:
+          - "head"
+
+    steps:
+    - uses: actions/checkout@v2
+      if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/ghc-head'
+
+    - name: Install gmp and tinfo
+      run: |
+        sudo -- sh -c "apt-get update"
+        sudo -- sh -c "apt-get -y install libgmp-dev libtinfo-dev"
+
+    - uses: haskell/actions/setup@main
+      id: setup-haskell-cabal
+      name: Setup Haskell
+      with:
+        ghc-version: ${{ matrix.ghc }}
+        cabal-version: ${{ matrix.cabal }}
+
+    - name: Prepare environment
+      run: echo "$HOME/.ghcup/bin" >> $GITHUB_PATH
+
+    - name: Freeze
+      run: |
+        cabal freeze
+ 
+    - uses: actions/cache@v2
+      name: Cache ~/.cabal/store
+      with:
+        path: |
+          ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
+        key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
+
+    - name: Build
+      run: |
+        cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
+        cabal build all
+
+    - name: Test
+      run: cabal test --test-show-details=direct --test-options="--haddock-stdout=/dev/stdout" all
diff --git a/utils/haddock/.github/workflows/hlint-ci.yml b/utils/haddock/.github/workflows/hlint-ci.yml
new file mode 100644
index 0000000000000000000000000000000000000000..7009e7392108a45de3399af804ac9192547b96b0
--- /dev/null
+++ b/utils/haddock/.github/workflows/hlint-ci.yml
@@ -0,0 +1,26 @@
+name: hlint
+
+on:
+  pull_request:
+  push:
+
+jobs:
+  build:
+    name: hlint
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v3
+      with:
+        submodules: true
+
+    - uses: rwe/actions-hlint-setup@v1
+      name: Set up HLint
+      with:
+        version: "3.4.1"
+
+    - uses: rwe/actions-hlint-run@v2
+      name: hlint
+      with:
+        path: '[ "haddock-library/", "haddock-api/", "haddock-test/", "hoogle-test/", "html-test/", "hypsrc-test/", "latex-test/" ]'
+        fail-on: suggestion
\ No newline at end of file
diff --git a/utils/haddock/.gitignore b/utils/haddock/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..ba26cf0ea77313382c0127445f2d7cceeffb2897
--- /dev/null
+++ b/utils/haddock/.gitignore
@@ -0,0 +1,39 @@
+/dist/
+/dist-newstyle/
+/haddock-api/dist/
+/haddock-library/dist/
+/haddock-test/dist/
+/html-test/out/
+/hypsrc-test/out/
+/latex-test/out/
+/hoogle-test/out/
+
+*.o
+*.hi
+*.dyn_o
+*.dyn_hi
+*.hp
+
+/doc/haddock
+/doc/haddock.ps
+/doc/haddock.pdf
+/doc/autom4te.cache/
+/doc/config.log
+/doc/config.mk
+/doc/config.status
+/doc/configure
+tags
+TAGS
+
+/haddock-api/resources/html/node_modules
+/haddock-api/resources/html/*.js.map
+
+.cabal-sandbox
+.ghc.environment.*
+cabal.sandbox.config
+cabal.project.local
+cabal.project.local~
+
+.stack-work/
+
+.hspec-failures
diff --git a/utils/haddock/.hlint.yaml b/utils/haddock/.hlint.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..b57c494f6ed170c8bb8fb2972593051d7319a1c9
--- /dev/null
+++ b/utils/haddock/.hlint.yaml
@@ -0,0 +1,82 @@
+# Warnings currently triggered
+- ignore: {name: "Avoid lambda"} # 3 hints
+- ignore: {name: "Avoid lambda using `infix`"} # 5 hints
+- ignore: {name: "Eta reduce"} # 18 hints
+- ignore: {name: "Functor law"} # 3 hints
+- ignore: {name: "Fuse concatMap/map"} # 1 hint
+- ignore: {name: "Fuse foldr/map"} # 2 hints
+- ignore: {name: "Fuse mapM/map"} # 2 hints
+- ignore: {name: "Hoist not"} # 1 hint
+- ignore: {name: "Move brackets to avoid $"} # 7 hints
+- ignore: {name: "Move guards forward"} # 1 hint
+- ignore: {name: "Move map inside list comprehension"} # 2 hints
+- ignore: {name: "Redundant <$>"} # 3 hints
+- ignore: {name: "Redundant bracket"} # 44 hints
+- ignore: {name: "Redundant id"} # 1 hint
+- ignore: {name: "Redundant if"} # 3 hints
+- ignore: {name: "Redundant lambda"} # 2 hints
+- ignore: {name: "Redundant map"} # 3 hints
+- ignore: {name: "Redundant return"} # 1 hint
+- ignore: {name: "Replace case with fromMaybe"} # 2 hints
+- ignore: {name: "Replace case with maybe"} # 4 hints
+- ignore: {name: "Use $>"} # 4 hints
+- ignore: {name: "Use ++"} # 3 hints
+- ignore: {name: "Use :"} # 4 hints
+- ignore: {name: "Use <$>"} # 12 hints
+- ignore: {name: "Use <&>"} # 1 hint
+- ignore: {name: "Use <|>"} # 1 hint
+- ignore: {name: "Use =<<"} # 1 hint
+- ignore: {name: "Use all"} # 1 hint
+- ignore: {name: "Use bimap"} # 1 hint
+- ignore: {name: "Use camelCase"} # 31 hints
+- ignore: {name: "Use concatMap"} # 1 hint
+- ignore: {name: "Use const"} # 4 hints
+- ignore: {name: "Use fewer LANGUAGE pragmas"} # 1 hint
+- ignore: {name: "Use find"} # 1 hint
+- ignore: {name: "Use fmap"} # 12 hints
+- ignore: {name: "Use foldr"} # 1 hint
+- ignore: {name: "Use fromMaybe"} # 2 hints
+- ignore: {name: "Use infix"} # 3 hints
+- ignore: {name: "Use intercalate"} # 1 hint
+- ignore: {name: "Use isAsciiLower"} # 1 hint
+- ignore: {name: "Use isAsciiUpper"} # 1 hint
+- ignore: {name: "Use isDigit"} # 1 hint
+- ignore: {name: "Use lambda-case"} # 4 hints
+- ignore: {name: "Use let"} # 2 hints
+- ignore: {name: "Use list comprehension"} # 2 hints
+- ignore: {name: "Use list literal pattern"} # 1 hint
+- ignore: {name: "Use map once"} # 1 hint
+- ignore: {name: "Use maybe"} # 2 hints
+- ignore: {name: "Use newtype instead of data"} # 13 hints
+- ignore: {name: "Use notElem"} # 2 hints
+- ignore: {name: "Use print"} # 3 hints
+- ignore: {name: "Use record patterns"} # 5 hints
+- ignore: {name: "Use second"} # 3 hints
+- ignore: {name: "Use sortOn"} # 3 hints
+- ignore: {name: "Use tuple-section"} # 3 hints
+- ignore: {name: "Use unless"} # 1 hint
+- ignore: {name: "Use void"} # 1 hint
+# Ignore within modules where following hlint or adding an HLint annotation
+# would alter the expected test output.
+- ignore: {name: "Unused LANGUAGE pragma", within: [QuasiExpr, TH, Ticket112]}
+# Module names (not all unique) where CPP can be used
+- extensions:
+  - name: CPP
+    within:
+    - Bug1091
+    - CompatPrelude
+    - CPP
+    - Documentation.Haddock.Parser.UtilSpec
+    - Documentation.Haddock.Types
+    - Haddock
+    - Haddock.Config
+    - Haddock.Convert
+    - Haddock.Interface
+    - Haddock.Interface.Create
+    - Haddock.InterfaceFile
+    - Haddock.Types
+    - Haddock.Utils
+    - Haddock.Version
+    - Haddock.Backends.Xhtml
+    - Main
+    - Test.Haddock.Config
diff --git a/utils/haddock/CHANGES.md b/utils/haddock/CHANGES.md
new file mode 100644
index 0000000000000000000000000000000000000000..55f28c2e58916f4d727f378169150e06c730bd48
--- /dev/null
+++ b/utils/haddock/CHANGES.md
@@ -0,0 +1,898 @@
+## Changes in 2.28.0
+ * `hi-haddock` is integrated, which means docstrings are no longer extracted
+   through typchecked module results. Instead, docstrings are taken from Haskell
+   interface (`.hi`) files.
+
+ * Support qualified and unqualified names in `--ignore-link-symbol`.
+
+ * Add `--trace-args` flag which prints arguments to standard output. This is
+   useful for examining arguments passed when Haddock is invoked through `cabal
+   haddock`, as `cabal` uses temporary response files to pass arguments to
+   Haddock.
+
+ * Avoid recompilation due to changes in optimization flags.
+
+## Changes in 2.24.0
+
+ * Reify oversaturated data family instances correctly (#1103)
+
+ * Removed the majority of Haddock's possible `panic` routes through
+   the TTG refactor to make extension variants empty
+
+## Changes in 2.23.0
+
+ * "Linuwial" is the new default theme (#721, #782, #949)
+
+ * Fix style switcher (enabled by `--built-in-themes`) (#949)
+
+ * Support inline markup in markdown-style links (#875)
+
+ * The hyperlinker backend has been re-engineered to use HIE files
+   and display type annotations on expressions (#977)
+
+ * The hyperlinker backend lexer is now more incremental, faster, and
+   more memory efficient (#977)
+
+ * Add an "Instances" menu item to the HTML backend for controlling
+   settings related to expanding/collapsing instances (#1007)
+
+ * Improved identifier links including value/type namespaces, and
+   hyperlinking of parenthesized/backticked identifiers
+
+ * Substantial bugfixes for converting `TyThing` back into source
+   declarations (#1003, #1005, #1022, #1020)
+
+ * `--show-interface` now outputs to stdout (instead of stderr)
+
+ * Render associated type defaults and also improve rendering of
+   default method signatures
+
+ * Many fixes to the LaTeX backend, mostly focused on not crashing
+   as well as generating LaTeX source that compiles
+
+ * More flexible parsing of the module header
+
+## Changes in version 2.22.0
+
+ * Make `--package-version` optional for `--hoogle` (#899)
+
+ * Support type and data families in the LaTeX backend (#734)
+
+ * Support pattern synonyms in the Hoogle backend (#947)
+
+## Changes in version 2.21.0
+
+ * Overhaul handling of data declarations in XHTML and LaTeX. Adds support for
+   documenting individual arguments of constructors/patterns (#709)
+
+ * Actually list all fixities for `--hoogle` (#871)
+
+ * Fix broken instance source links (#869)
+
+ * Avoiding line breaks due to ling line in the output of `--hoogle` (#868)
+
+ * Capture docs on type family instances (#867)
+
+## Changes in version 2.20.0
+
+ * Show where instances are defined (#748)
+
+ * `@since` includes package name (#452, #550, #749)
+
+## Changes in version 2.19.0.1
+
+ * Support for linking unicode operators (#458)
+
+ * Hyperlinker: Fix file handle leak in (#763)
+
+## Changes in version 2.19.0
+
+ * Haddock now supports tables in documentation inspired by reSTs grid tables
+
+ * `--quickjump` allows for quick navigation in documentation on hackage and
+   other documentation hosting sites.
+
+ * A --reexport flag, which can be used to add extra modules to the
+   top-level module tree
+
+ * Haddock no longer reports coverage statistics for hidden modules. By default
+   cabal-install marks all package internal modules as hidden.
+
+ * Haddock now writes additional information about the documentation to `meta.json`
+
+ * Fix renaming of type variables after specializing instance method signatures (#613)
+
+ * Move markup related data types to haddock-library
+
+ * Fix: Show empty constraint contexts in pattern type signatures (#663)
+
+ * Fix: Generate constraint signatures for constructors exported as pattern
+   synonyms (#663)
+
+ * The hyperlinker backend now uses the GHC lexer instead of a custom one.
+   This notably fixes rendering of quasiquotes.
+
+ * Overhaul Haddock's rendering of kind signatures so that invisible kind
+   parameters are not printed (#681) (Fixes #544)
+
+ * Recognise `SPDX-License-Identifier` as alias for `License` in module header
+   parser (#743)
+
+ * Remove the response file related utilities, and use the ones that
+   come with `base` (Trac #13896)
+
+ * Remove the response file related utilities, and use the ones that
+   come with `base` (Trac #13896)
+
+## Changes in version 2.18.1
+
+ * Synopsis is working again (#599)
+
+ * Per-argument documentation on class methods working again (#647)
+
+ * Support user defined signatures on pattern synonyms
+
+ * Support for bundled pattern synonyms (#494, #551, #626)
+
+## Changes in version 2.17.4
+
+ * Fix 'internal error: links: UnhelpfulSpan' (#554, #565)
+
+ * Hyperlink backend knows about `DataKinds` (#510)
+
+ * Fix rendering of class methods for `Eq` and `Ord` (#549)
+
+ * Export `MDoc` and `toInstalledIface` from `Haddock.Types`
+
+## Changes in version 2.17.3.1
+
+ * Disable `NFData` instances for GHC types when GHC >= 8.0.2 (#537)
+
+## Changes in version 2.17.3
+
+ * Remove framed view of the HTML documentation
+
+## Changes in version 2.17.2
+
+ * Fix portability of documentation building within GHC
+
+## Changes in version 2.17.1
+
+ * Included with GHC 8.0.1
+
+ * Fixed Makefile for GHC installation
+
+ * Fixed clean rule of GHC Makefile
+
+## Changes in version 2.17.0 (not released)
+
+ * Support typesetting of mathematical expressions via Mathjax (#397)
+
+ * Describe orphan instances defined in a module in its documentation (#449)
+
+ * Produce specialized type signatures for typeclass methods (#425)
+
+ * Support GCC-like response files (#470)
+
+## Changes in version 2.16.2
+
+ * Generate hyperlinked source ourselves (#410, part of GSOC 2015)
+
+ * Fix expansion icon for user-collapsible sections (#412)
+
+ * Break up response file arguments on newlines
+
+ * Various HTML fixes (#301, #406, #407, #421)
+
+ * Line anchors in hyperlinked source (#420)
+
+## Changes in version 2.16.1
+
+ * Don't default to type constructors for out-of-scope names (#253 and
+   #375)
+
+ * Fix Hoogle display of constructors (#361)
+
+ * Fully qualify names in Hoogle instances output (#263)
+
+ * Output method documentation in Hoogle backend (#259)
+
+ * Don't print instance safety information in Hoogle (#168)
+
+ * Expand response files in arguments (#285)
+
+ * Build the main executable with -threaded (#399)
+
+ * Use SrcSpan of declarations for inferred type sigs (#207)
+
+ * Fix cross-module instance locations (#383)
+
+ * Fix alignment of Source link for instances in Firefox (#384)
+
+## Changes in version 2.16.0
+
+ * Experimental collapsible header support (#335)
+
+ * Add support for markdown links and images
+
+ * Allow an optional colon after the closing bracket of definition lists.
+   This is to disambiguate them from markdown links and will be require with a
+   future release.
+
+ * Fix re-exports of built-in type families (#310)
+
+ * Fix parsing of infix identifiers such as ``elem``.
+
+ * Print missing docs by default and add --no-print-missing-docs
+
+ * parser: now parses out some meta data too, breaking the API
+
+ * parser: markdown syntax for images and URLs is now accepted:
+   <<foo>> style for images and <foo bar> style for links is now
+   considered deprecated. <foo> for links is still OK.
+
+ * parser: add support for @since element: this is paragraph-level
+   element of the form ‘@since x.y.z’ where x.y.z is the version
+   number. The way it is rendered is subject to change.
+
+ * properly render package ID (not package key) in index (#329)
+
+ * links to source location of class instance definitions
+
+ * Fix code blocks in presence of Windows line endings
+
+ * Deal better with long synopsis lines (#151)
+
+## Changes in version 2.15.0
+
+ * Always read in prologue files as UTF8 (#286 and Cabal #1721)
+
+ * parser: don't wrap headers in DocParagraph (#307)
+
+ * parser: don't mangle append order for nested lists (pandoc #1346)
+
+ * parser: preserve list ordering in certain scenarios (#313)
+
+ * parser: update the attoparsec version used internally giving slight
+   parsing performance boost.
+
+ * Move development to be against latest GHC release and not GHC HEAD.
+
+ * Further split up the package to separate the executable from the
+   library, necessary by things like GHCJS. We now have
+   ‘haddock-library’ which are the parts that don't use GHC API,
+   ‘haddock-api’ which are (some of) the parts that do use GHC API and
+   ‘haddock’ which merely provides the executable.
+
+ * Export few extra functions in the API.
+
+ * Add compatibility with GHC 7.8.2.
+
+ * Omit unnecessary ‘forall’s (#315 and #86)
+
+ * Remove some files which were really old or did not belong in the
+   repository in the first place.
+
+## Changes in version 2.14.3
+
+ * Fix parsing of identifiers with ^ or ⋆ in them (#298)
+
+ * Fix anchors (#308)
+
+## 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
+
+ * Display minimal complete definitions for type classes
+
+ * Hide right hand side of TF instances with hidden names on the RHS
+
+## Changes in version 2.14.0
+
+ * Print entities with missing documentation (#258)
+
+ * Print a warning message when given `-optghc` instead of `--optghc` (#5)
+
+ * Add `--compatible-interface-versions` (#231)
+
+ * Allow to generate latex documentation for FFI declarations (#247)
+
+ * Add copyright and license information to generated documentation
+
+ * Improved to Unicode support
+
+ * Bold markup support
+
+ * Nested paragraphs
+
+ * Better escaping
+
+ * Header markup
+
+ * Parser should no longer fail to parse any markup
+
+ * {-# OPTIONS_HADDOCK show-extensions #-} pragma will show the GHC extensions
+   enabled in the module.
+
+ * Properly render License field (#271)
+
+ * Print type/data family instances (for exported types only)
+
+ * Fix display of poly-kinded type operators (#189)
+
+ * PatternSynonyms support
+
+ * Fix display of implicit parameters (#260)
+
+ * Fix rendering of Contents when links are present (#276)
+
+ * Fix documentation duplication on record fields (#195)
+
+ * Add `--source-entity-line` for exact line links (eg. things defined
+   inside TH splices) (#79)
+
+ * Display fixity information for names with nonstandard fixities
+
+ * Bird tracks specified like "> code" no longer suffer from an extra leading
+   space in the code output
+
+## Changes in version 2.13.2
+
+ * Handle HsExplicitListTy in renamer (#213)
+
+ * Allow haddock markup in deprecation messages
+
+ * Export more types from Documentation.Haddock
+
+ * Include everything that is required to run the test suite with the cabal
+   package (#230)
+
+## Changes in version 2.13.1
+
+ * Hide instances that are "internal" to a module
+
+ * Add support for properties in documentation
+
+ * Fix a bug with spurious superclass constraints
+
+ * Fix and extend the Haddock API
+
+## Changes in version 2.12.0
+
+ * Labeled URLs (e.g <http://example.net/ some label>)
+
+ * Improved memory usage (new dependency: deepseq)
+
+## Changes in version 2.11.0
+
+ * Show deprecation messages for identifiers
+
+ * List identifiers declared on the same line (with a common type) separately
+
+ * Don't crash on unicode strings in doc comments
+
+ * Fix reporting of modules safe haskell mode
+
+ * Fix a case where we were generating invalid xhtml
+
+ * Improved --qual option (no crashes, proper error messages)
+
+ * 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
+
+ * Access to unexported identifiers through the Haddock API again
+
+## Changes in version 2.10.0
+
+ * Require GHC >= 7.4
+
+ * Safe Haskell indications on module pages
+
+ * Type declarations on identifiers no longer necessary
+
+ * Add flag --interface-version
+
+ * Warn when comment refers to in-scope identifier without documentation
+
+ * Bug fix: links to out-of-scope things (#78)
+
+ * Bug fix: module references to other packages work again
+
+## Changes in version 2.9.4
+
+  * Require GHC >= 7.2
+
+  * Support Alex 3.x
+
+## Changes in version 2.9.3
+
+  [This is the version that comes with GHC 7.2.1 although it claims it's 2.9.2!]
+
+  * Build with GHC 7.2.1
+
+  * Support blank lines in results of examples
+
+  * A type signature for multiple names generates one signature in the output
+
+  * Minor bug fixes
+
+## Changes in version 2.9.2
+
+  * Build with GHC 7.0.2
+
+  * Write Hoogle output in utf8; fixes GHC build on Windows
+
+## Changes in version 2.9.1
+
+  * Fix build in GHC tree
+
+  * Improve .cabal file
+
+## Changes in version 2.9.0
+
+  * Drop support for ghc < 7
+
+  * New flag --qual for qualification of names
+
+  * Print doc coverage information to stdout when generating docs
+
+  * Include an 'All' option in the A-Z subdivided index
+
+  * Make TOC group header identifiers validate
+
+  * Minor changes to the API
+
+## Changes in the version that comes with GHC 7.0.1
+
+  [This version claims it is 2.8.0 but is actually based on 2.8.1]
+
+  * Fix URL creation on Windows: Use / not \ in URLs.
+
+  * Support GHC 7.0
+
+## Changes in version 2.8.1
+
+  * Fix build on Windows with MinGW
+
+## Changes in version 2.8.0
+
+  * HTML backend completely rewritten to generate semantically rich XHTML
+    using the xhtml package.
+
+  * New default CSS based on the color scheme chosen for the new Haskell
+    wiki, with a pull-out tab for the synopsis.
+
+  * Theme engine based on CSS files. Themes can be switched from the
+    header menu. (New flags --built-in-themes and --theme. The latter
+    is an alias for --css which now has extended semantics).
+
+  * Markup support for executable examples/unit-tests. To be used with an
+    upcoming version of the DocTest program.
+
+  * Addition of a LaTeX backend.
+
+  * Frames-mode can be enabled from the header menu.
+
+  * Path to source entities can be specified per package, so that source
+    links work for cross-package documentation.
+
+  * Support for a second form of enumerated lists (1. 2. etc).
+
+  * Additions and changes to the Haddock API.
+
+  * New flag --no-tmp-comp-dir to tell Haddock to write and pick up
+    compilation files (.o, .hi, etc) to/from GHC's output directory instead
+    of a temporary directory.
+
+  * Various bug fixes.
+
+-----------------------------------------------------------------------------
+
+## Changes in version 2.6.1 (bug fix release from the stable branch)
+
+  * Fix #128
+
+-----------------------------------------------------------------------------
+
+## Changes in version 2.7.2
+
+  * Add Paths_haddock to library
+
+-----------------------------------------------------------------------------
+
+## Changes in version 2.7.1:
+
+  * Fix problems with library part of .cabal file
+
+-----------------------------------------------------------------------------
+
+## Changes in version 2.7.0:
+
+  * Instances can be commented
+
+  * The Haddock API now exposes more of the internals of Haddock
+
+  * Bug fixes (most importantly #128)
+
+-----------------------------------------------------------------------------
+
+## Changes in version 2.6.0:
+
+  * Drop support for GHC 6.10.*
+
+  * Add support for GHC 6.12.1
+
+  * Cross-package documentation: full documentation show up when re-exporting
+    things coming from external packages
+
+  * Lexing and parsing the Haddock comment markup is now done in Haddock
+    again, instead of in GHC
+
+  * Slightly prettier printing of instance heads
+
+  * Support platforms for which GHC has no native code generator
+
+  * Add a flag --print-ghc-libdir
+
+  * Minor bug fixes
+
+-----------------------------------------------------------------------------
+
+Changed in version 2.5.0:
+
+  * Drop support for GHC 6.8.*
+
+  * Add support for GHC 6.10.3 and 6.10.4
+
+  * Revert to the old multi-page index for large packages (#106)
+
+  * Show GADT records in the generated documentation
+
+  * Create output directory if it doesn't exist (#104)
+
+  * Use the native codegen instead of compiling via C for TH modules
+
+  * Add --use-unicode flag for displaying prettier versions of common symbols
+
+  * Multiple verbosity levels: remove --verbose and add --verbosity=n
+
+-----------------------------------------------------------------------------
+
+Changed in version 2.4.2:
+
+  * Support GHC 6.10.2
+
+  * Haddock no longer crashes on Template Haskell modules (#68)
+    (only with GHC 6.10.2 or above)
+
+  * Fix problem with Template Haskell-generated declarations disappearing (#59)
+
+  * Generate two anchors for each link for compatibility between IE and Opera
+    (#45)
+
+  * Improved error messages
+
+  * Show re-exports from external packages again (GHC ticket #2746)
+
+  * Store hidden modules in .haddock files again (needed by the haddock
+    library)
+
+  * Avoid processing boot modules
+
+  * Pragmas may exist between document comments and declarations
+
+  * Do not indicate that a constructor argument is unboxed
+
+  * Fix problem with non-working links to ghc-prim
+
+  * Allow referring to a specific section within a module in a module link
+    (#65)
+
+  * Fixes to the Hoogle backend
+
+  * Improvements to the haddock library
+
+  * Many other fixes (including #67, #69, #58, #57)
+
+-----------------------------------------------------------------------------
+
+Changed in version 2.4.1:
+
+  * Depend on base 4.* when GHC >= 6.9, otherwise 3.*
+
+-----------------------------------------------------------------------------
+
+Changed in version 2.4.0:
+
+  * Add framed view of the HTML documentation
+
+  * Build with GHC 6.8.2 and 6.8.3 again
+
+  * Support images in documentation comments again
+
+  * Small improvements to the Hoogle output
+
+  * A few bugs has been fixed
+
+-----------------------------------------------------------------------------
+
+Changed in version 2.3.0:
+
+  * Support for GHC 6.10.1
+
+  * Slightly improved space usage
+
+  * Fix a bug that made hidden modules show up in the contents & index pages
+
+  * Fix a bug that made Haddock load modules twice
+
+  * Improvements to the Hoogle output
+
+-----------------------------------------------------------------------------
+
+Changed in version 2.2.2:
+
+  * Relax version dependency on ghc-paths
+
+-----------------------------------------------------------------------------
+
+## Changes in version 2.2.1:
+
+  * Support for GHC 6.8.3
+
+  * The Hoogle backend is back, thanks to Neil Mitchell. The plan is to be
+    compatible with the upcoming Hoogle 4 pre-release
+
+  * Show associated types in the documentation for class declarations
+
+  * Show type family declarations
+
+  * Show type equality predicates
+
+  * Major bug fixes (#1 and #44)
+
+  * It is no longer required to specify the path to GHC's lib dir
+
+  * Remove unnecessary parenthesis in type signatures
+
+-----------------------------------------------------------------------------
+
+## Changes in version 2.1.0:
+
+  * Fix a bug that made links point to the defining module instead
+    of the "best" one (e.g Int pointing to GHC.Base instead of Data.Int)
+
+  * Fix a couple of smaller bugs
+
+  * The representation of DocName was changed in the library
+
+  * Add a flag --no-warnings for turning off warnings
+
+-----------------------------------------------------------------------------
+
+## Changes in version 2.0.0.0:
+
+  * The GHC API is used as the front-end
+
+  * Haddock now understands all syntax understood by GHC 6.8.2
+
+  * 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 specifying
+    module attributes is via a new OPTIONS_HADDOCK pragma. Example:
+    {-# OPTIONS_HADDOCK hide, prune #-}
+
+  * Haddock understands literate source files
+
+  * Add a small library to read Haddock's interface files
+
+  * Add a flag -B for passing the path to the GHC lib dir
+
+  * Add a flag --optghc for passing options to GHC
+
+  * Add a flag --ghc-version for printing the GHC version
+
+  * Remove --use-package, --allow-missing-html, --ghc-pkg, in favour of only
+    supporting --read-interface
+
+  * Remove --package flag, the GHC flag -package-name can be used instead
+
+  * Remove --no-implicit-prelude flag, the GHC flag -XNoImplicitPrelude can
+    be used instead
+
+-----------------------------------------------------------------------------
+
+## Changes in version 0.9:
+
+  * Infix type operators, e.g., first :: a~>a' -> (a,b)~>(a',b)
+
+  * Add a search box to the index page which automatically narrows
+    the index to the search as you type (thanks to Neil Mitchell).
+
+  * Add a --ghc-pkg flag
+
+  * Add a flag --allow-missing-html
+
+  * URL expansion for %%, %L, %{LINE}
+
+  * added substitution %{FILE///c}
+
+  * Lexing of /.../ is now more like '...', in that a / character must
+    be matched by another / character on the same line, otherwise it
+    is treated as a literal '/'.  This removes a common source of
+    accidental parse errors in documentation.
+
+  * Various bugs were fixed.
+
+  * Cabal 1.2 is now required, and Haddock builds with GHC 6.8.x.
+
+-----------------------------------------------------------------------------
+
+## Changes in version 0.8:
+
+  * Haddock has a Cabal build system, and will build on Windows without
+    Cygwin or MSYS.  GHC 6.4 or later is required.
+
+  * New options: --comments-base, --comments-module, --comments-entity
+    for generating links to pages (eg. wiki) for collecting user comments.
+
+  * New options: --source-base, --source-module, --source-entity
+    for generating links to source code.  Haddock now understands
+    {-# LINE #-} pragmas, which means it can figure out the correct
+    name for the source file even if the file is preprocessed.
+
+  * Haddock generates output for populating the Hoogle search engine.
+
+  * New markup <<url>> for including images.
+
+-----------------------------------------------------------------------------
+
+## Changes in version 0.7:
+
+  * ## Changes in the way Haddock decides where to direct hyperlinks.  Each entity
+    is now assigned a single "home" module, and all hyperlinks are directed
+    to that module.  See the docs ("Hyperlinking and re-exported entities")
+    for details.
+
+  * New options --ignore-all-exports, --hide
+
+  * New option --use-package for creating documentation that hyperlinks to
+    the HTML documentation for existing packages on your system.  It works
+    by querying ghc-pkg for the location of the Haddock interface and
+    HTML for the given package.
+
+  * Parts of the HTML documentation, notably lists of instances, are
+    now "collapsible" with a +/- button.  Also, the contents page is now
+    in the form of tree in which subtrees can be collapsed.
+
+  * Support for Microsoft DevHelp and HtmlHelp 2.0 formats.
+
+  * Support for a short description for each module for the contents page.
+
+  * Compiles with GHC 6.4+
+
+  * Various bugfixes
+
+-----------------------------------------------------------------------------
+
+## Changes in version 0.6:
+
+  * Implicit parameters, zip comprehensions and 'mdo' are now
+    supported by the parser.
+
+  * Some lexical bugs were fixed, mainly concerning literal paragraphs
+    next to non-literal paragraphs.
+
+  * New options:  --gen-index, --use-index, --gen-contents and --use-contents,
+    for generting a combined index and contents for several libraries
+    from the appropriate .haddock files.
+
+  * There is now one index rather than separate Function/Constructor and
+    Type/Class indices.  Where a name refers to several entities, these
+    are listed separately in the index.
+
+  * New option: -v, elicits more verbose warnings.  Some warnings are
+    now turned off by default; Haddock should be a little less noisy
+    in general.
+
+  * Markup for definition lists has been added.  See the documentation
+    for details.
+
+  * New option: --package for setting the package name.  The package
+    is listed alongside each module name in the combined contents.
+
+  * Entities which are re-exported from another package now at least
+    leave a hyperlink in the generated HTML, rather than nothing at all.
+
+  * Some fixes for bugs which caused incorrect hyperlinks in the
+    generated HTML.  In particular, instances should now be linked
+    correctly.
+
+  * Some aesthetic improvements to the generated HTML.
+
+-----------------------------------------------------------------------------
+
+## Changes in version 0.5:
+
+  * Compiles with recent versions of GHC.
+
+  * A few bugs have been fixed.
+
+  * New labelling/linking feature (see "Anchors" in the manual).
+
+-----------------------------------------------------------------------------
+
+## Changes in version 0.4:
+
+  * Import declarations which list entities in parentheses, or with
+    hiding clauses, are now properly supported.  Modulo one or two
+    small infelicities, the full Haskell modules system is now supported.
+
+  * Haddock is now more flexible about the placing of separators
+    (commas, semicolons) in relation to doc comments.
+
+  * There is support for generating and reading "interface files"
+    which describe the exports of a set of modules.  This is useful
+    for generating documentation which hyperlinks to
+    previously-generated documentation.
+
+  * Support for generating the extra files required by the Microsoft
+    Help compiler.
+
+  * New option: --prologue specifies a file of documentation which is
+    placed on the contents page.
+
+  * Many bugs fixed
+
+-----------------------------------------------------------------------------
+## Changes in version 0.3:
+
+  * Documentation on individual function arguments is now implemented
+
+  * Links can be made to identifiers that aren't in scope, by using
+    the fully qualified name.
+
+  * Instances are collected and listed with the appropriate classes
+    and datatypes (not for derived instances yet).
+
+  * Single quotes are only interpreted specially when they surround a
+    legal Haskell identifier, otherwise they are treated literally.
+
+  * Bird-tracked text is now literal.  If you want marked-up text in
+    a code block, use the @...@ notation instead.
+
+  * Various changes to the layout, it generally looks nicer now.
+
+  * Various bugs fixed.
+
+-----------------------------------------------------------------------------
+## Changes in version 0.2:
+
+  * The [...] markup for typewriter font has been changed to @...@.
+
+  * Module attributes introduced (see the documentation for details).
+
+  * {- ... -} style comments may now be used for documentation annotations
+
+  * Recursive modules are detected and reported as an error.
+
+  * Existential constructors and rank-N types are now groked by the parser
+
+  * Some type rendering cleaned up
+
+  * `abc' is accepted as well as 'abc' to markup an identifier
+
+  * Several bugs fixed, and error messages improved.
diff --git a/utils/haddock/CODE_OF_CONDUCT.md b/utils/haddock/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000000000000000000000000000000000000..5082492d3bfcbbc14ce3b0ad72d164358a5260d3
--- /dev/null
+++ b/utils/haddock/CODE_OF_CONDUCT.md
@@ -0,0 +1,33 @@
+# Conduct
+
+* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience,
+gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age,
+religion, nationality, or other similar characteristic.
+
+* Please avoid using overtly sexual aliases or other nicknames that might detract from a friendly, safe
+and welcoming environment for all.
+
+* Please be kind and courteous. There’s no need to be mean or rude.
+
+* Respect that people have differences of opinion and that every design or implementation choice carries a trade-off
+and numerous costs. There is seldom a right answer.
+
+* Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with,
+make a fork and see how it works.
+
+* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior.
+We interpret the term “harassment” as including the definition in the [Citizen Code of Conduct][CCC];
+if you have any lack of clarity about what might be included in that concept, please read their definition.
+In particular, we don’t tolerate behavior that excludes people in socially marginalized groups.
+
+* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or
+made uncomfortable by a community member, please contact one of the maintainers or any of the
+Core Team immediately. Whether you’re a regular contributor or a newcomer,
+we care about making this community a safe place for you and we’ve got your back.
+
+* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome.
+
+_Adapted from the [Rust Lang][Rust CoC]'s code of conduct_
+
+[CCC]: https://github.com/stumpsyn/policies/blob/master/citizen_code_of_conduct.md
+[Rust CoC]: https://www.rust-lang.org/policies/code-of-conduct
diff --git a/utils/haddock/CONTRIBUTING.md b/utils/haddock/CONTRIBUTING.md
new file mode 100644
index 0000000000000000000000000000000000000000..1a9ce05d7b92afc0434c3f230d1280b2489c3c21
--- /dev/null
+++ b/utils/haddock/CONTRIBUTING.md
@@ -0,0 +1,78 @@
+# Contributing to Haddock
+
+Thank you for contributing to Haddock! Here is the information you will need in
+order to make your contribution
+
+## Code of Conduct
+
+We need you to read, acknowledge, and abide by our [Code of Conduct][CoC].
+
+## Reporting issues
+
+Please open a ticket if you get an unexpected behaviour from Haddock!  
+You should ideally include a [Short, Self Contained, Correct (Compilable), Example][SSCCE]
+in your ticket, so that the maintainers may easily reproduce your issue.
+
+Here is a list of things you should include in your ticket
+
+* Your GHC version.
+
+* Your platform, OS and distribution if applicable.
+
+* Your cabal version if applicable.
+
+* Include any other info you think might be relevant (sandbox? unusual setup?).
+
+## Hacking
+
+To get started you'll need the latest GHC release installed.
+
+Clone the repository:
+
+```bash
+git clone https://github.com/haskell/haddock.git
+cd haddock
+```
+
+### Git Branches
+
+If your patch consists of glue code and interface changes with GHC, please
+open a Pull Request targeting the `ghc-head` branch.
+
+Otherwise, for improvements to the documentation generator,
+please base your pull request on the current GHC version branch
+(`ghc-9.0` for instance). The PR will be forward-ported to `ghc-head`
+so that documentation built within GHC can benefit from it.
+
+### Building the packages
+
+#### Using `cabal`
+
+Requires cabal `>= 3.4` and GHC `== 9.4`:
+
+You can install the latest build of GHC via ghcup using this command:
+
+```bash
+ghcup install ghc -u "https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-deb9-linux-integer-simple.tar.xz?job=validate-x86_64-linux-deb9-integer-simple" head
+```
+
+```bash
+cabal v2-build all --enable-tests
+cabal v2-test all
+```
+
+### Updating golden testsuite outputs
+
+If you've changed Haddock's output, you will probably need to accept the new
+output of Haddock's golden test suites (`html-test`, `latex-test`,
+`hoogle-test`, and `hypsrc-test`). This can be done by passing the `--accept`
+argument to these test suites. With a new enough version of `cabal-install`:
+
+```
+cabal v2-test html-test latex-test hoogle-test hypsrc-test \
+  --test-option='--accept'
+```
+
+
+[SSCCE]: http://sscce.org/
+[CoC]: ./CODE_OF_CONDUCT.md
diff --git a/utils/haddock/LICENSE b/utils/haddock/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..d5f0b37c4140c901b64760bfca422e1cd94a5e1c
--- /dev/null
+++ b/utils/haddock/LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2002-2010, Simon Marlow
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the
+   distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/utils/haddock/Makefile b/utils/haddock/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..839e7eca3af99f74a7b16d3018690929c1f4ca36
--- /dev/null
+++ b/utils/haddock/Makefile
@@ -0,0 +1,37 @@
+clean: ## Remove compilation artifacts
+	@cabal clean
+
+repl: ## Start a REPL
+	@cabal repl
+
+test: ## Run the test suite
+	@cabal test
+
+lint: ## Run the code linter (HLint)
+	@find driver haddock-api haddock-library haddock-test hoogle-test hypsrc-test latex-test \
+			-name "*.hs" | xargs -P $(PROCS) -I {} hlint --refactor-options="-i" --refactor {}
+
+style: ## Run the code styler (fourmolu and cabal-fmt)
+	@cabal-fmt -i **/*.cabal
+	@fourmolu -q --mode inplace driver haddock-api haddock-library
+
+style-check: ## Check the code's style (fourmolu and cabal-fmt)
+	@cabal-fmt -i **/*.cabal
+	@fourmolu -q --mode check driver haddock-api haddock-library
+
+style-quick: ## Run the code styler on modified files
+	@cabal-fmt -i **/*.cabal
+	@git diff origin --name-only driver haddock-api haddock-library | xargs -P $(PROCS) -I {} fourmolu -q -i {}
+
+tags: ## Generate ctags and etags for the source code (ghc-tags)
+	@ghc-tags -e -c
+
+help: ## Display this help message
+	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.* ?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
+
+PROCS := $(shell nproc)
+
+.PHONY: all $(MAKECMDGOALS)
+
+.DEFAULT_GOAL := help
+
diff --git a/utils/haddock/README.md b/utils/haddock/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..530e752d525b5ed0eb3d7acf7f828fdbca03e934
--- /dev/null
+++ b/utils/haddock/README.md
@@ -0,0 +1,34 @@
+# Haddock [![CI][CI badge]][CI page] [![Hackage][Hackage badge]][Hackage page]
+
+Haddock is the standard tool for generating documentation from Haskell code.
+Full documentation about Haddock itself can be found in the `doc/` subdirectory,
+in [reStructuredText][reST] format.
+
+## Project overview
+
+This project consists of three packages:
+
+ * `haddock`: provides the `haddock` executable. It is implemented as a tiny
+    wrapper around `haddock-api`'s `Documentation.Haddock.haddock` function.
+
+ * `haddock-api`: contains the program logic of the `haddock` tool.
+   [The haddocks for the `Documentation.Haddock` module][Documentation.Haddock]
+   offer a good overview of the functionality.
+
+ * `haddock-library`: is concerned with the parsing and processing of the
+   Haddock markup language. Unlike the other packages, it is expected to build
+   on a fairly wide range of GHC versions.
+
+## Contributing
+
+See [CONTRIBUTING.md](CONTRIBUTING.md) to see how to make contributions to the
+project.
+
+
+[CI page]: https://github.com/haskell/haddock/actions/workflows/ci.yml
+[CI badge]: https://github.com/haskell/haddock/actions/workflows/ci.yml/badge.svg
+[Hackage page]: https://hackage.haskell.org/package/haddock
+[Hackage badge]: https://img.shields.io/hackage/v/haddock.svg
+[reST]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html
+[Documentation.Haddock]: http://hackage.haskell.org/package/haddock-api/docs/Documentation-Haddock.html
+[cabal v2]: https://cabal.readthedocs.io/en/latest/nix-local-build-overview.html
diff --git a/utils/haddock/Setup.lhs b/utils/haddock/Setup.lhs
new file mode 100755
index 0000000000000000000000000000000000000000..5bde0de962274e26328ecffabb4e9f6430a10cc9
--- /dev/null
+++ b/utils/haddock/Setup.lhs
@@ -0,0 +1,3 @@
+#!/usr/bin/env runhaskell
+> import Distribution.Simple
+> main = defaultMain
diff --git a/utils/haddock/cabal.project b/utils/haddock/cabal.project
new file mode 100644
index 0000000000000000000000000000000000000000..28290fd794e84b6938c9dfcc8eb22b73e2798417
--- /dev/null
+++ b/utils/haddock/cabal.project
@@ -0,0 +1,23 @@
+with-compiler: ghc-9.7
+
+packages: ./
+          ./haddock-api
+          ./haddock-library
+          ./haddock-test
+
+test-show-details: direct
+
+allow-newer:
+  ghc-paths:Cabal,
+  *:base,
+  *:ghc-prim,
+  tree-diff:time
+
+package haddock-library
+  tests: False
+
+package haddock-api
+  tests: False
+
+-- Pinning the index-state helps to make reasonably CI deterministic
+index-state: 2023-05-22T15:14:29Z
diff --git a/utils/haddock/doc/.gitignore b/utils/haddock/doc/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..1bf230d147120099ce62b23c52fc512c5c631636
--- /dev/null
+++ b/utils/haddock/doc/.gitignore
@@ -0,0 +1 @@
+.build-html
\ No newline at end of file
diff --git a/utils/haddock/doc/Makefile b/utils/haddock/doc/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..f4356f438237270055fcf143cc4dd339e5cb5c8f
--- /dev/null
+++ b/utils/haddock/doc/Makefile
@@ -0,0 +1,8 @@
+SPHINX_BUILD ?= sphinx-build
+
+all : html
+
+.PHONY : html
+
+html :
+	$(SPHINX_BUILD) -b html . .build-html
diff --git a/utils/haddock/doc/README.md b/utils/haddock/doc/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..947d7f931c14520d5f7e94cd420933a154f8c41d
--- /dev/null
+++ b/utils/haddock/doc/README.md
@@ -0,0 +1,10 @@
+# Haddock documentation
+
+The documentation is in ReStructuredText format. You need
+[Sphinx](http://www.sphinx-doc.org/) to process it. To build the HTML
+documentation,
+
+    $ make html
+
+which leaves the HTML documentation the `.build-html/` subdirectory.
+
diff --git a/utils/haddock/doc/cheatsheet/LICENSE b/utils/haddock/doc/cheatsheet/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..fd662a7e6c628e351ccd072bf4a30710d36f4556
--- /dev/null
+++ b/utils/haddock/doc/cheatsheet/LICENSE
@@ -0,0 +1,428 @@
+Attribution-ShareAlike 4.0 International
+
+=======================================================================
+
+Creative Commons Corporation ("Creative Commons") is not a law firm and
+does not provide legal services or legal advice. Distribution of
+Creative Commons public licenses does not create a lawyer-client or
+other relationship. Creative Commons makes its licenses and related
+information available on an "as-is" basis. Creative Commons gives no
+warranties regarding its licenses, any material licensed under their
+terms and conditions, or any related information. Creative Commons
+disclaims all liability for damages resulting from their use to the
+fullest extent possible.
+
+Using Creative Commons Public Licenses
+
+Creative Commons public licenses provide a standard set of terms and
+conditions that creators and other rights holders may use to share
+original works of authorship and other material subject to copyright
+and certain other rights specified in the public license below. The
+following considerations are for informational purposes only, are not
+exhaustive, and do not form part of our licenses.
+
+     Considerations for licensors: Our public licenses are
+     intended for use by those authorized to give the public
+     permission to use material in ways otherwise restricted by
+     copyright and certain other rights. Our licenses are
+     irrevocable. Licensors should read and understand the terms
+     and conditions of the license they choose before applying it.
+     Licensors should also secure all rights necessary before
+     applying our licenses so that the public can reuse the
+     material as expected. Licensors should clearly mark any
+     material not subject to the license. This includes other CC-
+     licensed material, or material used under an exception or
+     limitation to copyright. More considerations for licensors:
+	wiki.creativecommons.org/Considerations_for_licensors
+
+     Considerations for the public: By using one of our public
+     licenses, a licensor grants the public permission to use the
+     licensed material under specified terms and conditions. If
+     the licensor's permission is not necessary for any reason--for
+     example, because of any applicable exception or limitation to
+     copyright--then that use is not regulated by the license. Our
+     licenses grant only permissions under copyright and certain
+     other rights that a licensor has authority to grant. Use of
+     the licensed material may still be restricted for other
+     reasons, including because others have copyright or other
+     rights in the material. A licensor may make special requests,
+     such as asking that all changes be marked or described.
+     Although not required by our licenses, you are encouraged to
+     respect those requests where reasonable. More_considerations
+     for the public: 
+	wiki.creativecommons.org/Considerations_for_licensees
+
+=======================================================================
+
+Creative Commons Attribution-ShareAlike 4.0 International Public
+License
+
+By exercising the Licensed Rights (defined below), You accept and agree
+to be bound by the terms and conditions of this Creative Commons
+Attribution-ShareAlike 4.0 International Public License ("Public
+License"). To the extent this Public License may be interpreted as a
+contract, You are granted the Licensed Rights in consideration of Your
+acceptance of these terms and conditions, and the Licensor grants You
+such rights in consideration of benefits the Licensor receives from
+making the Licensed Material available under these terms and
+conditions.
+
+
+Section 1 -- Definitions.
+
+  a. Adapted Material means material subject to Copyright and Similar
+     Rights that is derived from or based upon the Licensed Material
+     and in which the Licensed Material is translated, altered,
+     arranged, transformed, or otherwise modified in a manner requiring
+     permission under the Copyright and Similar Rights held by the
+     Licensor. For purposes of this Public License, where the Licensed
+     Material is a musical work, performance, or sound recording,
+     Adapted Material is always produced where the Licensed Material is
+     synched in timed relation with a moving image.
+
+  b. Adapter's License means the license You apply to Your Copyright
+     and Similar Rights in Your contributions to Adapted Material in
+     accordance with the terms and conditions of this Public License.
+
+  c. BY-SA Compatible License means a license listed at
+     creativecommons.org/compatiblelicenses, approved by Creative
+     Commons as essentially the equivalent of this Public License.
+
+  d. Copyright and Similar Rights means copyright and/or similar rights
+     closely related to copyright including, without limitation,
+     performance, broadcast, sound recording, and Sui Generis Database
+     Rights, without regard to how the rights are labeled or
+     categorized. For purposes of this Public License, the rights
+     specified in Section 2(b)(1)-(2) are not Copyright and Similar
+     Rights.
+
+  e. Effective Technological Measures means those measures that, in the
+     absence of proper authority, may not be circumvented under laws
+     fulfilling obligations under Article 11 of the WIPO Copyright
+     Treaty adopted on December 20, 1996, and/or similar international
+     agreements.
+
+  f. Exceptions and Limitations means fair use, fair dealing, and/or
+     any other exception or limitation to Copyright and Similar Rights
+     that applies to Your use of the Licensed Material.
+
+  g. License Elements means the license attributes listed in the name
+     of a Creative Commons Public License. The License Elements of this
+     Public License are Attribution and ShareAlike.
+
+  h. Licensed Material means the artistic or literary work, database,
+     or other material to which the Licensor applied this Public
+     License.
+
+  i. Licensed Rights means the rights granted to You subject to the
+     terms and conditions of this Public License, which are limited to
+     all Copyright and Similar Rights that apply to Your use of the
+     Licensed Material and that the Licensor has authority to license.
+
+  j. Licensor means the individual(s) or entity(ies) granting rights
+     under this Public License.
+
+  k. Share means to provide material to the public by any means or
+     process that requires permission under the Licensed Rights, such
+     as reproduction, public display, public performance, distribution,
+     dissemination, communication, or importation, and to make material
+     available to the public including in ways that members of the
+     public may access the material from a place and at a time
+     individually chosen by them.
+
+  l. Sui Generis Database Rights means rights other than copyright
+     resulting from Directive 96/9/EC of the European Parliament and of
+     the Council of 11 March 1996 on the legal protection of databases,
+     as amended and/or succeeded, as well as other essentially
+     equivalent rights anywhere in the world.
+
+  m. You means the individual or entity exercising the Licensed Rights
+     under this Public License. Your has a corresponding meaning.
+
+
+Section 2 -- Scope.
+
+  a. License grant.
+
+       1. Subject to the terms and conditions of this Public License,
+          the Licensor hereby grants You a worldwide, royalty-free,
+          non-sublicensable, non-exclusive, irrevocable license to
+          exercise the Licensed Rights in the Licensed Material to:
+
+            a. reproduce and Share the Licensed Material, in whole or
+               in part; and
+
+            b. produce, reproduce, and Share Adapted Material.
+
+       2. Exceptions and Limitations. For the avoidance of doubt, where
+          Exceptions and Limitations apply to Your use, this Public
+          License does not apply, and You do not need to comply with
+          its terms and conditions.
+
+       3. Term. The term of this Public License is specified in Section
+          6(a).
+
+       4. Media and formats; technical modifications allowed. The
+          Licensor authorizes You to exercise the Licensed Rights in
+          all media and formats whether now known or hereafter created,
+          and to make technical modifications necessary to do so. The
+          Licensor waives and/or agrees not to assert any right or
+          authority to forbid You from making technical modifications
+          necessary to exercise the Licensed Rights, including
+          technical modifications necessary to circumvent Effective
+          Technological Measures. For purposes of this Public License,
+          simply making modifications authorized by this Section 2(a)
+          (4) never produces Adapted Material.
+
+       5. Downstream recipients.
+
+            a. Offer from the Licensor -- Licensed Material. Every
+               recipient of the Licensed Material automatically
+               receives an offer from the Licensor to exercise the
+               Licensed Rights under the terms and conditions of this
+               Public License.
+
+            b. Additional offer from the Licensor -- Adapted Material.
+               Every recipient of Adapted Material from You
+               automatically receives an offer from the Licensor to
+               exercise the Licensed Rights in the Adapted Material
+               under the conditions of the Adapter's License You apply.
+
+            c. No downstream restrictions. You may not offer or impose
+               any additional or different terms or conditions on, or
+               apply any Effective Technological Measures to, the
+               Licensed Material if doing so restricts exercise of the
+               Licensed Rights by any recipient of the Licensed
+               Material.
+
+       6. No endorsement. Nothing in this Public License constitutes or
+          may be construed as permission to assert or imply that You
+          are, or that Your use of the Licensed Material is, connected
+          with, or sponsored, endorsed, or granted official status by,
+          the Licensor or others designated to receive attribution as
+          provided in Section 3(a)(1)(A)(i).
+
+  b. Other rights.
+
+       1. Moral rights, such as the right of integrity, are not
+          licensed under this Public License, nor are publicity,
+          privacy, and/or other similar personality rights; however, to
+          the extent possible, the Licensor waives and/or agrees not to
+          assert any such rights held by the Licensor to the limited
+          extent necessary to allow You to exercise the Licensed
+          Rights, but not otherwise.
+
+       2. Patent and trademark rights are not licensed under this
+          Public License.
+
+       3. To the extent possible, the Licensor waives any right to
+          collect royalties from You for the exercise of the Licensed
+          Rights, whether directly or through a collecting society
+          under any voluntary or waivable statutory or compulsory
+          licensing scheme. In all other cases the Licensor expressly
+          reserves any right to collect such royalties.
+
+
+Section 3 -- License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the
+following conditions.
+
+  a. Attribution.
+
+       1. If You Share the Licensed Material (including in modified
+          form), You must:
+
+            a. retain the following if it is supplied by the Licensor
+               with the Licensed Material:
+
+                 i. identification of the creator(s) of the Licensed
+                    Material and any others designated to receive
+                    attribution, in any reasonable manner requested by
+                    the Licensor (including by pseudonym if
+                    designated);
+
+                ii. a copyright notice;
+
+               iii. a notice that refers to this Public License;
+
+                iv. a notice that refers to the disclaimer of
+                    warranties;
+
+                 v. a URI or hyperlink to the Licensed Material to the
+                    extent reasonably practicable;
+
+            b. indicate if You modified the Licensed Material and
+               retain an indication of any previous modifications; and
+
+            c. indicate the Licensed Material is licensed under this
+               Public License, and include the text of, or the URI or
+               hyperlink to, this Public License.
+
+       2. You may satisfy the conditions in Section 3(a)(1) in any
+          reasonable manner based on the medium, means, and context in
+          which You Share the Licensed Material. For example, it may be
+          reasonable to satisfy the conditions by providing a URI or
+          hyperlink to a resource that includes the required
+          information.
+
+       3. If requested by the Licensor, You must remove any of the
+          information required by Section 3(a)(1)(A) to the extent
+          reasonably practicable.
+
+  b. ShareAlike.
+
+     In addition to the conditions in Section 3(a), if You Share
+     Adapted Material You produce, the following conditions also apply.
+
+       1. The Adapter's License You apply must be a Creative Commons
+          license with the same License Elements, this version or
+          later, or a BY-SA Compatible License.
+
+       2. You must include the text of, or the URI or hyperlink to, the
+          Adapter's License You apply. You may satisfy this condition
+          in any reasonable manner based on the medium, means, and
+          context in which You Share Adapted Material.
+
+       3. You may not offer or impose any additional or different terms
+          or conditions on, or apply any Effective Technological
+          Measures to, Adapted Material that restrict exercise of the
+          rights granted under the Adapter's License You apply.
+
+
+Section 4 -- Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that
+apply to Your use of the Licensed Material:
+
+  a. for the avoidance of doubt, Section 2(a)(1) grants You the right
+     to extract, reuse, reproduce, and Share all or a substantial
+     portion of the contents of the database;
+
+  b. if You include all or a substantial portion of the database
+     contents in a database in which You have Sui Generis Database
+     Rights, then the database in which You have Sui Generis Database
+     Rights (but not its individual contents) is Adapted Material,
+
+     including for purposes of Section 3(b); and
+  c. You must comply with the conditions in Section 3(a) if You Share
+     all or a substantial portion of the contents of the database.
+
+For the avoidance of doubt, this Section 4 supplements and does not
+replace Your obligations under this Public License where the Licensed
+Rights include other Copyright and Similar Rights.
+
+
+Section 5 -- Disclaimer of Warranties and Limitation of Liability.
+
+  a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
+     EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
+     AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
+     ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
+     IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
+     WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
+     PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
+     ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
+     KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
+     ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
+
+  b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
+     TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
+     NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
+     INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
+     COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
+     USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
+     ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
+     DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
+     IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
+
+  c. The disclaimer of warranties and limitation of liability provided
+     above shall be interpreted in a manner that, to the extent
+     possible, most closely approximates an absolute disclaimer and
+     waiver of all liability.
+
+
+Section 6 -- Term and Termination.
+
+  a. This Public License applies for the term of the Copyright and
+     Similar Rights licensed here. However, if You fail to comply with
+     this Public License, then Your rights under this Public License
+     terminate automatically.
+
+  b. Where Your right to use the Licensed Material has terminated under
+     Section 6(a), it reinstates:
+
+       1. automatically as of the date the violation is cured, provided
+          it is cured within 30 days of Your discovery of the
+          violation; or
+
+       2. upon express reinstatement by the Licensor.
+
+     For the avoidance of doubt, this Section 6(b) does not affect any
+     right the Licensor may have to seek remedies for Your violations
+     of this Public License.
+
+  c. For the avoidance of doubt, the Licensor may also offer the
+     Licensed Material under separate terms or conditions or stop
+     distributing the Licensed Material at any time; however, doing so
+     will not terminate this Public License.
+
+  d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
+     License.
+
+
+Section 7 -- Other Terms and Conditions.
+
+  a. The Licensor shall not be bound by any additional or different
+     terms or conditions communicated by You unless expressly agreed.
+
+  b. Any arrangements, understandings, or agreements regarding the
+     Licensed Material not stated herein are separate from and
+     independent of the terms and conditions of this Public License.
+
+
+Section 8 -- Interpretation.
+
+  a. For the avoidance of doubt, this Public License does not, and
+     shall not be interpreted to, reduce, limit, restrict, or impose
+     conditions on any use of the Licensed Material that could lawfully
+     be made without permission under this Public License.
+
+  b. To the extent possible, if any provision of this Public License is
+     deemed unenforceable, it shall be automatically reformed to the
+     minimum extent necessary to make it enforceable. If the provision
+     cannot be reformed, it shall be severed from this Public License
+     without affecting the enforceability of the remaining terms and
+     conditions.
+
+  c. No term or condition of this Public License will be waived and no
+     failure to comply consented to unless expressly agreed to by the
+     Licensor.
+
+  d. Nothing in this Public License constitutes or may be interpreted
+     as a limitation upon, or waiver of, any privileges and immunities
+     that apply to the Licensor or You, including from the legal
+     processes of any jurisdiction or authority.
+
+
+=======================================================================
+
+Creative Commons is not a party to its public
+licenses. Notwithstanding, Creative Commons may elect to apply one of
+its public licenses to material it publishes and in those instances
+will be considered the “Licensor.” The text of the Creative Commons
+public licenses is dedicated to the public domain under the CC0 Public
+Domain Dedication. Except for the limited purpose of indicating that
+material is shared under a Creative Commons public license or as
+otherwise permitted by the Creative Commons policies published at
+creativecommons.org/policies, Creative Commons does not authorize the
+use of the trademark "Creative Commons" or any other trademark or logo
+of Creative Commons without its prior written consent including,
+without limitation, in connection with any unauthorized modifications
+to any of its public licenses or any other arrangements,
+understandings, or agreements concerning use of licensed material. For
+the avoidance of doubt, this paragraph does not form part of the
+public licenses.
+
+Creative Commons may be contacted at creativecommons.org.
+
diff --git a/utils/haddock/doc/cheatsheet/README.md b/utils/haddock/doc/cheatsheet/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..c585621729a100a92426a813b736f3370650bec5
--- /dev/null
+++ b/utils/haddock/doc/cheatsheet/README.md
@@ -0,0 +1,9 @@
+![License: CC BY-SA 4.0](https://img.shields.io/badge/License-CC%20BY--SA%204.0-lightgrey.svg)
+
+# Haddock Markup Quick Reference
+
+This page is a single-page quick reference for the markup used in GHC's [Haddock](https://www.haskell.org/haddock/) documentation format. It doesn't list all the details of the format, just the basic markup, so for the vagaries and edge-cases of the syntax, it would be helpful to consult the [Haddock user guide](http://haskell-haddock.readthedocs.io/en/latest/index.html).
+
+## License
+
+This document is licensed under the CC BY-SA 4.0 license.
diff --git a/utils/haddock/doc/cheatsheet/haddocks.md b/utils/haddock/doc/cheatsheet/haddocks.md
new file mode 100644
index 0000000000000000000000000000000000000000..1b4f85180801e5957347a1e3dfd1875437eb131b
--- /dev/null
+++ b/utils/haddock/doc/cheatsheet/haddocks.md
@@ -0,0 +1,136 @@
+# Code Sections
+
+```
+  -- * Section
+  -- ** Sub-section
+  -- *** Sub-sub-section
+  -- et cetera
+```
+
+# Named Documentation Chunks
+
+```
+  -- $name
+[...]
+  -- $name
+  -- Here is the documentation text
+  -- which is embedded elsewhere
+```
+
+# Code Blocks
+
+```
+With internal markup:
+  -- @
+  --   fact n = product [1..n]
+  -- @
+With literal text:
+  -- > fact n = product [1..n]
+```
+
+# REPL Examples
+
+```
+  -- >>> fact 5
+  -- 120
+```
+
+# Properties
+
+```
+  -- prop> a + b = b + a
+```
+
+# Hyperlinked Identifiers
+
+```
+  -- The value 'x' of type 'T'
+  -- The out-of-scope 'MyModule.x'
+  -- The "MyModule" module
+```
+
+# Textual Markup
+
+```
+  -- Emphasis: /forward slashes/.
+  -- Bolding: __underscores__.
+  -- Monospaced text: @ampersands@.
+```
+
+# Links and Images
+
+```
+  -- A raw link <http://example.com>
+  -- [a link](http://example.com)
+  -- ![description](imagepath.png)
+```
+
+# Lists
+
+```
+itemized with "*" or "-"
+  -- * first item
+  -- * second item
+numbered with "(n)" or "n."
+  -- 1. first item
+  -- 2. second item
+definitions with "[thing]"
+  -- [one] first item
+  -- [two] second item
+```
+
+# Mathematics/LaTeX
+
+```
+  -- \[
+  --   f(n) = \Sum_{i=1}^{n} i
+  -- \]
+  -- when \(n > 0\)
+```
+
+# Headings in Documentation
+
+```
+  -- = Heading
+  -- == Sub-heading
+  -- === Sub-sub-heading
+```
+
+# Metadata
+
+```
+  -- @since 1.2.3
+```
+
+# Module Attributes
+
+```
+{-# OPTIONS_HADDOCK hide #-}
+  Omit this module from the docs
+{-# OPTIONS_HADDOCK prune #-}
+  Omit definitions without docs
+{-# OPTIONS_HADDOCK not-home #-}
+  Do not treat this module as the
+  "home" of identifiers it exports
+{-# OPTIONS_HADDOCK show-extensions #-}
+  Show all enabled LANGUAGE extensions
+{-# OPTIONS_HADDOCK print-explicit-runtime-reps #-}
+  Show all `RuntimeRep` type variables
+```
+
+# Grid tables
+
+```
++------------------------+------------+----------+----------+
+| Header row, column 1   | Header 2   | Header 3 | Header 4 |
+| (header rows optional) |            |          |          |
++========================+============+==========+==========+
+| body row 1, column 1   | column 2   | column 3 | column 4 |
++------------------------+------------+----------+----------+
+| body row 2             | Cells may span columns.          |
++------------------------+------------+---------------------+
+| body row 3             | Cells may  | \[                  |
++------------------------+ span rows. | f(n) = \sum_{i=1}   |
+| body row 4             |            | \]                  |
++------------------------+------------+---------------------+
+```
diff --git a/utils/haddock/doc/cheatsheet/haddocks.pdf b/utils/haddock/doc/cheatsheet/haddocks.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..130e85959cb6f5edd84498f30ff8976d0040a459
Binary files /dev/null and b/utils/haddock/doc/cheatsheet/haddocks.pdf differ
diff --git a/utils/haddock/doc/cheatsheet/haddocks.svg b/utils/haddock/doc/cheatsheet/haddocks.svg
new file mode 100644
index 0000000000000000000000000000000000000000..ea08781fff46c7809bdcf9e804bf92bfb475ab38
--- /dev/null
+++ b/utils/haddock/doc/cheatsheet/haddocks.svg
@@ -0,0 +1,624 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="8.5in"
+   height="11in"
+   viewBox="0 0 170 220"
+   version="1.1"
+   id="svg8"
+   inkscape:version="0.92.1 r"
+   sodipodi:docname="haddocks.svg"
+   inkscape:export-filename="/home/gdritter/projects/haddock-cheatsheet/haddocks.png"
+   inkscape:export-xdpi="100"
+   inkscape:export-ydpi="100">
+  <defs
+     id="defs2" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.99607843"
+     inkscape:pageshadow="2"
+     inkscape:zoom="1.1689792"
+     inkscape:cx="338.82394"
+     inkscape:cy="776.62735"
+     inkscape:document-units="in"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:snap-smooth-nodes="true"
+     inkscape:snap-intersection-paths="true"
+     units="in"
+     scale-x="20"
+     inkscape:window-width="1918"
+     inkscape:window-height="1036"
+     inkscape:window-x="0"
+     inkscape:window-y="42"
+     inkscape:window-maximized="0"
+     showguides="true"
+     inkscape:guide-bbox="true">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4485" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata5">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-17.599983)">
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="9.2960958"
+       y="44.426563"
+       id="text4489"><tspan
+         sodipodi:role="line"
+         x="9.2960958"
+         y="44.426563"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         id="tspan4497">Code Sections</tspan><tspan
+         sodipodi:role="line"
+         x="9.2960958"
+         y="49.229057"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4507">  -- * Section</tspan><tspan
+         sodipodi:role="line"
+         x="9.2960958"
+         y="54.461079"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4511">  -- ** Sub-section</tspan><tspan
+         sodipodi:role="line"
+         x="9.2960958"
+         y="59.6931"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4513">  -- *** Sub-sub-section</tspan><tspan
+         sodipodi:role="line"
+         x="9.2960958"
+         y="64.925117"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4515">  -- et cetera</tspan></text>
+    <text
+       id="text4569"
+       y="70.848915"
+       x="9.3546734"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="70.848915"
+         x="9.3546734"
+         sodipodi:role="line"
+         id="tspan4753">Named Documentation Chunks</tspan><tspan
+         id="tspan4567"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82077742px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="75.651405"
+         x="9.3546734"
+         sodipodi:role="line">  -- $name</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82077742px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="80.955017"
+         x="9.3546734"
+         sodipodi:role="line"
+         id="tspan4580"><tspan
+           style="font-size:2.82077742px;fill:#808080;stroke-width:0.24425368px"
+           id="tspan4586">[...]</tspan></tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82077742px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="86.258629"
+         x="9.3546734"
+         sodipodi:role="line"
+         id="tspan4578">  -- $name</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82077742px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="91.562233"
+         x="9.3546734"
+         sodipodi:role="line"
+         id="tspan4582">  -- Here is the documentation text</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82077742px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="96.865845"
+         x="9.3546734"
+         sodipodi:role="line"
+         id="tspan4584">  -- which is embedded elsewhere</tspan></text>
+    <text
+       id="text4661"
+       y="102.25972"
+       x="9.3546734"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         id="tspan4647"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="102.25972"
+         x="9.3546734"
+         sodipodi:role="line">Code Blocks</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';fill:#808080;stroke-width:0.24425368px"
+         y="107.06221"
+         x="9.3546734"
+         sodipodi:role="line"
+         id="tspan4649">With internal markup:</tspan><tspan
+         id="tspan4651"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="112.29424"
+         x="9.3546734"
+         sodipodi:role="line">  -- @</tspan><tspan
+         id="tspan4653"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="117.52625"
+         x="9.3546734"
+         sodipodi:role="line">  --   fact n = product [1..n]</tspan><tspan
+         id="tspan4655"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="122.75829"
+         x="9.3546734"
+         sodipodi:role="line">  -- @</tspan><tspan
+         id="tspan4657"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';fill:#808080;stroke-width:0.24425368px"
+         y="127.9903"
+         x="9.3546734"
+         sodipodi:role="line">With literal text:</tspan><tspan
+         id="tspan4659"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="133.22232"
+         x="9.3546734"
+         sodipodi:role="line">  -- &gt; fact n = product [1..n]</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="9.3546734"
+       y="140.30173"
+       id="text4602"><tspan
+         sodipodi:role="line"
+         x="9.3546734"
+         y="140.30173"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         id="tspan4588">REPL Examples</tspan><tspan
+         sodipodi:role="line"
+         x="9.3546734"
+         y="145.10422"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4629">  -- &gt;&gt;&gt; fact 5</tspan><tspan
+         sodipodi:role="line"
+         x="9.3546734"
+         y="150.33624"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4674">  -- 120</tspan></text>
+    <text
+       id="text4692"
+       y="156.90796"
+       x="9.3546734"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         id="tspan4680"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="156.90796"
+         x="9.3546734"
+         sodipodi:role="line">Properties</tspan><tspan
+         id="tspan4690"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="161.71045"
+         x="9.3546734"
+         sodipodi:role="line">  -- prop&gt; a + b = b + a</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:23.3177433px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24289316px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="9.5486708"
+       y="169.6808"
+       id="text4731"><tspan
+         sodipodi:role="line"
+         x="9.5486708"
+         y="169.6808"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.59010696px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24289316px"
+         id="tspan4727">Hyperlinked Identifiers</tspan><tspan
+         sodipodi:role="line"
+         x="9.5486708"
+         y="174.45654"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.06007123px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24289316px"
+         id="tspan4729">  -- The value 'x' of type 'T'</tspan><tspan
+         sodipodi:role="line"
+         x="9.5486708"
+         y="179.65942"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.06007123px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24289316px"
+         id="tspan4733">  -- The out-of-scope 'MyModule.x'</tspan><tspan
+         sodipodi:role="line"
+         x="9.5486708"
+         y="184.8623"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.06007123px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24289316px"
+         id="tspan4747">  -- The &quot;MyModule&quot; module</tspan></text>
+    <text
+       id="text4741"
+       y="192.34953"
+       x="9.3546734"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         id="tspan4735"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="192.34953"
+         x="9.3546734"
+         sodipodi:role="line">Textual Markup</tspan><tspan
+         id="tspan4737"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="197.15202"
+         x="9.3546734"
+         sodipodi:role="line">  -- Emphasis: /forward slashes/.</tspan><tspan
+         id="tspan4739"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="202.38405"
+         x="9.3546734"
+         sodipodi:role="line">  -- Bolding: __underscores__.</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="207.61607"
+         x="9.3546734"
+         sodipodi:role="line"
+         id="tspan4745">  -- Monospaced text: @at signs@.</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="9.3546734"
+       y="215.33546"
+       id="text4771"><tspan
+         sodipodi:role="line"
+         x="9.3546734"
+         y="215.33546"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         id="tspan4763">Links and Images</tspan><tspan
+         id="tspan4769"
+         sodipodi:role="line"
+         x="9.3546734"
+         y="220.13795"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px">  -- A raw link &lt;http://example.com&gt;</tspan><tspan
+         sodipodi:role="line"
+         x="9.3546734"
+         y="225.36998"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4780">  -- [a link](http://example.com)</tspan><tspan
+         sodipodi:role="line"
+         x="9.3546734"
+         y="230.60201"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4778">  -- ![description](imagepath.png)</tspan></text>
+    <text
+       id="text4806"
+       y="44.426563"
+       x="89.102867"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         id="tspan4796"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="44.426563"
+         x="89.102867"
+         sodipodi:role="line">Lists</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="49.229057"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan4812" /><tspan
+         id="tspan4798"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';fill:#808080;stroke-width:0.24425368px"
+         y="49.229057"
+         x="89.102867"
+         sodipodi:role="line">itemized with &quot;*&quot; or &quot;-&quot;</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="54.461079"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan4814">  -- * first item</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="59.6931"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan4810">  -- * second item</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';fill:#808080;stroke-width:0.24425368px"
+         y="64.925117"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan4816">numbered with &quot;(n)&quot; or &quot;n.&quot;</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="70.157143"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan4818">  -- 1. first item</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="75.38916"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan4822">  -- 2. second item</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';fill:#808080;stroke-width:0.24425368px"
+         y="80.621185"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan4826">definitions with &quot;[thing]&quot;</tspan><tspan
+         id="tspan4804"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="85.853203"
+         x="89.102867"
+         sodipodi:role="line">  -- [one] first item</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="91.085228"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan4834">  -- [two] second item</tspan></text>
+    <text
+       id="text4936"
+       y="98.872009"
+       x="89.102867"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         id="tspan4920"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="98.872009"
+         x="89.102867"
+         sodipodi:role="line">Mathematics/LaTeX</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="103.6745"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan4922" /><tspan
+         id="tspan4924"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="103.6745"
+         x="89.102867"
+         sodipodi:role="line" /><tspan
+         id="tspan4926"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="103.6745"
+         x="89.102867"
+         sodipodi:role="line">  -- \[</tspan><tspan
+         id="tspan4928"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="108.90652"
+         x="89.102867"
+         sodipodi:role="line">  --   f(n) = \Sum_{i=1}^{n} i</tspan><tspan
+         id="tspan4930"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="114.13854"
+         x="89.102867"
+         sodipodi:role="line">  -- \]</tspan><tspan
+         id="tspan4934"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="119.37056"
+         x="89.102867"
+         sodipodi:role="line">  -- when \(n &gt; 0\)</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="89.102867"
+       y="126.79274"
+       id="text4984"><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="126.79274"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         id="tspan4970">Headings in Documentation</tspan><tspan
+         id="tspan4972"
+         sodipodi:role="line"
+         x="89.102867"
+         y="131.59523"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px" /><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="131.59523"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4974" /><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="131.59523"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4982">  -- = Heading</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="136.82726"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4995">  -- == Sub-heading</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="142.05928"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan4997">  -- === sub-sub-heading</tspan></text>
+    <text
+       id="text5011"
+       y="149.362"
+       x="89.102867"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         id="tspan4999"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="149.362"
+         x="89.102867"
+         sodipodi:role="line">Metadata</tspan><tspan
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         y="154.16449"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan5001" /><tspan
+         id="tspan5009"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="154.16449"
+         x="89.102867"
+         sodipodi:role="line" /><tspan
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         y="154.16449"
+         x="89.102867"
+         sodipodi:role="line"
+         id="tspan5018">  -- @since 1.2.3</tspan></text>
+    <flowRoot
+       xml:space="preserve"
+       id="flowRoot5020"
+       style="font-style:normal;font-weight:normal;font-size:96px;line-height:25px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       transform="matrix(0.92316354,0,0,0.92316354,5.4302439,15.266139)"><flowRegion
+         id="flowRegion5022"><rect
+           id="rect5024"
+           width="238.32765"
+           height="162.11119"
+           x="435.52261"
+           y="59.137138" /></flowRegion><flowPara
+         id="flowPara5026" /></flowRoot>    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:23.44835281px;line-height:0px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.24425368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="89.102867"
+       y="161.86107"
+       id="text5038"><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="161.86107"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px"
+         id="tspan5028">Module Attributes</tspan><tspan
+         id="tspan5030"
+         sodipodi:role="line"
+         x="89.102867"
+         y="166.66356"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.61581755px;line-height:0px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.24425368px" /><tspan
+         id="tspan5036"
+         sodipodi:role="line"
+         x="89.102867"
+         y="166.66356"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px" /><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="166.66356"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan5044">{-# OPTIONS_HADDOCK hide #-}</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="171.89558"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan5048"><tspan
+           style="fill:#808080;stroke-width:0.24425368px"
+           id="tspan5080">  Omit this module from the docs</tspan></tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="177.12761"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan5050">{-# OPTIONS_HADDOCK prune #-}</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="182.35962"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan5054"><tspan
+           style="fill:#808080;stroke-width:0.24425368px"
+           id="tspan5082">  Omit definitions without docs</tspan></tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="187.59164"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan5056">{-# OPTIONS_HADDOCK ignore-exports #-}</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="192.82367"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan5060"><tspan
+           style="fill:#808080;stroke-width:0.24425368px"
+           id="tspan5084">  Treat this module as though all</tspan></tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="198.05569"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';fill:#808080;stroke-width:0.24425368px"
+         id="tspan5064">  top-level items are exported</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="203.2877"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan5066">{-# OPTIONS_HADDOCK not-home #-}</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="208.51973"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';fill:#808080;stroke-width:0.24425368px"
+         id="tspan5068">  Do not treat this module as the</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="213.75175"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';fill:#808080;stroke-width:0.24425368px"
+         id="tspan5078">  &quot;home&quot; of identifiers it exports</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="218.98378"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan5070">{-# OPTIONS_HADDOCK show-extensions #-}</tspan><tspan
+         sodipodi:role="line"
+         x="89.102867"
+         y="224.21579"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.07721162px;line-height:0px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';stroke-width:0.24425368px"
+         id="tspan5072"><tspan
+           style="fill:#808080;stroke-width:0.24425368px"
+           id="tspan5086">  Show all enabled LANGUAGE extensions</tspan></tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:20px;line-height:5.20833302px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.20833333px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="5.544848"
+       y="32.398926"
+       id="text5294"><tspan
+         sodipodi:role="line"
+         id="tspan5292"
+         x="5.544848"
+         y="32.398926"
+         style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:13.33333302px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';stroke-width:0.20833333px">Haddock Markup</tspan></text>
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.78740158;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
+       d="M 6.2499999,37.599983 H 162.5"
+       id="path5504"
+       inkscape:connector-curvature="0" />
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:20px;line-height:5.20833302px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.20833333px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="121.27747"
+       y="21.599566"
+       id="text5529"><tspan
+         sodipodi:role="line"
+         id="tspan5527"
+         x="121.27747"
+         y="29.399044"
+         style="stroke-width:0.20833333px" /></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.22222233px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:end;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:end;fill:#666666;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="163.25969"
+       y="21.504742"
+       id="text4489-0"><tspan
+         sodipodi:role="line"
+         x="163.25969"
+         y="21.504742"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.94444454px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:end;writing-mode:lr-tb;text-anchor:end;fill:#666666;stroke-width:0.26458332px"
+         id="tspan5579">Haddock Markup Cheat-sheet, Version 1.1</tspan><tspan
+         sodipodi:role="line"
+         x="163.25969"
+         y="24.28252"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.94444454px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:end;writing-mode:lr-tb;text-anchor:end;fill:#666666;stroke-width:0.26458332px"
+         id="tspan5571">Getty Ritter (<tspan
+   style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.94444454px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';fill:#666666"
+   id="tspan5597">@aisamanra</tspan>)</tspan><tspan
+         sodipodi:role="line"
+         x="163.25969"
+         y="27.060297"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.94444454px;font-family:'Fira Mono';-inkscape-font-specification:'Fira Mono';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:end;writing-mode:lr-tb;text-anchor:end;fill:#666666;stroke-width:0.26458332px"
+         id="tspan5565">github.com/aisamanra/haddock-cheatsheet</tspan><tspan
+         sodipodi:role="line"
+         x="163.25969"
+         y="29.838076"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.94444454px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:end;writing-mode:lr-tb;text-anchor:end;fill:#666666;stroke-width:0.26458332px"
+         id="tspan5601" /><tspan
+         sodipodi:role="line"
+         x="163.25969"
+         y="32.615852"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.94444454px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:end;writing-mode:lr-tb;text-anchor:end;fill:#666666;stroke-width:0.26458332px"
+         id="tspan5605">This work is licensed under a Creative Commons</tspan><tspan
+         sodipodi:role="line"
+         x="163.25969"
+         y="35.393631"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.94444454px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:end;writing-mode:lr-tb;text-anchor:end;fill:#666666;stroke-width:0.26458332px"
+         id="tspan5593">Attribution-ShareAlike 4.0 International License</tspan></text>
+  </g>
+</svg>
diff --git a/utils/haddock/doc/common-errors.rst b/utils/haddock/doc/common-errors.rst
new file mode 100644
index 0000000000000000000000000000000000000000..504ee8867aeec8d720bd0d32f08e34d7f3f6c6c8
--- /dev/null
+++ b/utils/haddock/doc/common-errors.rst
@@ -0,0 +1,19 @@
+Common Errors
+=============
+
+``parse error on input ‘-- | xxx’``
+-----------------------------------
+
+This is probably caused by the ``-- | xxx`` comment not following a declaration. I.e. use ``-- xxx`` instead. See :ref:`top-level-declaration`.
+
+``parse error on input ‘-- $ xxx’``
+-----------------------------------
+
+You've probably commented out code like::
+
+  f x
+    $ xxx
+    
+``-- $`` is a special syntax for named chunks, see :ref:`named-chunks`. You can fix this by escaping the ``$``::
+
+  -- \$ xxx
diff --git a/utils/haddock/doc/conf.py b/utils/haddock/doc/conf.py
new file mode 100644
index 0000000000000000000000000000000000000000..9adbd254e19ec07426afc59813b4642848c1979e
--- /dev/null
+++ b/utils/haddock/doc/conf.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+
+import sys
+import os
+import shlex
+
+extensions = []
+
+source_suffix = '.rst'
+master_doc = 'index'
+
+# General information about the project.
+project = u'Haddock'
+copyright = u'2016, Simon Marlow'
+author = u'Simon Marlow'
+version = '1.0'
+release = '1.0'
+
+language = 'en'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['.build']
+todo_include_todos = False
+
+# Syntax highlighting
+highlight_language = 'haskell'
+pygments_style = 'tango'
+
+# -- Options for HTML output ----------------------------------------------
+
+htmlhelp_basename = 'Haddockdoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = { }
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+#  author, documentclass [howto, manual, or own class]).
+latex_documents = [
+  (master_doc, 'Haddock.tex', u'Haddock Documentation',
+   u'Simon Marlow', 'manual'),
+]
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    (master_doc, 'haddock', u'Haddock Documentation',
+     [author], 1)
+]
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  (master_doc, 'Haddock', u'Haddock Documentation',
+   author, 'Haddock', 'One line description of project.',
+   'Miscellaneous'),
+]
+
diff --git a/utils/haddock/doc/ghc.mk b/utils/haddock/doc/ghc.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6f800c57e3091c9bb958fa54ae9f572d9e577357
--- /dev/null
+++ b/utils/haddock/doc/ghc.mk
@@ -0,0 +1,24 @@
+# -----------------------------------------------------------------------------
+#
+# (c) 2009 The University of Glasgow
+#
+# This file is part of the GHC build system.
+#
+# To understand how the build system works and how to modify it, see
+#      http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
+#      http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
+#
+# -----------------------------------------------------------------------------
+
+ifeq "$(BUILD_SPHINX_HTML)" "YES"
+html : html_utils/haddock/doc
+
+$(eval $(call clean-target,utils/haddock/doc,sphinx,utils/haddock/doc/haddock utils/haddock/doc/.build-html utils/haddock/doc/.build-pdf))
+$(eval $(call all-target,utils/haddock/doc,html_utils/haddock/doc))
+INSTALL_HTML_DOC_DIRS += utils/haddock/doc/haddock
+endif
+
+html_utils/haddock/doc :
+	$(MAKE) -C utils/haddock/doc html SPHINX_BUILD=$(SPHINXBUILD)
+	cp -R utils/haddock/doc/.build-html utils/haddock/doc/haddock
+
diff --git a/utils/haddock/doc/index.rst b/utils/haddock/doc/index.rst
new file mode 100644
index 0000000000000000000000000000000000000000..f370e42fd54e6b8b42a9eacd34ee8776165ce99a
--- /dev/null
+++ b/utils/haddock/doc/index.rst
@@ -0,0 +1,23 @@
+Welcome to Haddock's documentation!
+===================================
+
+This is Haddock, a tool for automatically generating documentation from
+annotated Haskell source code.
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   intro
+   invoking
+   markup
+   common-errors
+   multi-components
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`search`
diff --git a/utils/haddock/doc/intro.rst b/utils/haddock/doc/intro.rst
new file mode 100644
index 0000000000000000000000000000000000000000..1f4234cbe7b7c1f565fd4ef7e12980d3008b9469
--- /dev/null
+++ b/utils/haddock/doc/intro.rst
@@ -0,0 +1,124 @@
+Introduction
+============
+
+This is Haddock, a tool for automatically generating documentation from
+annotated Haskell source code. Haddock was designed with several goals
+in mind:
+
+-  When documenting APIs, it is desirable to keep the documentation
+   close to the actual interface or implementation of the API,
+   preferably in the same file, to reduce the risk that the two become
+   out of sync. Haddock therefore lets you write the documentation for
+   an entity (function, type, or class) next to the definition of the
+   entity in the source code.
+
+-  There is a tremendous amount of useful API documentation that can be
+   extracted from just the bare source code, including types of exported
+   functions, definitions of data types and classes, and so on. Haddock
+   can therefore generate documentation from a set of straight Haskell
+   98 modules, and the documentation will contain precisely the
+   interface that is available to a programmer using those modules.
+
+-  Documentation annotations in the source code should be easy on the
+   eye when editing the source code itself, so as not to obscure the
+   code and to make reading and writing documentation annotations easy.
+   The easier it is to write documentation, the more likely the
+   programmer is to do it. Haddock therefore uses lightweight markup in
+   its annotations, taking several ideas from
+   `IDoc <https://web.archive.org/web/20180621053227/http://www.cse.unsw.edu.au/~chak/haskell/idoc/>`__. In fact,
+   Haddock can understand IDoc-annotated source code.
+
+-  The documentation should not expose any of the structure of the
+   implementation, or to put it another way, the implementer of the API
+   should be free to structure the implementation however he or she
+   wishes, without exposing any of that structure to the consumer. In
+   practical terms, this means that while an API may internally consist
+   of several Haskell modules, we often only want to expose a single
+   module to the user of the interface, where this single module just
+   re-exports the relevant parts of the implementation modules.
+
+   Haddock therefore understands the Haskell module system and can
+   generate documentation which hides not only non-exported entities
+   from the interface, but also the internal module structure of the
+   interface. A documentation annotation can still be placed next to the
+   implementation, and it will be propagated to the external module in
+   the generated documentation.
+
+-  Being able to move around the documentation by following hyperlinks
+   is essential. Documentation generated by Haddock is therefore
+   littered with hyperlinks: every type and class name is a link to the
+   corresponding definition, and user-written documentation annotations
+   can contain identifiers which are linked automatically when the
+   documentation is generated.
+
+-  We might want documentation in multiple formats - online and printed,
+   for example. Haddock comes with HTML, LaTeX, and Hoogle backends, and
+   it is structured in such a way that adding new backends is
+   straightforward.
+
+Obtaining Haddock
+-----------------
+
+Haddock is distributed with GHC distributions, and will automatically be provided if you use 
+`ghcup <https://www.haskell.org/ghcup>`__, for instance.
+
+Up-to-date sources can also be obtained from our public GitHub
+repository. The Haddock sources are at
+``https://github.com/haskell/haddock``.
+
+License
+-------
+
+The following license covers this documentation, and the Haddock source
+code, except where otherwise indicated.
+
+    Copyright (c) 2002-2010, Simon Marlow
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are
+    met:
+
+    1. Redistributions of source code must retain the above copyright
+       notice, this list of conditions and the following disclaimer.
+
+    2. Redistributions in binary form must reproduce the above copyright
+       notice, this list of conditions and the following disclaimer in the
+       documentation and/or other materials provided with the
+       distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Contributors
+------------
+
+A list of contributors to the project can be seen at
+``https://github.com/haskell/haddock/graphs/contributors``.
+
+Acknowledgements
+----------------
+
+Several documentation systems provided the inspiration for Haddock, most
+notably:
+
+-  `IDoc <https://web.archive.org/web/20180621053227/http://www.cse.unsw.edu.au/~chak/haskell/idoc/>`__
+
+-  `HDoc <https://mail.haskell.org/pipermail/haskelldoc/2001-April/000067.html>`__
+
+-  `Doxygen <https://www.doxygen.nl/index.html>`__
+
+and probably several others I've forgotten.
+
+Thanks to the the members of haskelldoc@haskell.org,
+haddock@projects.haskell.org and everyone who contributed to the many
+libraries that Haddock makes use of.
diff --git a/utils/haddock/doc/invoking.rst b/utils/haddock/doc/invoking.rst
new file mode 100644
index 0000000000000000000000000000000000000000..0069f0811255879d3bde48b4afeac5e765e34d6d
--- /dev/null
+++ b/utils/haddock/doc/invoking.rst
@@ -0,0 +1,606 @@
+Invoking Haddock
+================
+
+Haddock is invoked from the command line, like so:
+
+.. code-block:: none
+
+    haddock [option ...] file ...
+
+Where each ``file`` is a filename containing a Haskell source module (.hs)
+or a Literate Haskell source module (.lhs) or just a module name.
+
+All the modules specified on the command line will be processed
+together. When one module refers to an entity in another module being
+processed, the documentation will link directly to that entity.
+
+Entities that cannot be found, for example because they are in a module
+that isn't being processed as part of the current batch, simply won't be
+hyperlinked in the generated documentation. Haddock will emit warnings
+listing all the identifiers it couldn't resolve.
+
+The modules should *not* be mutually recursive, as Haddock don't like
+swimming in circles.
+
+Note that while older version would fail on invalid markup, this is
+considered a bug in the new versions. If you ever get failed parsing
+message, please report it.
+
+You must also specify an option for the output format. Currently only
+the :option:`--html` option for HTML, the :option:`--hoogle` option for
+outputting Hoogle data, and the :option:`--latex` option are functional.
+
+The packaging tool
+`Cabal <http://www.haskell.org/ghc/docs/latest/html/Cabal/index.html>`__
+has Haddock support, and is often used instead of invoking Haddock
+directly.
+
+The following options are available:
+
+.. option:: -B <dir>
+
+    Tell GHC that its lib directory is dir. Can be used to override
+    the default path.
+
+.. option:: -o <dir>
+            --odir=<dir>
+
+    Generate files into dir instead of the current directory.
+
+.. option:: -l <dir>
+            --lib=<dir>
+
+    Use Haddock auxiliary files (themes, javascript, etc...) in dir.
+
+.. option:: -i <file>
+            --read-interface=<file>
+            -i <docpath>,<file>
+            --read-interface=<docpath>,<file>
+            -i <docpath>,<srcpath>,<file>
+            --read-interface=<docpath>,<srcpath>,<file>
+            -i <docpath>,<srcpath>,<visibility>,<file>
+
+    Read the interface file in file, which must have been produced by
+    running Haddock with the :option:`--dump-interface` option. The interface
+    describes a set of modules whose HTML documentation is located in
+    docpath (which may be a relative pathname). The docpath is optional,
+    and defaults to “.”. The srcpath is optional but has no default
+    value.
+
+    This option allows Haddock to produce separate sets of documentation
+    with hyperlinks between them. The docpath is used to direct
+    hyperlinks to point to the right files; so make sure you don't move
+    the HTML files later or these links will break. Using a relative
+    docpath means that a documentation subtree can still be moved around
+    without breaking links.
+
+    Similarly to docpath, srcpath is used generate cross-package
+    hyperlinks but within sources rendered with :option:`--hyperlinked-source`
+    option.
+
+    If visibility is set to `hidden`, modules from that interface file will
+    not be listed in haddock generated content file.
+
+    Multiple :option:`--read-interface` options may be given.
+
+.. option:: -D <file>
+            --dump-interface=<file>
+
+    Produce an interface file [1]_ in the file file. An interface file
+    contains information Haddock needs to produce more documentation
+    that refers to the modules currently being processed - see the
+    :option:`--read-interface` option for more details. The interface file is
+    in a binary format; don't try to read it.
+
+.. option:: --show-interface=<file>
+
+    Dumps a binary interface file to stdout in a human readable fashion.
+    Uses json as output format.
+
+.. [1]
+   Haddock interface files are not the same as Haskell interface files,
+   I just couldn't think of a better name.
+
+.. option:: --html, -h
+
+    Generate documentation in HTML format. Several files will be
+    generated into the current directory (or the specified directory if
+    the :option:`-o` option is given), including the following:
+
+    ``module.html``; ``mini_module.html``
+        An HTML page for each module, and a "mini" page for each used
+        when viewing their synopsis.
+
+    ``index.html``
+        The top level page of the documentation: lists the modules
+        available, using indentation to represent the hierarchy if the
+        modules are hierarchical.
+
+    ``doc-index.html``; ``doc-index-X.html``
+        The alphabetic index, possibly split into multiple pages if big
+        enough.
+
+    ``some.css``; ``etc...``
+        Files needed for the themes used. Specify your themes using the
+        :option:`--theme` option.
+
+    ``haddock-util.js``
+        Some JavaScript utilities used to implement some of the dynamic
+        features like collapsible sections.
+
+.. option:: --mathjax
+
+    Specify a custom URL for a mathjax-compatible JS script. By default,
+    this is set to `MathJax
+    <https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML>`_.
+
+.. option:: --latex
+
+    Generate documentation in LaTeX format. Several files will be
+    generated into the current directory (or the specified directory if
+    the :option:`-o` option is given), including the following:
+
+    ``package.tex``
+        The top-level LaTeX source file; to format the documentation
+        into PDF you might run something like this: ::
+
+            $ pdflatex package.tex
+
+    ``haddock.sty``
+        The default style. The file contains definitions for various
+        macros used in the LaTeX sources generated by Haddock; to change
+        the way the formatted output looks, you might want to override
+        these by specifying your own style with the :option:`--latex-style`
+        option.
+
+    ``module.tex``
+        The LaTeX documentation for each module.
+
+.. option:: --latex-style=<style>
+
+    This option lets you override the default style used by the LaTeX
+    generated by the :option:`--latex` option. Normally Haddock puts a
+    standard ``haddock.sty`` in the output directory, and includes the
+    command ``\usepackage{haddock}`` in the LaTeX source. If this option
+    is given, then ``haddock.sty`` is not generated, and the command is
+    instead ``\usepackage{style}``.
+
+.. option:: --hoogle
+
+    Generate an index file for the
+    `Hoogle <http://hackage.haskell.org/package/hoogle>`_ search engine.
+    One text file will be generated into the current directory (or the
+    specified directory if the :option:`-o` is given). Note that
+    the :option:`--package-name` is required.
+
+    Since the output is intended to be parsed by Hoogle, some conventions
+    need to be upheld:
+
+      * Every entity should span exactly one line. ::
+
+            newtype ReaderT r (m :: * -> *) a :: * -> (* -> *) -> * -> *
+
+        The one exception to this rule is classes. The body of a class
+        is split up with one class member per line, an opening brace on
+        the line of the header, and a closing brace on a new line after
+        the class. ::
+
+            class Foo a where {
+                foo :: a -> a -> Baz a;
+                type family Baz a;
+                type Baz a = [(a, a)];
+            }
+
+      * Entites that are exported only indirectly (for instance data
+        constructors visible via a ``ReaderT(..)`` export) have their names
+        wrapped in square brackets. ::
+
+            [ReaderT] :: (r -> m a) -> ReaderT r m a
+            [runReaderT] :: ReaderT r m a -> r -> m a
+
+
+.. option:: --hyperlinked-source
+
+    Generate hyperlinked source code (as HTML web page). All rendered
+    files will be put into ``src/`` subfolder of output directory.
+
+    Usually, this should be used in combination with :option:`--html` option -
+    generated documentation will then contain references to appropriate
+    code fragments. Previously, this behaviour could be achieved by
+    generating sources using external tool and specifying
+    :option:`--source-base`, :option:`--source-module`, :option:`--source-entity` and
+    related options. Note that these flags are ignored once
+    :option:`--hyperlinked-source` is set.
+
+    In order to make cross-package source hyperlinking possible,
+    appropriate source paths have to be set up when providing interface
+    files using :option:`--read-interface` option.
+
+.. option:: --source-css=<style>
+
+    Use custom CSS file for sources rendered by the
+    :option:`--hyperlinked-source` option. If no custom style file is
+    provided, Haddock will use default one.
+
+.. option:: -S, --docbook
+
+    Reserved for future use (output documentation in DocBook XML
+    format).
+
+.. option:: --base-url=<url>
+
+    Base url for static assets (eg. css, javascript, json files etc.).
+    When present, static assets are not copied.  This option is useful
+    when creating documentation for multiple packages, it allows to have
+    a single copy of static assets served from the given url.
+
+.. option:: --source-base=<url>
+            --source-module=<url>
+            --source-entity=<url>
+            --source-entity-line=<url>
+
+    Include links to the source files in the generated documentation.
+    Use the :option:`--source-base` option to add a source code link in the
+    header bar of the contents and index pages. Use the
+    :option:`--source-module` to add a source code link in the header bar of
+    each module page. Use the :option:`--source-entity` option to add a source
+    code link next to the documentation for every value and type in each
+    module. :option:`--source-entity-line` is a flag that gets used for
+    entities that need to link to an exact source location rather than a
+    name, eg. since they were defined inside a Template Haskell splice.
+
+    In each case URL is the base URL where the source files can be
+    found. For the per-module and per-entity URLs, the following
+    substitutions are made within the string URL:
+
+    -  The string ``%M`` or ``%{MODULE}`` is replaced by the module
+       name. Note that for the per-entity URLs this is the name of the
+       *exporting* module.
+
+    -  The string ``%N`` or ``%{NAME}`` is replaced by the name of the
+       exported value or type. This is only valid for the
+       :option:`--source-entity` option.
+
+    -  The string ``%K`` or ``%{KIND}`` is replaced by a flag indicating
+       whether the exported name is a value ``v`` or a type
+       ``t``. This is only valid for the :option:`--source-entity` option.
+
+    -  The string ``%L`` or ``%{LINE}`` is replaced by the number of the
+       line where the exported value or type is defined. This is only
+       valid for the :option:`--source-entity` option.
+
+    -  The string ``%%`` is replaced by ``%``.
+
+    If you have html versions of your sources online with anchors for
+    each type and function name, you would say
+    ``haddock --source-base=url/ --source-module=url/%M.html --source-entity=url/%M.html#%N``
+
+    For the ``%{MODULE}`` substitution you may want to replace the
+    ``.`` character in the module names with some other character
+    (some web servers are known to get confused by multiple ``.``
+    characters in a file name). To replace it with a character c use
+    ``%{MODULE/./c}``.
+
+    One example of a tool that can generate syntax-highlighted HTML from
+    your source code, complete with anchors suitable for use from
+    haddock, is
+    `hscolour <http://www.cs.york.ac.uk/fp/darcs/hscolour>`__.
+
+.. option:: -s <url>
+            --source=<url>
+
+    Deprecated aliases for :option:`--source-module`
+
+.. option:: --comments-base=<url>
+            --comments-module=<url>
+            --comments-entity=<url>
+
+    documentation. This feature would typically be used in conjunction
+    with a Wiki system.
+
+    Use the :option:`--comments-base` option to add a user comments link in
+    the header bar of the contents and index pages. Use the
+    :option:`--comments-module` to add a user comments link in the header bar
+    of each module page. Use the :option:`--comments-entity` option to add a
+    comments link next to the documentation for every value and type in
+    each module.
+
+    In each case URL is the base URL where the corresponding comments
+    page can be found. For the per-module and per-entity URLs the same
+    substitutions are made as with the :option:`--source-module` and
+    :option:`--source-entity` options above.
+
+    For example, if you want to link the contents page to a wiki page,
+    and every module to subpages, you would say
+    ``haddock --comments-base=url --comments-module=url/%M``
+
+    If your Wiki system doesn't like the ``.`` character in Haskell
+    module names, you can replace it with a different character. For
+    example to replace the ``.`` characters with ``_`` use
+    ``haddock --comments-base=url --comments-module=url/%{MODULE/./_}``.
+    Similarly, you can replace the ``/`` in a file name (may be useful for
+    entity comments, but probably not).
+
+.. option:: --theme=<path>
+
+    Specify a theme to be used for HTML (:option:`--html`) documentation. If
+    given multiple times then the pages will use the first theme given
+    by default, and have alternate style sheets for the others. The
+    reader can switch between themes with browsers that support
+    alternate style sheets, or with the "Style" menu that gets added
+    when the page is loaded. If no themes are specified, then just the
+    default built-in theme ("Linuwial") is used.
+
+    The path parameter can be one of:
+
+    -  A *directory*: The base name of the directory becomes the name of
+       the theme. The directory must contain exactly one ``some.css``
+       file. Other files, usually image files, will be copied, along
+       with the ``some.css`` file, into the generated output directory.
+
+    -  A *CSS file*: The base name of the file becomes the name of the
+       theme.
+
+    -  The *name* of a built-in theme ("Linuwial", "Ocean", or "Classic").
+
+.. option:: --built-in-themes
+
+    Includes the built-in themes ("Linuwial", "Ocean", and "Classic"). Can be
+    combined with :option:`--theme`. Note that order matters: The first
+    specified theme will be the default.
+
+.. option:: --use-unicode
+
+    Enable use of Unicode characters in HTML output.
+
+.. option:: -c <file>
+            --css=<file>
+
+    Deprecated aliases for :option:`--theme`
+
+.. option:: -p <file>
+            --prologue=<file>
+
+    Specify a file containing documentation which is placed on the main
+    contents page under the heading “Description”. The file is parsed as
+    a normal Haddock doc comment (but the comment markers are not
+    required).
+
+.. option:: -t <title>
+            --title=<title>
+
+    Use title as the page heading for each page in the
+    documentation.This will normally be the name of the library being
+    documented.
+
+    The title should be a plain string (no markup please!).
+
+.. option:: --package-name=<name>
+
+    Specify the name of the package being documented.
+
+.. option:: --package-version=<version>
+
+    Specify the version of the package being documented.
+
+.. option:: -q <mode>
+            --qual=<mode>
+
+    Specify how identifiers are qualified.
+
+    mode should be one of
+
+    -  ``none`` (default): don't qualify any identifiers
+
+    -  ``full``: always qualify identifiers completely
+
+    -  ``local``: only qualify identifiers that are not part of the module
+
+    -  ``relative``: like local, but strip name of the module from
+       qualifications of identifiers in submodules
+
+    Example: If you generate documentation for module A, then the
+    identifiers A.x, A.B.y and C.z are qualified as follows.
+
+    -  none: x, y, z
+
+    -  full: A.x, A.B.y, C.z
+
+    -  local: x, A.B.y, C.z
+
+    -  relative: x, B.y, C.z
+
+.. option:: --since-qual=<mode>
+
+    Specify how ``@since`` annotations are qualified.
+
+    mode should be one of
+
+    -  ``always`` (default): always qualify ``@since`` annotations with
+       a package name and version
+
+    -  ``only-external``: only qualify ``@since`` annotations with a
+       package name and version when they do not come from the current
+       package
+
+.. option:: -?
+            --help
+
+    Display help and exit.
+
+.. option:: -V
+            --version
+
+    Output version information and exit.
+
+.. option:: --ghc-version
+
+    Output the version of GHC which Haddock expects to find at :option:-B
+    and exit.
+
+.. option:: --print-ghc-path
+
+    Output the path to the GHC (which Haddock computes based on :option:-B)
+    and exit.
+
+.. option:: --print-ghc-libdir
+
+    Output the path to the GHC ``lib`` directory (which Haddock computes
+    based on :option:-B) and exit.
+
+.. option:: -v
+            --verbose
+
+    Increase verbosity. Currently this will cause Haddock to emit some
+    extra warnings, in particular about modules which were imported but
+    it had no information about (this is often quite normal; for example
+    when there is no information about the ``Prelude``).
+
+.. option:: --use-contents=<url>
+            --use-index=<url>
+
+    When generating HTML, do not generate an index. Instead, redirect
+    the Contents and/or Index link on each page to URL. This option is
+    intended for use in conjunction with :option:`--gen-contents` and/or
+    :option:`--gen-index` for generating a separate contents and/or index
+    covering multiple libraries.
+
+.. option:: --gen-contents
+            --gen-index
+
+    Generate an HTML contents and/or index containing entries pulled
+    from all the specified interfaces (interfaces are specified using
+    :option:`-i` or :option:`--read-interface`). This is used to generate a single
+    contents and/or index for multiple sets of Haddock documentation.
+
+.. option:: --hide <module>
+
+    Causes Haddock to behave as if module module has the ``hide``
+    attribute. (:ref:`module-attrs`).
+
+.. option:: --show <module>
+
+    Causes Haddock to behave as if module module does not have the ``hide``
+    attribute. (:ref:`module-attrs`).
+
+.. option:: --show-all
+
+    Causes Haddock to behave as if no modules have the ``hide`` attribute.
+    (:ref:`module-attrs`).
+
+.. option:: --show-extensions <module>
+
+    Causes Haddock to behave as if module module has the
+    ``show-extensions`` attribute. (:ref:`module-attrs`).
+
+.. option:: --optghc=<option>
+
+    Pass option to GHC. Note that there is a double dash there, unlike
+    for GHC.
+
+.. option:: -w
+            --no-warnings
+
+    Turn off all warnings.
+
+.. option:: --interface-version
+
+    Prints out the version of the binary Haddock interface files that
+    this version of Haddock generates.
+
+.. option:: --compatible-interface-versions
+
+    Prints out space-separated versions of binary Haddock interface
+    files that this version of Haddock is compatible with.
+
+.. option:: --bypass-interface-version-check
+
+    **DANGEROUS** Causes Haddock to ignore the interface versions of
+    binary Haddock interface files. This can make Haddock crash during
+    deserialization of interface files.
+
+.. option:: --no-tmp-comp-dir
+
+    Do not use a temporary directory for reading and writing compilation
+    output files (``.o``, ``.hi``, and stub files). Instead, use the
+    present directory or another directory that you have explicitly told
+    GHC to use via the :option:`--optghc` flag.
+
+    This flag can be used to avoid recompilation if compilation files
+    already exist. Compilation files are produced when Haddock has to
+    process modules that make use of Template Haskell, in which case
+    Haddock compiles the modules using the GHC API.
+
+.. option:: --print-missing-docs
+
+    Print extra information about any undocumented entities.
+
+.. option:: --trace-args
+
+    Make Haddock print the arguments it receives to standard output. This is
+    useful for examining arguments when invoking through ``cabal haddock``, as
+    ``cabal`` uses temporary `response files
+    <https://gcc.gnu.org/wiki/Response_Files>`_ to pass arguments to Haddock.
+
+Using literate or pre-processed source
+--------------------------------------
+
+Since Haddock uses GHC internally, both plain and literate Haskell
+sources are accepted without the need for the user to do anything. To
+use the C pre-processor, however, the user must pass the ``-cpp``
+option to GHC using :option:`--optghc`.
+
+Avoiding recompilation
+----------------------
+
+With the advent of "hi-haddock", Haddock now produces documentation from ``.hi``
+(Haskell interface) files and ``.hie`` (``.hi`` extended) files [#]_, rather
+than typechecked module results. This means that as long as the necessary
+``.hi`` and ``.hie`` files are available (i.e. produced by your build process),
+recompilation can be avoided during documentation generation.
+
+.. [#] Note that ``.hie`` files are only necessary to build documentation which
+       includes hyperlinked source files `like this one
+       <https://hackage.haskell.org/package/base-4.18.0.0/docs/src/GHC.Base.html>`_,
+       while ``.hi`` files are required for all Haddock documentation flavors.
+
+The first step is to ensure that your build process is producing ``.hi`` files
+that contain Haddock docstrings. This requires that you somehow provide the
+``-fwrite-interface`` and ``-haddock`` flags to GHC. If you intend to generate
+documentation that includes hyperlinked source files, you should also provide
+the ``-fwrite-ide-info`` flag to GHC. You may specify the directory in which GHC
+should write the ``.hi`` and ``.hie`` files by providing the
+``-hidir=/path/to/hidir`` and ``-hiedir=/path/to/hiedir`` flags to GHC. If you
+are building your application with ``cabal build``, the default location is in
+``dist-newstyle/build/<arch>-<os>/ghc-<ghc-version>/<component>-0.1.0/build``.
+
+The next step is to ensure that the flags which Haddock passes to GHC will not
+trigger recompilation. Unfortunately, this is not very easy to do if you are
+invoking Haddock through ``cabal haddock``. Upon ``cabal haddock``, Cabal passes
+a ``--optghc="-optP-D__HADDOCK_VERSION__=NNNN"`` (where ``NNNN`` is the Haddock
+version number) flag to Haddock, which forwards the ``-optP=...`` flag to GHC
+and triggers a recompilation (unless the existing build results were also
+created by a ``cabal haddock``). Additionally, Cabal passes a
+``--optghc="-stubdir=<temp directory>"`` flag to Haddock, which forwards the
+``-stubdir=<temp directory>`` flag to GHC and triggers a recompilation since
+``-stubdir`` adds a global include directory. Moreover, since the ``stubdir``
+that Cabal passes is a temporary directory, a recompilation is triggered even
+for immediately successive invocations. To avoid recompilations due to these
+flags, one must manually extract the arguments passed to Haddock by Cabal and
+remove the ``--optghc="-optP-D__HADDOCK_VERSION__=NNNN"`` and
+``--optghc="-stubdir=<temp directory>"`` flags. This can be achieved using the
+:option:`--trace-args` flag by invoking ``cabal haddock`` with
+``--haddock-option="--trace-args"`` and copying the traced arguments to a script
+which makes an equivalent call to Haddock without the aformentioned flags.
+
+In addition to the above, Cabal passes a temporary directory as ``-hidir`` to
+Haddock by default. Obviously, this also triggers a recompilation for every
+invocation of ``cabal haddock``, since it will never find the necessary
+interface files in that temporary directory. To remedy this, pass a
+``--optghc="-hidir=/path/to/hidir"`` flag to Haddock, where ``/path/to/hidir``
+is the path to the directory in which your build process is writing ``.hi``
+files.
+
+Following the steps above will allow you to take full advantage of "hi-haddock"
+and generate Haddock documentation from existing build results without requiring
+any further compilation.
diff --git a/utils/haddock/doc/markup.rst b/utils/haddock/doc/markup.rst
new file mode 100644
index 0000000000000000000000000000000000000000..a587948bc4d2d1b6821615f387f3fbcb3f141a68
--- /dev/null
+++ b/utils/haddock/doc/markup.rst
@@ -0,0 +1,1276 @@
+Documentation and Markup
+========================
+
+Haddock understands special documentation annotations in the Haskell
+source file and propagates these into the generated documentation. The
+annotations are purely optional: if there are no annotations, Haddock
+will just generate documentation that contains the type signatures, data
+type declarations, and class declarations exported by each of the
+modules being processed.
+
+.. _top-level-declaration:
+
+Documenting a Top-Level Declaration
+-----------------------------------
+
+The simplest example of a documentation annotation is for documenting
+any top-level declaration (function type signature, type declaration, or
+class declaration). For example, if the source file contains the
+following type signature: ::
+
+    square :: Int -> Int
+    square x = x * x
+
+Then we can document it like this: ::
+
+    -- |The 'square' function squares an integer.
+    square :: Int -> Int
+    square x = x * x
+
+The ``-- |`` syntax begins a documentation annotation, which applies
+to the *following* declaration in the source file. Note that the
+annotation is just a comment in Haskell — it will be ignored by the
+Haskell compiler.
+
+The declaration following a documentation annotation should be one of
+the following:
+
+-  A type signature for a top-level function,
+
+-  A definition for a top-level function with no type signature,
+
+-  A ``data`` declaration,
+
+-  A ``pattern`` declaration,
+
+-  A ``newtype`` declaration,
+
+-  A ``type`` declaration
+
+-  A ``class`` declaration,
+
+-  An ``instance`` declaration,
+
+-  A ``data family`` or ``type family`` declaration, or
+
+-  A ``data instance`` or ``type instance`` declaration.
+
+If the annotation is followed by a different kind of declaration, it
+will probably be ignored by Haddock.
+
+Some people like to write their documentation *after* the declaration;
+this is possible in Haddock too: ::
+
+    square :: Int -> Int
+    -- ^The 'square' function squares an integer.
+    square x = x * x
+
+Since Haddock uses the GHC API internally, it can infer types for
+top-level functions without type signatures. However, you're
+encouraged to add explicit type signatures for all top-level
+functions, to make your source code more readable for your users, and
+at times to avoid GHC inferring overly general type signatures that
+are less helpful to your users.
+
+Documentation annotations may span several lines; the annotation
+continues until the first non-comment line in the source file. For
+example: ::
+
+    -- |The 'square' function squares an integer.
+    -- It takes one argument, of type 'Int'.
+    square :: Int -> Int
+    square x = x * x
+
+You can also use Haskell's nested-comment style for documentation
+annotations, which is sometimes more convenient when using multi-line
+comments: ::
+
+    {-|
+      The 'square' function squares an integer.
+      It takes one argument, of type 'Int'.
+    -}
+    square :: Int -> Int
+    square x = x * x
+
+Documenting Parts of a Declaration
+----------------------------------
+
+In addition to documenting the whole declaration, in some cases we can
+also document individual parts of the declaration.
+
+Class Methods
+~~~~~~~~~~~~~
+
+Class methods are documented in the same way as top level type
+signatures, by using either the ``-- |`` or ``-- ^`` annotations: ::
+
+    class C a where
+       -- | This is the documentation for the 'f' method
+       f :: a -> Int
+       -- | This is the documentation for the 'g' method
+       g :: Int -> a
+
+Associated type and data families can also be annotated in this way.
+
+Constructors and Record Fields
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Constructors are documented like so: ::
+
+    data T a b
+      -- | This is the documentation for the 'C1' constructor
+      = C1 a b
+      -- | This is the documentation for the 'C2' constructor
+      | C2 a b
+
+or like this: ::
+
+    data T a b
+      = C1   -- ^ This is the documentation for the 'C1' constructor
+          a  -- ^ This is the documentation for the argument of type 'a'
+          b  -- ^ This is the documentation for the argument of type 'b'
+
+There is one edge case that is handled differently: only one ``-- ^``
+annotation occurring after the constructor and all its arguments is
+applied to the constructor, not its last argument: ::
+
+    data T a b
+      = C1 a b  -- ^ This is the documentation for the 'C1' constructor
+      | C2 a b  -- ^ This is the documentation for the 'C2' constructor
+
+Record fields are documented using one of these styles: ::
+
+    data R a b =
+      C { -- | This is the documentation for the 'a' field
+          a :: a,
+          -- | This is the documentation for the 'b' field
+          b :: b
+        }
+
+    data R a b =
+      C { a :: a  -- ^ This is the documentation for the 'a' field
+        , b :: b  -- ^ This is the documentation for the 'b' field
+        }
+
+Alternative layout styles are generally accepted by Haddock - for
+example doc comments can appear before or after the comma in separated
+lists such as the list of record fields above.
+
+In cases where more than one constructor exports a field with the same
+name, the documentation attached to the first occurrence of the field
+will be used, even if a comment is not present. ::
+
+    data T a = A { someField :: a -- ^ Doc for someField of A
+                 }
+             | B { someField :: a -- ^ Doc for someField of B
+                 }
+
+In the above example, all occurrences of ``someField`` in the
+documentation are going to be documented with
+``Doc for someField of A``. Note that Haddock versions 2.14.0 and before
+would join up documentation of each field and render the result. The
+reason for this seemingly weird behaviour is the fact that ``someField``
+is actually the same (partial) function.
+
+Deriving clauses
+~~~~~~~~~~~~~~~~
+
+Most instances are top-level, so can be documented as in
+:ref:`top-level-declaration`. The exception to this is instance that are
+come from a ``deriving`` clause on a datatype declaration. These can
+be documented like this: ::
+
+    data D a = L a | M
+      deriving ( Eq   -- ^ @since 4.5
+               , Ord  -- ^ default 'Ord' instance
+               )
+
+This also scales to the various GHC extensions for deriving: ::
+
+    newtype T a = T a
+      deriving          Show     -- ^ derivation of 'Show'
+      deriving stock  ( Eq       -- ^ stock derivation of 'Eq'
+                      , Foldable -- ^ stock derivation of 'Foldable'
+                      )
+      deriving newtype  Ord      -- ^ newtype derivation of 'Ord'
+      deriving anyclass Read     -- ^ unsafe derivation of 'Read'
+      deriving        ( Eq1      -- ^ deriving 'Eq1' via 'Identity'
+                      , Ord1     -- ^ deriving 'Ord1' via 'Identity'
+                      ) via Identity
+
+Function Arguments
+~~~~~~~~~~~~~~~~~~
+
+Individual arguments to a function may be documented like this: ::
+
+    f  :: Int      -- ^ The 'Int' argument
+       -> Float    -- ^ The 'Float' argument
+       -> IO ()    -- ^ The return value
+
+Pattern synonyms, GADT-style data constructors, and class methods also
+support this style of documentation.
+
+.. _module-description:
+
+The Module Description
+----------------------
+
+A module itself may be documented with multiple fields that can then be
+displayed by the backend. In particular, the HTML backend displays all
+the fields it currently knows about. We first show the most complete
+module documentation example and then talk about the fields. ::
+
+    {-|
+    Module      : W
+    Description : Short description
+    Copyright   : (c) Some Person, 2013
+                      Someone Else, 2014
+    License     : GPL-3
+    Maintainer  : sample@email.com
+    Stability   : experimental
+    Portability : POSIX
+
+    Here is a longer description of this module, containing some
+    commentary with @some markup@.
+    -}
+    module W where
+    ...
+
+All fields are optional but they must be in order if they do appear.
+Multi-line fields are accepted but the consecutive lines have to start
+indented more than their label. If your label is indented one space, as
+is often the case with the ``--`` syntax, the consecutive lines have
+to start at two spaces at the very least. For example, above we saw a
+multiline ``Copyright`` field: ::
+
+    {-|
+    ...
+    Copyright   : (c) Some Person, 2013
+                      Someone Else, 2014
+    ...
+    -}
+
+That could equivalently be written as: ::
+
+    -- | ...
+    -- Copyright:
+    --  (c) Some Person, 2013
+    --  Someone Else, 2014
+    -- ...
+
+or as: ::
+
+    -- | ...
+    -- Copyright: (c) Some Person, 2013
+    --     Someone Else, 2014
+    -- ...
+
+but not as: ::
+
+    -- | ...
+    -- Copyright: (c) Some Person, 2013
+    -- Someone Else, 2014
+    -- ...
+
+since the ``Someone`` needs to be indented more than the
+``Copyright``.
+
+Whether new lines and other formatting in multiline fields is
+preserved depends on the field type. For example, new lines in the
+``Copyright`` field are preserved, but new lines in the
+``Description`` field are not; leading whitespace is not preserved in
+either [#backend]_. Please note that we do not enforce the format for
+any of the fields and the established formats are just a convention.
+
+.. [#backend] Technically, whitespace and newlines in the
+   ``Description`` field are preserved verbatim by the HTML backend,
+   but because most browsers collapse whitespace in HTML, they don't
+   render as such. But other backends may render this whitespace.
+
+Fields of the Module Description
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``Module`` field specifies the current module name. Since the module
+name can be inferred automatically from the source file, it doesn't
+affect the output of any of the backends. But you might want to
+include it for any other tools that might be parsing these comments
+without the help of GHC.
+
+The ``Description`` field accepts some short text which outlines the
+general purpose of the module. If you're generating HTML, it will show
+up next to the module link in the module index.
+
+The ``Copyright``, ``License``, ``Maintainer`` and ``Stability`` fields should
+be obvious. An alternative spelling for the ``License`` field is accepted
+as ``Licence`` but the output will always prefer ``License``.
+
+The ``Portability`` field has seen varied use by different library
+authors. Some people put down things like operating system constraints
+there while others put down which GHC extensions are used in the module.
+Note that you might want to consider using the ``show-extensions`` module
+flag for the latter (see :ref:`module-attrs`).
+
+Finally, a module may contain a documentation comment before the
+module header, in which case this comment is interpreted by Haddock as
+an overall description of the module itself, and placed in a section
+entitled ``Description`` in the documentation for the module. All the
+usual Haddock :ref:`markup` is valid in this comment.
+
+Controlling the Documentation Structure
+---------------------------------------
+
+Haddock produces interface documentation that lists only the entities
+actually exported by the module. If there is no export list then all
+entities defined by the module are exported.
+
+The documentation for a module will
+include *all* entities exported by that module, even if they were
+re-exported from another module. The only exception is when Haddock can't
+see the declaration for the re-exported entity, perhaps because it isn't
+part of the batch of modules currently being processed.
+
+To Haddock the export list has even more significance than just
+specifying the entities to be included in the documentation. It also
+specifies the *order* that entities will be listed in the generated
+documentation. This leaves the programmer free to implement functions in
+any order he/she pleases, and indeed in any *module* he/she pleases, but
+still specify the order that the functions should be documented in the
+export list. Indeed, many programmers already do this: the export list
+is often used as a kind of ad-hoc interface documentation, with
+headings, groups of functions, type signatures and declarations in
+comments.
+
+In the next section we give examples illustrating most of the
+structural markup features. After the examples we go into more detail
+explaining the related markup, namely :ref:`section-headings`,
+:ref:`named-chunks`, and :ref:`re-exporting-entire-module`.
+
+.. _structure-examples:
+
+Documentation Structure Examples
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We now give several examples that produce similar results and
+illustrate most of the structural markup features. The first two
+examples use an export list, but the third example does not.
+
+The first example, using an export list with :ref:`section-headings`
+and inline section descriptions: ::
+
+    module Image
+      ( -- * Image importers
+        --
+        -- | There is a "smart" importer, 'readImage', that determines
+        -- the image format from the file extension, and several
+        -- "dumb" format-specific importers that decode the file as
+        -- the specified type.
+        readImage
+      , readPngImage
+      , readGifImage
+      , ...
+        -- * Image exporters
+        -- ...
+      ) where
+
+    import Image.Types ( Image )
+
+    -- | Read an image, guessing the format from the file name.
+    readImage :: FilePath -> IO Image
+    readImage = ...
+
+    -- | Read a GIF.
+    readGifImage :: FilePath -> IO Image
+    readGifImage = ...
+
+    -- | Read a PNG.
+    readPngImage :: FilePath -> IO Image
+    readPngImage = ...
+
+    ...
+
+Note that the order of the entities ``readPngImage`` and
+``readGifImage`` in the export list is different from the order of the
+actual declarations farther down; the order in the export list is the
+order used in the generated docs. Also, the imported ``Image`` type
+itself is not re-exported, so it will not be included in the rendered
+docs (see :ref:`hyperlinking-re-exported`).
+
+The second example, using an export list with a section description
+defined elsewhere (the ``$imageImporters``; see :ref:`named-chunks`):
+::
+
+    module Image
+      ( -- * Image importers
+        --
+        -- $imageImporters
+        readImage
+      , readPngImage
+      , readGifImage
+      , ...
+        -- * Image exporters
+        -- ...
+      ) where
+
+    import Image.Types ( Image )
+
+    -- $imageImporters
+    --
+    -- There is a "smart" importer, 'readImage', that determines the
+    -- image format from the file extension, and several "dumb"
+    -- format-specific importers that decode the file as the specified
+    -- type.
+
+    -- | Read an image, guessing the format from the file name.
+    readImage :: FilePath -> IO Image
+    readImage = ...
+
+    -- | Read a GIF.
+    readGifImage :: FilePath -> IO Image
+    readGifImage = ...
+
+    -- | Read a PNG.
+    readPngImage :: FilePath -> IO Image
+    readPngImage = ...
+
+    ...
+
+This produces the same rendered docs as the first example, but the
+source code itself is arguably more readable, since the documentation
+for the group of importer functions is closer to their definitions.
+
+The third example, without an export list: ::
+
+    module Image where
+
+    import Image.Types ( Image )
+
+    -- * Image importers
+    --
+    -- $imageImporters
+    --
+    -- There is a "smart" importer, 'readImage', that determines the
+    -- image format from the file extension, and several "dumb"
+    -- format-specific importers that decode the file as the specified
+    -- type.
+
+    -- | Read an image, guessing the format from the file name.
+    readImage :: FilePath -> IO Image
+    readImage = ...
+
+    -- | Read a GIF.
+    readGifImage :: FilePath -> IO Image
+    readGifImage = ...
+
+    -- | Read a PNG.
+    readPngImage :: FilePath -> IO Image
+    readPngImage = ...
+
+    ...
+
+    -- * Image exporters
+    -- ...
+
+Note that the section headers (e.g. ``-- * Image importers``) now
+appear in the module body itself, and that the section documentation
+is still given using :ref:`named-chunks`. Unlike in the first example
+when using an export list, the named chunk syntax ``$imageImporters``
+*must* be used for the section documentation; attempting to use the
+``-- | ...`` syntax to document the image importers here will wrongly
+associate the documentation chunk with the next definition!
+
+.. _section-headings:
+
+Section Headings
+~~~~~~~~~~~~~~~~
+
+You can insert headings and sub-headings in the documentation by
+including annotations at the appropriate point in the export list, or
+in the module body directly when not using an export list.
+
+For example: ::
+
+    module Foo (
+      -- * Classes
+      C(..),
+      -- * Types
+      -- ** A data type
+      T,
+      -- ** A record
+      R,
+      -- * Some functions
+      f, g
+      ) where
+
+Headings are introduced with the syntax ``-- *``, ``-- **`` and so
+on, where the number of ``*``\ s indicates the level of the heading
+(section, sub-section, sub-sub-section, etc.).
+
+If you use section headings, then Haddock will generate a table of
+contents at the top of the module documentation for you.
+
+By default, when generating HTML documentation Haddock will create an
+anchor to each section of the form ``#g:n``, where ``n`` is an integer
+that might change as you add new section headings. If you want to
+create stable links, you can add an explicit anchor (see
+:ref:`anchors`) after the section heading: ::
+
+  module Foo (
+    -- * Classes #classes#
+    C(..)
+  ) where
+
+This will create an HTML anchor ``#g:classes`` to the section.
+
+The alternative style of placing the commas at the beginning of each
+line is also supported, e.g.: ::
+
+    module Foo (
+      -- * Classes
+        C(..)
+      -- * Types
+      -- ** A data type
+      , T
+      -- ** A record
+      , R
+      -- * Some functions
+      , f
+      , g
+      ) where
+
+When not using an export list, you may insert section headers in the
+module body. Such section headers associate with all entities
+declared up until the next section header. For example: ::
+
+    module Foo where
+
+    -- * Classes
+    class C a where ...
+
+    -- * Types
+    -- ** A data type
+    data T = ...
+
+    -- ** A record
+    data R = ...
+
+    -- * Some functions
+    f :: ...
+    f = ...
+    g :: ...
+    g = ...
+
+.. _re-exporting-entire-module:
+
+Re-Exporting an Entire Module
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Haskell allows you to re-export the entire contents of a module (or at
+least, everything currently in scope that was imported from a given
+module) by listing it in the export list: ::
+
+    module A (
+      module B,
+      module C
+     ) where
+
+What will the Haddock-generated documentation for this module look like?
+Well, it depends on how the modules ``B`` and ``C`` are imported. If
+they are imported wholly and without any ``hiding`` qualifiers, then the
+documentation will just contain a cross-reference to the documentation
+for ``B`` and ``C``.
+
+However, if the modules are not *completely* re-exported, for example:
+::
+
+    module A (
+      module B,
+      module C
+     ) where
+
+    import B hiding (f)
+    import C (a, b)
+
+then Haddock behaves as if the set of entities re-exported from ``B``
+and ``C`` had been listed explicitly in the export list.
+
+The exception to this rule is when the re-exported module is declared
+with the ``hide`` attribute (see :ref:`module-attrs`), in which
+case the module is
+never cross-referenced; the contents are always expanded in place in the
+re-exporting module.
+
+.. _named-chunks:
+
+(Named) Chunks of Documentation
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+It is often desirable to include a chunk of documentation which is not
+attached to any particular Haskell declaration, for example, when
+giving summary documentation for a group of related definitions (see
+:ref:`structure-examples`). In addition to including such documentation
+chunks at the top of the file, as part of the
+:ref:`module-description`, you can also associate them with
+:ref:`section-headings`.
+
+There are several ways to associate documentation chunks with section
+headings, depending on whether you are using an export list or not:
+
+-  The documentation can be included in the export list directly, by
+   preceding it with a ``-- |``. For example: ::
+
+       module Foo (
+          -- * A section heading
+
+          -- | Some documentation not attached to a particular Haskell entity
+          ...
+        ) where
+
+   In this case the chunk is not "named".
+
+-  If the documentation is large and placing it inline in the export
+   list might bloat the export list and obscure the structure, then it
+   can be given a name and placed out of line in the body of the module.
+   This is achieved with a special form of documentation annotation
+   ``-- $``, which we call a *named chunk*: ::
+
+       module Foo (
+          -- * A section heading
+
+          -- $doc
+          ...
+        ) where
+
+       -- $doc
+       -- Here is a large chunk of documentation which may be referred to by
+       -- the name $doc.
+
+   The documentation chunk is given a name of your choice (here
+   ``doc``), which is the sequence of alphanumeric characters directly
+   after the ``-- $``, and it may be referred to by the same name in
+   the export list. Note that named chunks must come *after* any
+   imports in the module body.
+
+-  If you aren't using an export list, then your only choice is to use
+   a named chunk with the ``-- $`` syntax. For example: ::
+
+       module Foo where
+
+       -- * A section heading
+       --
+       -- $doc
+       -- Here is a large chunk of documentation which may be referred to by
+       -- the name $doc.
+
+   Just like with entity declarations when not using an export list,
+   named chunks of documentation are associated with the preceding
+   section header here, or with the implicit top-level documentation
+   section if there is no preceding section header.
+
+   **Warning**: the form used in the first bullet above, where the
+   chunk is not named, *does not work* when you aren't using an
+   export list. For example: ::
+
+       module Foo where
+
+       -- * A section heading
+       --
+       -- | Some documentation not attached to a particular Haskell entity
+
+       -- | The fooifier.
+       foo :: ...
+
+   will result in ``Some documentation not ...`` being attached to the
+   *next* entity declaration, here ``foo``, in addition to any other
+   documentation that next entity already has!
+
+.. _hyperlinking-re-exported:
+
+Hyperlinking and Re-Exported Entities
+-------------------------------------
+
+When Haddock renders a type in the generated documentation, it
+hyperlinks all the type constructors and class names in that type to
+their respective definitions. But for a given type constructor or class
+there may be several modules re-exporting it, and therefore several
+modules whose documentation contains the definition of that type or
+class (possibly including the current module!) so which one do we link
+to?
+
+Let's look at an example. Suppose we have three modules ``A``, ``B`` and
+``C`` defined as follows: ::
+
+    module A (T) where
+    data T a = C a
+
+    module B (f) where
+    import A
+    f :: T Int -> Int
+    f (C i) = i
+
+    module C (T, f) where
+    import A
+    import B
+
+Module ``A`` exports a datatype ``T``. Module ``B`` imports ``A`` and
+exports a function ``f`` whose type refers to ``T``. Also, both ``T``
+and ``f`` are re-exported from module C.
+
+Haddock takes the view that each entity has a *home* module; that is,
+the module that the library designer would most like to direct the user
+to, to find the documentation for that entity. So, Haddock makes all
+links to an entity point to the home module. The one exception is when
+the entity is also exported by the current module: Haddock makes a local
+link if it can.
+
+How is the home module for an entity determined? Haddock uses the
+following rules:
+
+-  If modules A and B both export the entity, and module A imports
+   (directly or indirectly) module B, then B is preferred.
+
+-  A module with the ``hide`` attribute is never chosen as the home.
+
+-  A module with the ``not-home`` attribute is only chosen if there are
+   no other modules to choose.
+
+If multiple modules fit the criteria, then one is chosen at random. If
+no modules fit the criteria (because the candidates are all hidden),
+then Haddock will issue a warning for each reference to an entity
+without a home.
+
+In the example above, module ``A`` is chosen as the home for ``T``
+because it does not import any other module that exports ``T``. The link
+from ``f``'s type in module ``B`` will therefore point to ``A.T``.
+However, ``C`` also exports ``T`` and ``f``, and the link from ``f``'s
+type in ``C`` will therefore point locally to ``C.T``.
+
+.. _module-attrs:
+
+Module Attributes
+-----------------
+
+Certain attributes may be specified for each module which affect the
+way that Haddock generates documentation for that module. Attributes are
+specified in a comma-separated list in an
+``{-# OPTIONS_HADDOCK ... #-}`` pragma at the top of the module, either
+before or after the module description. For example: ::
+
+    {-# OPTIONS_HADDOCK hide, prune #-}
+
+    -- |Module description
+    module A where
+    ...
+
+The options and module description can be in either order.
+
+The following attributes are currently understood by Haddock:
+
+``hide``
+    Omit this module from the generated documentation, but nevertheless
+    propagate definitions and documentation from within this module to
+    modules that re-export those definitions.
+
+``prune``
+    Omit definitions that have no documentation annotations from the
+    generated documentation.
+
+``not-home``
+    Indicates that the current module should not be considered to be the
+    home module for each entity it exports, unless that entity is not
+    exported from any other module. See :ref:`hyperlinking-re-exported`
+    for more details.
+
+``show-extensions``
+    Indicates that we should render the extensions used in this module
+    in the resulting documentation. This will only render if the output
+    format supports it. If Language is set, it will be shown as well and
+    all the extensions implied by it won't. All enabled extensions will
+    be rendered, including those implied by their more powerful
+    versions.
+
+``print-explicit-runtime-reps``
+    Print type variables that have kind ``RuntimeRep``. By default, these
+    are defaulted to ``LiftedRep`` so that end users don't have to see the
+    underlying levity polymorphism. This flag is analogous to GHC's
+    ``-fprint-explicit-runtime-reps`` flag.
+
+.. _markup:
+
+Markup
+------
+
+Haddock understands certain textual cues inside documentation
+annotations that tell it how to render the documentation. The cues (or
+“markup”) have been designed to be simple and mnemonic in ASCII so
+the programmer doesn't have to deal with heavyweight annotations when
+editing documentation comments.
+
+Paragraphs
+~~~~~~~~~~
+
+One or more blank lines separates two paragraphs in a documentation
+comment.
+
+Special Characters
+~~~~~~~~~~~~~~~~~~
+
+The following characters have special meanings in documentation comments:
+``\``, ``/``, ``'``, `````, ``"``, ``@``, ``<``, ``$``, ``#``. To insert a
+literal occurrence of one of these special characters, precede it with a
+backslash (``\``).
+
+Additionally, the character ``>`` has a special meaning at the beginning
+of a line, and the following characters have special meanings at the
+beginning of a paragraph: ``*``, ``-``. These characters can also be
+escaped using ``\``.
+
+Furthermore, the character sequence ``>>>`` has a special meaning at the
+beginning of a line. To escape it, just prefix the characters in the
+sequence with a backslash.
+
+Character References
+~~~~~~~~~~~~~~~~~~~~
+
+Although Haskell source files may contain any character from the Unicode
+character set, the encoding of these characters as bytes varies between
+systems. Consequently, only source files restricted to the ASCII character set
+are portable. Other characters may be specified in character and string
+literals using Haskell character escapes. To represent such characters
+in documentation comments, Haddock supports SGML-style numeric character
+references of the forms ``&#``\ D\ ``;`` and ``&#x``\ H\ ``;`` where D
+and H are decimal and hexadecimal numbers denoting a code position in
+Unicode (or ISO 10646). For example, the references ``&#x3BB;``,
+``&#x3bb;`` and ``&#955;`` all represent the lower-case letter lambda.
+
+Code Blocks
+~~~~~~~~~~~
+
+Displayed blocks of code are indicated by surrounding a paragraph with
+``@...@`` or by preceding each line of a paragraph with ``>`` (we often
+call these “bird tracks”). For example: ::
+
+    -- | This documentation includes two blocks of code:
+    --
+    -- @
+    --     f x = x + x
+    -- @
+    --
+    -- >  g x = x * 42
+
+There is an important difference between the two forms of code block: in
+the bird-track form, the text to the right of the ‘\ ``>``\ ’ is
+interpreted literally, whereas the ``@...@`` form interprets markup as
+normal inside the code block. In particular, ``/`` is markup for italics,
+and so e.g. ``@x / y / z@`` renders as ``x`` followed by italic
+``y`` with no slashes, followed by ``z``.
+
+Examples
+~~~~~~~~
+
+Haddock has markup support for examples of interaction with a
+*read-eval-print loop (REPL)*. An example is introduced with ``>>>``
+followed by an expression followed by zero or more result lines: ::
+
+    -- | Two examples are given below:
+    --
+    -- >>> fib 10
+    -- 55
+    --
+    -- >>> putStrLn "foo\nbar"
+    -- foo
+    -- bar
+
+Result lines that only contain the string ``<BLANKLINE>`` are rendered
+as blank lines in the generated documentation.
+
+Properties
+~~~~~~~~~~
+
+Haddock provides markup for properties: ::
+
+    -- | Addition is commutative:
+    --
+    -- prop> a + b = b + a
+
+This allows third-party applications to extract and verify them.
+
+Hyperlinked Identifiers
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Referring to a Haskell identifier, whether it be a type, class,
+constructor, or function, is done by surrounding it with a combination
+of single quotes and backticks. For example: ::
+
+    -- | This module defines the type 'T'.
+
+```T``` is also ok. ``'T``` and ```T'`` are accepted but less common.
+
+If there is an entity ``T`` in scope in the current module, then the
+documentation will hyperlink the reference in the text to the definition
+of ``T`` (if the output format supports hyperlinking, of course; in a
+printed format it might instead insert a page reference to the
+definition).
+
+It is also possible to refer to entities that are not in scope in the
+current module, by giving the full qualified name of the entity: ::
+
+    -- | The identifier 'M.T' is not in scope
+
+If ``M.T`` is not otherwise in scope, then Haddock will simply emit a
+link pointing to the entity ``T`` exported from module ``M`` (without
+checking to see whether either ``M`` or ``M.T`` exist).
+
+Since values and types live in different namespaces in Haskell, it is possible
+for a reference such as ``'X'`` to be ambiguous. In such a case, Haddock
+defaults to pointing to the type. The ambiguity can be overcome by explicitly
+specifying a namespace, by way of a ``v`` (for value) or ``t`` (for type)
+immediately before the link: ::
+
+    -- | An implicit reference to  'X', the type constructor
+    --   An explicit reference to v'X', the data constructor
+    --   An explicit reference to t'X', the type constructor
+    data X = X
+
+To make life easier for documentation writers, a quoted identifier is
+only interpreted as such if the quotes surround a lexically valid
+Haskell identifier. This means, for example, that it normally isn't
+necessary to escape the single quote when used as an apostrophe: ::
+
+    -- | I don't have to escape my apostrophes; great, isn't it?
+
+Nothing special is needed to hyperlink identifiers which contain
+apostrophes themselves: to hyperlink ``foo'`` one would simply type
+``'foo''``. Hyperlinking operators works in exactly the same way. ::
+
+    -- | A prefix operator @'(++)'@ and an infix identifier @'`elem`'@.
+
+Emphasis, Bold and Monospaced Styled Text
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Text can be emphasized, made bold (strong) or monospaced (typewriter font) 
+by surrounding it with slashes, double-underscores or at-symbols: ::
+
+    -- | This is /emphasized text/, __bold text__ and @monospaced text@.
+
+Note that those styled texts must be kept on the same line: ::
+
+    -- | Styles /do not work
+    -- | when continuing on the next line/
+
+Other markup is valid inside emphasized, bold and monospaced text.
+
+Frequent special cases: 
+
+* To have a forward slash inside of emphasis, just escape it: ``/fo\/o/``.
+* There's no need to escape a single underscore if you need it
+  bold: ``__This_text_with_underscores_is_bold__``.
+* ``@'f' a b@`` will hyperlink the identifier ``f`` inside the code
+  fragment.
+* ``@__FILE__@`` will render ``FILE`` in bold with no underscores, 
+  which may not be what you had in mind.
+
+Linking to Modules
+~~~~~~~~~~~~~~~~~~
+
+Linking to a module is done by surrounding the module name with double
+quotes: ::
+
+    -- | This is a reference to the "Foo" module.
+
+A basic check is done on the syntax of the header name to ensure that it
+is valid before turning it into a link but unlike with identifiers,
+whether the module is in scope isn't checked and will always be turned
+into a link.
+
+It is also possible to specify alternate text for the generated link
+using syntax analogous to that used for URLs: ::
+
+  -- | This is a reference to [the main module]("Module.Main").
+
+Itemized and Enumerated Lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+A bulleted item is represented by preceding a paragraph with either
+“``*``” or “``-``”. A sequence of bulleted paragraphs is rendered as an
+itemized list in the generated documentation, e.g.: ::
+
+    -- | This is a bulleted list:
+    --
+    --     * first item
+    --
+    --     * second item
+
+An enumerated list is similar, except each paragraph must be preceded by
+either “``(n)``” or “``n.``” where n is any integer. e.g. ::
+
+    -- | This is an enumerated list:
+    --
+    --     (1) first item
+    --
+    --     2. second item
+
+Lists of the same type don't have to be separated by a newline: ::
+
+    -- | This is an enumerated list:
+    --
+    --     (1) first item
+    --     2. second item
+    --
+    -- This is a bulleted list:
+    --
+    --     * first item
+    --     * second item
+
+You can have more than one line of content in a list element: ::
+
+    -- |
+    -- * first item
+    -- and more content for the first item
+    -- * second item
+    -- and more content for the second item
+
+You can even nest whole paragraphs inside of list elements. The rules
+are 4 spaces for each indentation level. You're required to use a
+newline before such nested paragraphs: ::
+
+    {-|
+    * Beginning of list
+    This belongs to the list above!
+
+        > nested
+        > bird
+        > tracks
+
+        * Next list
+        More of the indented list.
+
+            * Deeper
+
+                @
+                even code blocks work
+                @
+
+                * Deeper
+
+                        1. Even deeper!
+                        2. No newline separation even in indented lists.
+    -}
+
+The indentation of the first list item is honoured. That is, in the
+following example the items are on the same level. Before Haddock
+2.16.1, the second item would have been nested under the first item
+which was unexpected. ::
+
+    {-|
+        * foo
+
+        * bar
+    -}
+
+Definition Lists
+~~~~~~~~~~~~~~~~
+
+Definition lists are written as follows: ::
+
+    -- | This is a definition list:
+    --
+    --   [@foo@]: The description of @foo@.
+    --
+    --   [@bar@]: The description of @bar@.
+
+To produce output something like this:
+
+``foo``
+    The description of ``foo``.
+
+``bar``
+    The description of ``bar``.
+
+Each paragraph should be preceded by the “definition term” enclosed in
+square brackets and followed by a colon. Other markup operators may be
+used freely within the definition term. You can escape ``]`` with a
+backslash as usual.
+
+Same rules about nesting and no newline separation as for bulleted and
+numbered lists apply.
+
+URLs
+~~~~
+
+A URL can be included in a documentation comment by surrounding it in
+angle brackets, for example: ::
+
+    <http://example.com>
+
+If the output format supports it, the URL will be turned into a
+hyperlink when rendered.
+
+If Haddock sees something that looks like a URL (such as something
+starting with ``http://`` or ``ssh://``) where the URL markup is valid,
+it will automatically make it a hyperlink.
+
+Links
+~~~~~
+
+Haddock supports Markdown syntax for inline links. A link consists of a
+link text and a URL. The link text is enclosed in square brackets and
+followed by the URL enclosed in regular parentheses, for example: ::
+
+    [some link](http://example.com)
+
+The link text is used as a description for the URL if the output
+format supports it.
+   
+Images
+~~~~~~
+
+Haddock supports Markdown syntax for inline images. This resembles the
+syntax for links, but starts with an exclamation mark. An example looks
+like this: ::
+
+    ![image description](pathtoimage.png)
+
+If the output format supports it, the image will be rendered inside the
+documentation. The image description is used as replacement text and/or
+an image title.
+
+Mathematics / LaTeX
+~~~~~~~~~~~~~~~~~~~
+
+Haddock supports LaTeX syntax for rendering mathematical notation. The
+delimiters are ``\[...\]`` for displayed mathematics and ``\(...\)``
+for in-line mathematics. An example looks like this: ::
+
+  \[
+  f(a) = \frac{1}{2\pi i}\oint_\gamma \frac{f(z)}{z-a}\,\mathrm{d}z
+  \]
+
+If the output format supports it, the mathematics will be rendered
+inside the documentation. For example, the HTML backend will display
+the mathematics via `MathJax <https://www.mathjax.org>`__.
+
+Grid Tables
+~~~~~~~~~~~
+
+Inspired by reSTs grid tables, Haddock supports a complete table representation
+via grid-like "ASCII art". Grid tables are described with a visual grid made
+up of the characters "-", "=", "|", and "+". The hyphen ("-") is used for
+horizontal lines (row separators). The equals sign ("=") may be used to
+separate optional header rows from the table body. The vertical bar ("|") is
+used for vertical lines (column separators). The plus sign ("+") is used for
+intersections of horizontal and vertical lines. ::
+
+    -- | This is a grid table:
+    --
+    -- +------------------------+------------+----------+----------+
+    -- | Header row, column 1   | Header 2   | Header 3 | Header 4 |
+    -- | (header rows optional) |            |          |          |
+    -- +========================+============+==========+==========+
+    -- | body row 1, column 1   | column 2   | column 3 | column 4 |
+    -- +------------------------+------------+----------+----------+
+    -- | body row 2             | Cells may span columns.          |
+    -- +------------------------+------------+---------------------+
+    -- | body row 3             | Cells may  | \[                  |
+    -- +------------------------+ span rows. | f(n) = \sum_{i=1}   |
+    -- | body row 4             |            | \]                  |
+    -- +------------------------+------------+---------------------+
+
+.. _anchors:
+
+Anchors
+~~~~~~~
+
+Sometimes it is useful to be able to link to a point in the
+documentation which doesn't correspond to a particular entity. For that
+purpose, we allow *anchors* to be included in a documentation comment.
+The syntax is ``#label#``, where label is the name of the anchor. An
+anchor is invisible in the generated documentation.
+
+To link to an anchor from elsewhere, use the syntax ``"module#label"``
+where module is the module name containing the anchor, and label is the
+anchor label. The module does not have to be local, it can be imported
+via an interface. Please note that in Haddock versions 2.13.x and
+earlier, the syntax was ``"module\#label"``. It is considered deprecated
+and will be removed in the future.
+
+Headings
+~~~~~~~~
+
+Headings inside of comment documentation are possible by preceding them
+with a number of ``=``\ s. From 1 to 6 are accepted. Extra ``=``\ s will
+be treated as belonging to the text of the heading. Note that it's up to
+the output format to decide how to render the different levels. ::
+
+    -- |
+    -- = Heading level 1 with some /emphasis/
+    -- Something underneath the heading.
+    --
+    -- == /Subheading/
+    -- More content.
+    --
+    -- === Subsubheading
+    -- Even more content.
+
+Note that while headings have to start on a new paragraph, we allow
+paragraph-level content to follow these immediately. ::
+
+    -- |
+    -- = Heading level 1 with some __bold__
+    -- Something underneath the heading.
+    --
+    -- == /Subheading/
+    -- More content.
+    --
+    -- === Subsubheading
+    -- >>> examples are only allowed at the start of paragraphs
+
+As of 2.15.1, there's experimental (read: subject to change or get
+removed) support for collapsible headers: simply wrap your existing
+header title in underscores, as per bold syntax. The collapsible section
+will stretch until the end of the comment or until a header of equal or
+smaller number of ``=``\ s. ::
+
+    -- |
+    -- === __Examples:__
+    -- >>> Some very long list of examples
+    --
+    -- ==== This still falls under the collapse
+    -- Some specialised examples
+    --
+    -- === This is does not go into the collapsable section.
+    -- More content.
+
+Metadata
+~~~~~~~~
+
+Since Haddock 2.16.0, some support for embedding metadata in the
+comments has started to appear. The use of such data aims to standardise
+various community conventions in how such information is conveyed and to
+provide uniform rendering.
+
+Since
+^^^^^
+
+``@since`` annotation can be used to convey information about when the
+function was introduced or when it has changed in a way significant to
+the user. ``@since`` is a paragraph-level element. While multiple such
+annotations are not an error, only the one to appear in the comment last
+will be used. ``@since`` has to be followed with a version number, no
+further description is currently allowed. The meaning of this feature is
+subject to change in the future per user feedback. ::
+
+    -- |
+    -- Some comment
+    --
+    -- @since 1.2.3
+
+Additionally, as of GHC 9.10 ``@since`` in docstrings following export list items: ::
+
+    module Mod
+        ( wombat -- ^ @since 2.0
+        ) where ...
+
+This has the function of superceding the ``@since`` annotation given at the
+definition site of ``wombat`` and can be used to record changes in the
+module exports, particularly when a declaration is re-exported from another
+module.
diff --git a/utils/haddock/doc/multi-components.rst b/utils/haddock/doc/multi-components.rst
new file mode 100644
index 0000000000000000000000000000000000000000..9f52cad3380d4a7c45c55e22937b160d5f15209c
--- /dev/null
+++ b/utils/haddock/doc/multi-components.rst
@@ -0,0 +1,48 @@
+Haddocks of multiple components
+===============================
+
+Haddock supports building documentation of multiple components.  First, one
+needs to build haddocks of all components which can be done with:
+
+.. code-block:: none
+
+    cabal haddock --haddock-html \
+                  --haddock-quickjump \
+                  --haddock-option="--use-index=../doc-index.html" \
+                  --haddock-option="--use-contents=../index.html" \
+                  --haddock-option="--base-url=.." \
+                  all
+
+The new ``--base-url`` option will allow to access the static files from the
+main directory (in this example its the relative ``./..`` directory).  It will
+also prevent ``haddock`` from copying its static files to each of the
+documentation folders, we're only need a single copy of them where the
+``--base-url`` option points to.
+
+The second step requires to copy all the haddocks to a common directory, let's
+say ``./docs``,  this will depend on your project and it might look like:
+
+.. code-block:: none
+
+    cp -r dist-newstyle/build/x86_64-linux/ghc-9.0.1/package-a-0.1.0.0/doc/html/package-a/ docs
+    cp -r dist-newstyle/build/x86_64-linux/ghc-9.0.1/package-b-0.1.0.0/doc/html/package-b/ docs
+
+Note that you can also include documentation of other packages in this way,
+e.g. ``base``, but you need to know where it is hidden on your hard-drive.
+
+To build html and js (``quickjump``) indexes one can now invoke ``haddock`` with:
+
+.. code-block:: none
+
+    haddock \
+      -o docs \
+      --quickjump --gen-index --gen-contents \
+      --read-interface=package-a,docs/package-a/package-a.haddock \
+      --read-interface=package-b,docs/package-b/package-b.haddock
+
+Note: the ``PATH`` in ``--read-interface=PATH,...`` must be a relative url of
+a package it points to (relative to the ``docs`` directory).
+
+There's an example project which shows how to do that posted `here
+<https://github.com/coot/haddock-example>`_, which haddocks are served on
+`github-pages <https://coot.github.io/haddock-example>`_.
diff --git a/utils/haddock/driver/Main.hs b/utils/haddock/driver/Main.hs
new file mode 100644
index 0000000000000000000000000000000000000000..44df4692cb1426a8c8faad1741b1c08df4b6063c
--- /dev/null
+++ b/utils/haddock/driver/Main.hs
@@ -0,0 +1,7 @@
+module Main where
+
+import Documentation.Haddock (haddock)
+import GHC.ResponseFile (getArgsWithResponseFiles)
+
+main :: IO ()
+main = getArgsWithResponseFiles >>= haddock
diff --git a/utils/haddock/fourmolu.yaml b/utils/haddock/fourmolu.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..39acb7d22c9bfc78e45118b918a9009213d2f55e
--- /dev/null
+++ b/utils/haddock/fourmolu.yaml
@@ -0,0 +1,11 @@
+indentation: 2
+comma-style: leading # for lists, tuples etc. - can also be 'leading'
+import-export-style: leading
+record-brace-space: false # rec {x = 1} vs. rec{x = 1}
+indent-wheres: true # 'false' means save space by only half-indenting the 'where' keyword
+respectful: true # don't be too opinionated about newlines etc.
+haddock-style: single-line # '--' vs. '{-'
+newlines-between-decls: 1 # number of newlines between top-level declarations
+fixities: []
+function-arrows: leading
+single-constraint-parens: never
diff --git a/utils/haddock/ghc-tags.yaml b/utils/haddock/ghc-tags.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..423867ca77596136b36e59c71737c52aa09fac4b
--- /dev/null
+++ b/utils/haddock/ghc-tags.yaml
@@ -0,0 +1,9 @@
+source_paths:
+-  ./driver         
+-  ./haddock-api    
+-  ./haddock-library
+-  ./haddock-test   
+-  ./hoogle-test    
+-  ./html-test      
+-  ./hypsrc-test    
+-  ./latex-test     
diff --git a/utils/haddock/ghc.mk b/utils/haddock/ghc.mk
new file mode 100644
index 0000000000000000000000000000000000000000..fc4a4632c37577ae69c56e0a67501961c8b70b41
--- /dev/null
+++ b/utils/haddock/ghc.mk
@@ -0,0 +1,73 @@
+utils/haddock_USES_CABAL = YES
+utils/haddock_PACKAGE = haddock
+utils/haddock_CONFIGURE_OPTS = --flag in-ghc-tree
+utils/haddock_dist_SHELL_WRAPPER = YES
+utils/haddock_dist_INSTALL = YES
+utils/haddock_dist_INSTALL_INPLACE = YES
+utils/haddock_dist_INSTALL_SHELL_WRAPPER_NAME = haddock-ghc-$(ProjectVersion)
+utils/haddock_dist_PROGNAME = haddock
+
+ifeq "$(GhcProfiled)" "YES"
+utils/haddock_dist_PROGRAM_WAY = p
+utils/haddock_dist_WAY = p
+utils/haddock/dist/build/tmp/$(utils/haddock_dist_PROG) : $(utils/haddock_dist_p_LIB)
+endif
+
+ifeq "$(HADDOCK_DOCS)" "NO"
+utils/haddock_dist_NOT_NEEDED = YES
+endif
+
+$(eval $(call build-prog,utils/haddock,dist,2))
+
+ifneq "$(BINDIST)" "YES"
+
+$(INPLACE_BIN)/$(utils/haddock_dist_PROG): $(INPLACE_LIB)/html $(INPLACE_LIB)/latex
+
+$(INPLACE_LIB)/html:
+	$(call removeTrees,$@)
+	"$(CP)" -RL utils/haddock/haddock-api/resources/html $@
+
+$(INPLACE_LIB)/latex:
+	$(call removeTrees,$@)
+	"$(CP)" -RL utils/haddock/haddock-api/resources/latex $@
+
+endif
+
+utils/haddock_dist_DATA_FILES += html/quick-jump.min.js
+utils/haddock_dist_DATA_FILES += html/quick-jump.css
+utils/haddock_dist_DATA_FILES += html/haddock-bundle.min.js
+utils/haddock_dist_DATA_FILES += html/Classic.theme/haskell_icon.gif
+utils/haddock_dist_DATA_FILES += html/Classic.theme/minus.gif
+utils/haddock_dist_DATA_FILES += html/Classic.theme/plus.gif
+utils/haddock_dist_DATA_FILES += html/Classic.theme/xhaddock.css
+utils/haddock_dist_DATA_FILES += html/Ocean.theme/hslogo-16.png
+utils/haddock_dist_DATA_FILES += html/Ocean.theme/minus.gif
+utils/haddock_dist_DATA_FILES += html/Ocean.theme/ocean.css
+utils/haddock_dist_DATA_FILES += html/Ocean.theme/plus.gif
+utils/haddock_dist_DATA_FILES += html/Ocean.theme/synopsis.png
+utils/haddock_dist_DATA_FILES += html/Linuwial.std-theme/linuwial.css
+utils/haddock_dist_DATA_FILES += html/Linuwial.std-theme/synopsis.png
+utils/haddock_dist_DATA_FILES += html/solarized.css
+utils/haddock_dist_DATA_FILES += html/highlight.js
+utils/haddock_dist_DATA_FILES += latex/haddock.sty
+
+ifeq "$(HADDOCK_DOCS)" "YES"
+install: install_utils/haddock_data
+ifeq "$(Windows_Host)" "NO"
+install: install_utils/haddock_link
+endif
+endif
+
+.PHONY: install_utils/haddock_data
+install_utils/haddock_data:
+	$(foreach i,$(sort $(dir $(utils/haddock_dist_DATA_FILES))), \
+	    $(call make-command,$(INSTALL_DIR) "$(DESTDIR)$(ghclibdir)/$i"))
+	$(foreach i,$(utils/haddock_dist_DATA_FILES), \
+	    $(call make-command,$(INSTALL_DATA) $(INSTALL_OPTS) utils/haddock/haddock-api/resources/$i "$(DESTDIR)$(ghclibdir)/$(dir $i)"))
+
+.PHONY: install_utils/haddock_link
+install_utils/haddock_link:
+	$(call removeFiles,"$(DESTDIR)$(bindir)/haddock")
+	$(LN_S) $(utils/haddock_dist_INSTALL_SHELL_WRAPPER_NAME) "$(DESTDIR)$(bindir)/haddock"
+
+BINDIST_EXTRAS += $(addprefix utils/haddock/haddock-api/resources/,$(utils/haddock_dist_DATA_FILES))
diff --git a/utils/haddock/haddock-api/CHANGES.md b/utils/haddock/haddock-api/CHANGES.md
new file mode 100644
index 0000000000000000000000000000000000000000..70d575ec4d0cdbf90f3939b7a7465e313228dbe4
--- /dev/null
+++ b/utils/haddock/haddock-api/CHANGES.md
@@ -0,0 +1 @@
+See [`haddock`'s changelog](https://hackage.haskell.org/package/haddock/changelog).
diff --git a/utils/haddock/haddock-api/LICENSE b/utils/haddock/haddock-api/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..d5f0b37c4140c901b64760bfca422e1cd94a5e1c
--- /dev/null
+++ b/utils/haddock/haddock-api/LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2002-2010, Simon Marlow
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the
+   distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/utils/haddock/haddock-api/Setup.lhs b/utils/haddock/haddock-api/Setup.lhs
new file mode 100755
index 0000000000000000000000000000000000000000..5bde0de962274e26328ecffabb4e9f6430a10cc9
--- /dev/null
+++ b/utils/haddock/haddock-api/Setup.lhs
@@ -0,0 +1,3 @@
+#!/usr/bin/env runhaskell
+> import Distribution.Simple
+> main = defaultMain
diff --git a/utils/haddock/haddock-api/haddock-api.cabal b/utils/haddock/haddock-api/haddock-api.cabal
new file mode 100644
index 0000000000000000000000000000000000000000..3a881cac89e005b51baf15c60b24f2063c1d8c4f
--- /dev/null
+++ b/utils/haddock/haddock-api/haddock-api.cabal
@@ -0,0 +1,210 @@
+cabal-version:        3.0
+name:                 haddock-api
+version:              2.28.0
+synopsis:             A documentation-generation tool for Haskell libraries
+description:          Haddock is a documentation-generation tool for Haskell
+                      libraries
+license:              BSD-2-Clause
+license-file:         LICENSE
+author:               Simon Marlow, David Waern
+maintainer:           Alec Theriault <alec.theriault@gmail.com>, Alex Biehl <alexbiehl@gmail.com>, Simon Hengel <sol@typeful.net>, Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>
+homepage:             http://www.haskell.org/haddock/
+bug-reports:          https://github.com/haskell/haddock/issues
+copyright:            (c) Simon Marlow, David Waern
+category:             Documentation
+build-type:           Simple
+tested-with:          GHC==9.6.*
+
+extra-source-files:
+  CHANGES.md
+
+data-dir:
+  resources
+data-files:
+  html/quick-jump.min.js
+  html/haddock-bundle.min.js
+  html/quick-jump.css
+  html/solarized.css
+  html/highlight.js
+  html/Classic.theme/haskell_icon.gif
+  html/Classic.theme/minus.gif
+  html/Classic.theme/plus.gif
+  html/Classic.theme/xhaddock.css
+  html/Ocean.theme/hslogo-16.png
+  html/Ocean.theme/minus.gif
+  html/Ocean.theme/ocean.css
+  html/Ocean.theme/plus.gif
+  html/Ocean.theme/synopsis.png
+  html/Linuwial.std-theme/linuwial.css
+  html/Linuwial.std-theme/synopsis.png
+  latex/haddock.sty
+
+library
+  default-language: Haskell2010
+
+  -- this package typically supports only single major versions
+  build-depends: base            ^>= 4.16.0
+               , ghc             ^>= 9.9
+               , ghc-paths       ^>= 0.1.0.12
+               , haddock-library ^>= 1.11
+               , xhtml           ^>= 3000.2.2
+               , parsec          ^>= 3.1.13.0
+
+  -- Versions for the dependencies below are transitively pinned by
+  -- the non-reinstallable `ghc` package and hence need no version
+  -- bounds
+  build-depends: array
+               , bytestring
+               , containers
+               , deepseq
+               , directory
+               , exceptions
+               , filepath
+               , ghc-boot
+               , mtl
+               , transformers
+
+  hs-source-dirs: src
+
+  ghc-options: -funbox-strict-fields -O2
+               -Wall
+               -Wcompat
+               -Wcompat-unqualified-imports
+               -Widentities
+               -Wredundant-constraints
+               -Wnoncanonical-monad-instances
+               -Wmissing-home-modules
+               -Wincomplete-uni-patterns
+               -Wincomplete-record-updates
+
+
+  exposed-modules:
+    Documentation.Haddock
+
+  other-modules:
+    Haddock
+    Haddock.Interface
+    Haddock.Interface.Rename
+    Haddock.Interface.RenameType
+    Haddock.Interface.Create
+    Haddock.Interface.AttachInstances
+    Haddock.Interface.Json
+    Haddock.Interface.LexParseRn
+    Haddock.Interface.ParseModuleHeader
+    Haddock.Parser
+    Haddock.Utils
+    Haddock.Utils.Json
+    Haddock.Utils.Json.Types
+    Haddock.Utils.Json.Parser
+    Haddock.Backends.Xhtml
+    Haddock.Backends.Xhtml.Decl
+    Haddock.Backends.Xhtml.DocMarkup
+    Haddock.Backends.Xhtml.Layout
+    Haddock.Backends.Xhtml.Meta
+    Haddock.Backends.Xhtml.Names
+    Haddock.Backends.Xhtml.Themes
+    Haddock.Backends.Xhtml.Types
+    Haddock.Backends.Xhtml.Utils
+    Haddock.Backends.LaTeX
+    Haddock.Backends.HaddockDB
+    Haddock.Backends.Hoogle
+    Haddock.Backends.Hyperlinker
+    Haddock.Backends.Hyperlinker.Parser
+    Haddock.Backends.Hyperlinker.Renderer
+    Haddock.Backends.Hyperlinker.Types
+    Haddock.Backends.Hyperlinker.Utils
+    Haddock.ModuleTree
+    Haddock.Types
+    Haddock.Doc
+    Haddock.Version
+    Haddock.InterfaceFile
+    Haddock.Options
+    Haddock.GhcUtils
+    Haddock.Convert
+    Paths_haddock_api
+
+  autogen-modules:
+    Paths_haddock_api
+
+test-suite spec
+  type:             exitcode-stdio-1.0
+  default-language: Haskell2010
+  main-is:          Spec.hs
+  ghc-options: -Wall
+
+  hs-source-dirs:
+      test
+    , src
+
+  other-modules:
+    Haddock
+    Haddock.Backends.Hoogle
+    Haddock.Backends.Hyperlinker
+    Haddock.Backends.Hyperlinker.Renderer
+    Haddock.Backends.Hyperlinker.Utils
+    Haddock.Backends.LaTeX
+    Haddock.Backends.Xhtml
+    Haddock.Backends.Xhtml.Decl
+    Haddock.Backends.Xhtml.DocMarkup
+    Haddock.Backends.Xhtml.Layout
+    Haddock.Backends.Xhtml.Meta
+    Haddock.Backends.Xhtml.Names
+    Haddock.Backends.Xhtml.Themes
+    Haddock.Backends.Xhtml.Types
+    Haddock.Backends.Xhtml.Utils
+    Haddock.Convert
+    Haddock.Doc
+    Haddock.GhcUtils
+    Haddock.Interface
+    Haddock.Interface.AttachInstances
+    Haddock.Interface.Create
+    Haddock.Interface.Json
+    Haddock.Interface.LexParseRn
+    Haddock.Interface.ParseModuleHeader
+    Haddock.Interface.Rename
+    Haddock.InterfaceFile
+    Haddock.ModuleTree
+    Haddock.Options
+    Haddock.Parser
+    Haddock.Types
+    Haddock.Utils
+    Haddock.Utils.Json
+    Haddock.Utils.Json.Types
+    Haddock.Utils.Json.Parser
+    Haddock.Version
+    Paths_haddock_api
+    Haddock.Backends.Hyperlinker.ParserSpec
+    Haddock.Backends.Hyperlinker.Parser
+    Haddock.Backends.Hyperlinker.Types
+
+  build-depends: ghc             ^>= 9.7
+               , ghc-paths       ^>= 0.1.0.12
+               , haddock-library ^>= 1.11
+               , xhtml           ^>= 3000.2.2
+               , hspec           ^>= 2.9
+               , parsec          ^>= 3.1.13.0
+               , QuickCheck      >= 2.11  && ^>= 2.14
+
+  -- Versions for the dependencies below are transitively pinned by
+  -- the non-reinstallable `ghc` package and hence need no version
+  -- bounds
+  build-depends: base
+               , array
+               , bytestring
+               , containers
+               , deepseq
+               , directory
+               , exceptions
+               , filepath
+               , ghc-boot
+               , ghc-boot-th
+               , mtl
+               , transformers
+
+  build-tool-depends:
+    hspec-discover:hspec-discover ^>= 2.9
+
+source-repository head
+  type:     git
+  subdir:   haddock-api
+  location: https://github.com/haskell/haddock.git
diff --git a/utils/haddock/haddock-api/resources/html/Classic.theme/haskell_icon.gif b/utils/haddock/haddock-api/resources/html/Classic.theme/haskell_icon.gif
new file mode 100644
index 0000000000000000000000000000000000000000..10589f91936c4b0ec54f67e59e7629bd1d95f2ad
Binary files /dev/null and b/utils/haddock/haddock-api/resources/html/Classic.theme/haskell_icon.gif differ
diff --git a/utils/haddock/haddock-api/resources/html/Classic.theme/minus.gif b/utils/haddock/haddock-api/resources/html/Classic.theme/minus.gif
new file mode 100644
index 0000000000000000000000000000000000000000..1deac2fe1a42e35b994f1b855488f392c50f6a89
Binary files /dev/null and b/utils/haddock/haddock-api/resources/html/Classic.theme/minus.gif differ
diff --git a/utils/haddock/haddock-api/resources/html/Classic.theme/plus.gif b/utils/haddock/haddock-api/resources/html/Classic.theme/plus.gif
new file mode 100644
index 0000000000000000000000000000000000000000..2d15c14173d23f664b955cd24f51c82f5f09d91d
Binary files /dev/null and b/utils/haddock/haddock-api/resources/html/Classic.theme/plus.gif differ
diff --git a/utils/haddock/haddock-api/resources/html/Classic.theme/xhaddock.css b/utils/haddock/haddock-api/resources/html/Classic.theme/xhaddock.css
new file mode 100644
index 0000000000000000000000000000000000000000..e7488cd2e96b891fc34d9d3417947ee42e809a05
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/Classic.theme/xhaddock.css
@@ -0,0 +1,519 @@
+* {
+	margin: 0;
+	padding: 0;
+}
+
+.extension-list {
+    list-style-type: none;
+    margin-left: 0;
+    padding-left: 0;
+}
+
+body {
+  	background-color: #ffffff;
+  	color: #000000;
+  	font-size: 100%;
+	font-family: sans-serif;
+	padding: 8px;
+}
+
+a:link    { color: #0000e0; text-decoration: none }
+a:visited { color: #0000a0; text-decoration: none }
+a:hover   { background-color: #e0e0ff; text-decoration: none }
+
+/* <tt> font is a little too small in MSIE */
+tt  { font-size: 100%; }
+pre { font-size: 100%; }
+.keyword { text-decoration: underline; }
+.caption {
+	font-weight: bold;
+	margin: 0;
+	padding: 0;
+}
+
+h1 {
+  padding-top: 15px;
+  font-weight: bold;
+  font-size: 150%;
+}
+
+h2 {
+  padding-top: 10px;
+  font-weight: bold;
+  font-size: 130%
+  }
+
+h3 {
+  padding-top: 5px;
+  font-weight: bold;
+  font-size: 110%
+  }
+
+h4, h5 {
+  font-weight: bold;
+  font-size: 100%
+  }
+
+h1, h2, h3, h4, h5 {
+	margin-top: 0.5em;
+	margin-bottom: 0.5em;
+}
+
+p  {
+	padding-top: 2px;
+	padding-left: 10px;
+}
+
+ul, ol, dl {
+	padding-top: 2px;
+	padding-left: 10px;
+	margin-left: 2.5em;
+}
+
+pre  {
+	padding-top: 2px;
+	padding-left: 20px;
+}
+
+* + p, * + pre {
+	margin-top: 1em;
+}
+.caption + p, .src + p {
+	margin-top: 0;
+}
+
+.def {
+	font-weight: bold;
+}
+
+ul.links {
+	list-style: none;
+	text-align: left;
+	float: right;
+	display: inline-table;
+	padding: 0;
+}
+
+ul.links li {
+	display: inline;
+	border-left-width: 1px;
+	border-left-color: #ffffff;
+	border-left-style: solid;
+	white-space: nowrap;
+	padding: 1px 5px;
+}
+
+.hide {	display: none; }
+.show { }
+.collapser {
+  background: url(minus.gif) no-repeat 0 0.3em;
+}
+.expander {
+  background: url(plus.gif) no-repeat 0 0.3em;
+}
+.collapser, .expander {
+  padding-left: 14px;
+  cursor: pointer;
+}
+
+@media print {
+  #footer { display: none; }
+}
+
+#package-header {
+	color: #ffffff;
+	padding: 5px 5px 5px 31px;
+	margin: 0 0 1px;
+	background: #000099 url(haskell_icon.gif) no-repeat 5px 6px;
+	position: relative;
+}
+
+#package-header .caption {
+	font-weight: normal;
+	font-style: normal;
+}
+#package-header a:link    { color: #ffffff }
+#package-header a:visited { color: #ffff00 }
+#package-header a:hover   { background-color: #6060ff; }
+#package-header ul.links li:hover { background-color: #6060ff; }
+
+div#style-menu-holder {
+	position: relative;
+	z-index: 2;
+	display: inline;
+}
+
+#style-menu {
+	position: absolute;
+	z-index: 1;
+	overflow: visible;
+	background-color: #000099;
+	margin: 0;
+	width: 6em;
+	text-align: center;
+	right: 0;
+	padding: 2px 2px 1px;
+	top: 1.25em;
+}
+
+#style-menu li {
+	display: list-item;
+	border-style: none;
+	margin: 0;
+	padding: 3px;
+	color: #000;
+	list-style-type: none;
+	border-top: 1px solid #ffffff;
+}
+
+#module-header {
+	overflow: hidden; /* makes sure info float is properly contained */
+	display: inline-block; /* triggers hasLayout in IE*/
+}
+
+#module-header {
+	display: block; /* back to block */
+	background-color: #0077dd;
+	padding: 5px;
+}
+
+#module-header .caption {
+	font-size: 200%;
+	padding: .35em 0;
+	font-weight: normal;
+	font-style: normal;
+}
+
+table.info {
+	color: #ffffff;
+	display: block;
+	float: right;
+	max-width: 50%;
+}
+
+.info th, .info td {
+	text-align: left;
+	padding: 0 10px 0 0;
+}
+
+
+#table-of-contents {
+	margin-top: 1em;
+	margin-bottom: 2em;
+}
+
+#table-of-contents ul {
+	margin-top: 1em;
+	margin-bottom: 1em;
+	margin-left: 0;
+	list-style-type: none;
+	padding: 0;
+}
+
+#table-of-contents ul ul {
+	margin-left: 2.5em;
+}
+
+#description .caption,
+#synopsis .caption,
+#module-list .caption,
+#index .caption {
+  padding-top: 15px;
+  font-weight: bold;
+  font-size: 150%
+}
+
+#synopsis {
+	margin-bottom: 2em;
+}
+
+#synopsis .expander,
+#synopsis .collapser {
+  background: none;
+  padding-left: inherit;
+}
+
+#synopsis .hide {
+  display: inherit;
+}
+
+#synopsis ul {
+	margin: 0;
+	padding-top: 0;
+	padding-left: 20px;
+	list-style-type: none;
+}
+
+#synopsis li {
+	margin-top: 8px;
+	margin-bottom: 8px;
+	padding: 3px;
+}
+
+#synopsis li li {
+	padding: 0;
+	margin-top: 0;
+	margin-bottom: 0;
+}
+
+
+div.top {
+	margin-top: 1em;
+	clear: left;
+	margin-bottom: 1em;
+}
+
+div.top h5 {
+	margin-left: 10px;
+}
+
+
+.src {
+	padding: 3px;
+	background-color: #f0f0f0;
+	font-family: monospace;
+	margin-bottom: 0;
+}
+
+
+.src a.link {
+	float: right;
+	border-left-width: 1px;
+	border-left-color: #000099;
+	border-left-style: solid;
+	white-space: nowrap;
+	font-size: small;
+	padding: 0 8px 2px 5px;
+	margin-right: -3px;
+	background-color: #f0f0f0;
+	-moz-user-select: none;
+}
+
+div.subs {
+	margin-left: 10px;
+	clear: both;
+	margin-top: 2px;
+}
+
+.subs dl {
+	margin-left: 0;
+}
+
+.subs dl dl {
+	padding-left: 0;
+	padding-top: 4px;
+}
+
+.subs dd
+{
+  margin: 2px 0 9px 2em;
+}
+
+.subs dd.empty {
+  display: none;
+}
+
+.subs table {
+	margin-left: 10px;
+	border-spacing: 1px 1px;
+	margin-top: 4px;
+	margin-bottom: 4px;
+}
+
+.subs table table {
+	margin-left: 0;
+}
+
+.arguments .caption,
+.fields .caption {
+	display: none;
+}
+
+/* need extra .subs in the selector to make it override the rules for .subs and .subs table */
+
+.subs.arguments {
+	margin: 0;
+}
+
+.subs.arguments table {
+	border-spacing: 0;
+	margin-top: 0;
+	margin-bottom: 0;
+}
+
+.subs.arguments td.src {
+	white-space: nowrap;
+}
+
+.subs.arguments + p {
+	margin-top: 0;
+}
+
+.subs.associated-types,
+.subs.methods {
+	margin-left: 20px;
+}
+
+.subs.associated-types .caption,
+.subs.methods .caption {
+	margin-top: 0.5em;
+	margin-left: -10px;
+}
+
+.subs.associated-types .src + .src,
+.subs.methods .src + .src {
+	margin-top: 8px;
+}
+
+p.arg {
+	margin-bottom: 0;
+}
+p.arg span {
+  background-color: #f0f0f0;
+  font-family: monospace;
+  white-space: nowrap;
+	float: none;
+}
+
+
+img.coll {
+	width : 0.75em; height: 0.75em; margin-bottom: 0; margin-right: 0.5em
+}
+
+
+td.arg {
+  padding: 3px;
+  background-color: #f0f0f0;
+  font-family: monospace;
+  margin-bottom: 0;
+}
+
+td.rdoc p {
+	margin-bottom: 0;
+}
+
+
+.doc table {
+  border-collapse: collapse;
+  border-spacing: 0px;
+}
+
+.doc th,
+.doc td {
+  padding: 5px;
+  border: 1px solid #ddd;
+}
+
+.doc th {
+  background-color: #f0f0f0;
+}
+
+#footer {
+  background-color: #000099;
+  color: #ffffff;
+  padding: 4px
+  }
+
+#footer p {
+	padding: 1px;
+	margin: 0;
+}
+
+#footer  a:link {
+  color: #ffffff;
+  text-decoration: underline
+  }
+#footer  a:visited {
+  color: #ffff00
+  }
+#footer  a:hover {
+  background-color: #6060ff
+  }
+
+
+#module-list ul {
+	list-style: none;
+	padding-bottom: 15px;
+	padding-left: 2px;
+	margin: 0;
+}
+
+#module-list ul ul {
+	padding-bottom: 0;
+	padding-left: 20px;
+}
+
+#module-list li .package {
+	float: right;
+}
+#mini #module-list .caption {
+	display: none;
+}
+
+#index .caption {
+}
+
+#alphabet ul {
+	list-style: none;
+	padding: 0;
+	margin: 0.5em 0 0;
+}
+
+#alphabet li {
+	display: inline;
+	margin: 0 0.2em;
+}
+
+#index .src {
+	background: none;
+	font-family: inherit;
+}
+
+#index td.alt {
+	padding-left: 2em;
+}
+
+#index td {
+	padding-top: 2px;
+	padding-bottom: 1px;
+	padding-right: 1em;
+}
+
+
+#mini h1 { font-size: 130%; }
+#mini h2 { font-size: 110%; }
+#mini h3 { font-size: 100%; }
+#mini h1, #mini h2, #mini h3 {
+  margin-top: 0.5em;
+  margin-bottom: 0.25em;
+  padding: 0 0;
+}
+
+#mini h1 { border-bottom: 1px solid #ccc; }
+
+#mini #module-header {
+	margin: 0;
+	padding: 0;
+}
+#mini #module-header .caption {
+  font-size: 130%;
+  background: #0077dd;
+  padding: 0.25em;
+  height: inherit;
+  margin: 0;
+}
+
+#mini #interface .top {
+	margin: 0;
+	padding: 0;
+}
+#mini #interface .src {
+	margin: 0;
+	padding: 0;
+	font-family: inherit;
+	background: inherit;
+}
+
+.warning {
+  color: red;
+}
diff --git a/utils/haddock/haddock-api/resources/html/Linuwial.std-theme/linuwial.css b/utils/haddock/haddock-api/resources/html/Linuwial.std-theme/linuwial.css
new file mode 100644
index 0000000000000000000000000000000000000000..4164b849fb85c513912c566e9408ce1ac1d595d8
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/Linuwial.std-theme/linuwial.css
@@ -0,0 +1,881 @@
+/* @group Fundamentals */
+
+* { margin: 0; padding: 0 }
+
+/* Is this portable? */
+html {
+  background-color: white;
+  width: 100%;
+  height: 100%;
+}
+
+body {
+  background: #fefefe;
+  color: #111;
+  text-align: left;
+  min-height: 100vh;
+  position: relative;
+  -webkit-text-size-adjust: 100%;
+  -webkit-font-feature-settings: "kern" 1, "liga" 0;
+  -moz-font-feature-settings: "kern" 1, "liga" 0;
+  -o-font-feature-settings: "kern" 1, "liga" 0;
+  font-feature-settings: "kern" 1, "liga" 0;
+  letter-spacing: 0.0015rem;
+}
+
+#content a {
+  overflow-wrap: break-word;
+}
+
+p {
+  margin: 0.8em 0;
+}
+
+ul, ol {
+  margin: 0.8em 0 0.8em 2em;
+}
+
+dl {
+  margin: 0.8em 0;
+}
+
+dt {
+  font-weight: bold;
+}
+dd {
+  margin-left: 2em;
+}
+
+a { text-decoration: none; }
+a[href]:link { color: #9E358F; }
+a[href]:visited {color: #6F5F9C; }
+a[href]:hover { text-decoration:underline; }
+
+a[href].def:link, a[href].def:visited { color: rgba(69, 59, 97, 0.8); }
+a[href].def:hover { color: rgb(78, 98, 114); }
+
+/* @end */
+
+/* @group Show and hide with JS */
+
+body.js-enabled .hide-when-js-enabled {
+  display: none;
+}
+
+/* @end */
+
+
+/* @group responsive */
+
+#package-header .caption {
+  margin: 0px 1em 0 2em;
+}
+
+@media only screen and (min-width: 1280px) {
+  #content {
+    width: 63vw;
+    max-width: 1450px;
+  }
+
+  #table-of-contents {
+    position: fixed;
+    max-width: 10vw;
+    top: 10.2em;
+    left: 2em;
+    bottom: 1em;
+    overflow-y: auto;
+  }
+
+  #synopsis {
+    display: block;
+    position: fixed;
+    float: left;
+    top: 5em;
+    bottom: 1em;
+    right: 0;
+    max-width: 65vw;
+    overflow-y: auto;
+    /* Ensure that synopsis covers everything (including MathJAX markup) */
+    z-index: 1;
+  }
+
+  #synopsis .show {
+    border: 1px solid #5E5184;
+    padding: 0.7em;
+    max-height: 65vh;
+  }
+
+}
+
+@media only screen and (max-width: 1279px) {
+  #content {
+    width: 80vw;
+  }
+
+  #synopsis {
+    display: block;
+    padding: 0;
+    position: relative;
+    margin: 0;
+    width: 100%;
+  }
+}
+
+@media only screen and (max-width: 999px) {
+  #content {
+    width: 93vw;
+  }
+}
+
+
+/* menu for wider screens
+
+  Display the package name at the left and the menu links at the right,
+  inline with each other:
+  The package name                                   Source . Contents . Index
+*/
+@media only screen and (min-width: 1000px) {
+  #package-header {
+      text-align: left;
+      white-space: nowrap;
+      height: 40px;
+      padding: 4px 1.5em 0px 1.5em;
+      overflow: visible;
+
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+  }
+
+  #package-header .caption {
+    display: inline-block;
+    margin: 0;
+  }
+
+  #package-header ul.links {
+    margin: 0;
+    display: inline-table;
+  }
+
+  #package-header .caption + ul.links {
+    margin-left: 1em;
+  }
+}
+
+/* menu for smaller screens
+
+Display the package name on top of the menu links and center both elements:
+                  The package name
+              Source . Contents . Index
+*/
+@media only screen and (max-width: 999px) {
+  #package-header {
+    text-align: center;
+    padding: 6px 0 4px 0;
+    overflow: hidden;
+  }
+
+  #package-header ul.links {
+    display: block;
+    text-align: center;
+    margin: 0;
+
+    /* Hide scrollbar but allow scrolling menu links horizontally */
+    white-space: nowrap;
+    overflow-x: auto;
+    overflow-y: hidden;
+    margin-bottom: -17px;
+    height: 50px;
+  }
+
+  #package-header .caption {
+    display: block;
+    margin: 4px 0;
+    text-align: center;
+  }
+
+  #package-header ul.links::-webkit-scrollbar {
+    display: none;
+  }
+
+  #package-header ul.links li:first-of-type {
+    padding-left: 1em;
+  }
+
+  #package-header ul.links li:last-of-type {
+    /*
+    The last link of the menu should offer the same distance to the right
+    as the #package-header enforces at the left.
+    */
+    padding-right: 1em;
+  }
+
+  #package-header .caption + ul.links {
+    padding-top: 9px;
+  }
+
+  #module-header table.info {
+    float: none;
+    top: 0;
+    margin: 0 auto;
+    overflow: hidden;
+    max-width: 80vw;
+  }
+}
+
+/* @end */
+
+
+/* @group Fonts & Sizes */
+
+/* Basic technique & IE workarounds from YUI 3
+   For reasons, see:
+      http://yui.yahooapis.com/3.1.1/build/cssfonts/fonts.css
+ */
+
+ body, button {
+   font: 400 14px/1.4 'PT Sans',
+     /* Fallback Font Stack */
+     -apple-system,
+	  BlinkMacSystemFont,
+     'Segoe UI',
+	  Roboto,
+	  Oxygen-Sans,
+	  Cantarell,
+	  'Helvetica Neue',
+     sans-serif;
+   *font-size: medium; /* for IE */
+   *font:x-small; /* for IE in quirks mode */
+ }
+
+h1 { font-size: 146.5%; /* 19pt */ }
+h2 { font-size: 131%;   /* 17pt */ }
+h3 { font-size: 116%;   /* 15pt */ }
+h4 { font-size: 100%;   /* 13pt */ }
+h5 { font-size: 100%;   /* 13pt */ }
+
+table {
+	font-size:inherit;
+	font:100%;
+}
+
+pre, code, kbd, samp, tt, .src {
+	font-family:monospace;
+}
+
+.links, .link {
+  font-size: 85%; /* 11pt */
+}
+
+#module-header .caption {
+  font-size: 182%; /* 24pt */
+}
+
+#module-header .caption sup {
+  font-size: 80%;
+  font-weight: normal;
+}
+
+#package-header #page-menu a:link, #package-header #page-menu a:visited { color: white; }
+
+
+.info {
+  font-size: 90%;
+}
+
+
+/* @end */
+
+/* @group Common */
+
+.caption, h1, h2, h3, h4, h5, h6, summary {
+  font-weight: bold;
+  color: #5E5184;
+  margin: 1.5em 0 1em 0;
+}
+
+
+* + h1, * + h2, * + h3, * + h4, * + h5, * + h6 {
+  margin-top: 2em;
+}
+
+h1 + h2, h2 + h3, h3 + h4, h4 + h5, h5 + h6 {
+  margin-top: inherit;
+}
+
+ul li + li {
+	margin-top: 0.2rem;
+}
+
+ul + p {
+  margin-top: 0.93em;
+}
+
+p + ul {
+  margin-top: 0.5em;
+}
+
+p {
+  margin-top: 0.7rem;
+}
+
+ul, ol {
+  margin: 0.8em 0 0.8em 2em;
+}
+
+ul.links {
+  list-style: none;
+  text-align: left;
+  font-size: 0.95em;
+}
+
+#package-header ul.links, #package-header ul.links button {
+  font-size: 1rem;
+}
+
+ul.links li {
+  display: inline;
+  white-space: nowrap;
+  padding: 0;
+}
+
+ul.links > li + li:before {
+  content: '\00B7';
+}
+
+ul.links li a {
+  padding: 0.2em 0.5em;
+}
+
+.hide { display: none; }
+.show { display: inherit; }
+.clear { clear: both; }
+
+.collapser:before, .expander:before, .noexpander:before {
+  font-size: 1.2em;
+  color: #9C5791;
+  display: inline-block;
+  padding-right: 7px;
+}
+
+.collapser:before {
+  content: 'â–¿';
+}
+.expander:before {
+  content: 'â–¹';
+}
+.noexpander:before {
+  content: 'â–¿';
+  visibility: hidden;
+}
+
+.collapser, .expander {
+  cursor: pointer;
+}
+
+.instance.collapser, .instance.expander {
+  margin-left: 0px;
+  background-position: left center;
+  min-width: 9px;
+  min-height: 9px;
+}
+
+summary {
+  cursor: pointer;
+  outline: none;
+}
+
+pre {
+  padding: 0.5rem 1rem;
+  margin: 1em 0 0 0;
+  background-color: #f7f7f7;
+  overflow: auto;
+  border: 1px solid #ddd;
+  border-radius: 0.3em;
+}
+
+pre + p {
+  margin-top: 1em;
+}
+
+pre + pre {
+  margin-top: 0.5em;
+}
+
+blockquote {
+  border-left: 3px solid #c7a5d3;
+  background-color: #eee4f1;
+  margin: 0.5em;
+  padding: 0.0005em 0.3em 0.5em 0.5em;
+}
+
+.src {
+  background: #f2f2f2;
+  padding: 0.2em 0.5em;
+}
+
+.keyword { font-weight: normal; }
+.def { font-weight: bold; }
+
+@media print {
+  #footer { display: none; }
+}
+
+/* @end */
+
+/* @group Page Structure */
+
+#content {
+  margin: 3em auto 6em auto;
+  padding: 0;
+}
+
+#package-header {
+  background: #5E5184;
+  border-bottom: 5px solid rgba(69, 59, 97, 0.5);
+  color: #ddd;
+  position: relative;
+  font-size: 1.2em;
+  text-align: left;
+  margin: 0 auto;
+}
+
+#package-header .caption {
+  color: white;
+  font-style: normal;
+  font-size: 1rem;
+  font-weight: bold;
+}
+
+#module-header .caption {
+  font-weight: bold;
+  border-bottom: 1px solid #ddd;
+}
+
+table.info {
+  float: right;
+  padding: 0.5em 1em;
+  border: 1px solid #ddd;
+  color: rgb(78,98,114);
+  background-color: #fff;
+  max-width: 60%;
+  border-spacing: 0;
+  position: relative;
+  top: -0.78em;
+  margin: 0 0 0 2em;
+}
+
+.info th {
+  padding: 0 1em 0 0;
+  text-align: right;
+}
+
+#style-menu li {
+	display: block;
+	border-style: none;
+	list-style-type: none;
+}
+
+#footer {
+  background: #ededed;
+  border-top: 1px solid #aaa;
+  padding: 0.5em 0;
+  color: #222;
+  text-align: center;
+  width: 100%;
+  height: 3em;
+  margin-top: 3em;
+  position: relative;
+  clear: both;
+}
+
+/* @end */
+
+/* @group Front Matter */
+
+#synopsis .caption,
+#contents-list .caption {
+  font-size: 1rem;
+}
+
+#synopsis, #table-of-contents {
+  font-size: 16px;
+}
+
+#contents-list {
+  background: #f4f4f4;
+  padding: 1em;
+  margin: 0;
+}
+
+#contents-list .caption {
+  text-align: left;
+  margin: 0;
+}
+
+#contents-list ul {
+  list-style: none;
+  margin: 0;
+  margin-top: 10px;
+  font-size: 14px;
+}
+
+#contents-list ul ul {
+  margin-left: 1.5em;
+}
+
+#description .caption {
+  display: none;
+}
+
+#synopsis summary {
+  display: block;
+  float: right;
+  width: 29px;
+  color: rgba(255,255,255,0);
+  height: 110px;
+  margin: 0;
+  font-size: 1px;
+  padding: 0;
+  background: url(synopsis.png) no-repeat 0px -8px;
+}
+
+#synopsis details[open] > summary {
+  background: url(synopsis.png) no-repeat -75px -8px;
+}
+
+#synopsis details:not([open]) > ul {
+  visibility: hidden;
+}
+
+#synopsis ul {
+  height: 100%;
+  overflow: auto;
+  padding: 0.5em;
+  margin: 0;
+}
+
+#synopsis ul ul {
+  overflow: hidden;
+}
+
+#synopsis ul,
+#synopsis ul li.src {
+  background-color: rgb(250,247,224);
+  white-space: nowrap;
+  list-style: none;
+  margin-left: 0;
+}
+
+#interface td.src {
+  white-space: nowrap;
+}
+
+/* @end */
+
+/* @group Main Content */
+
+#interface div.top + div.top {
+  margin-top: 1.5em;
+}
+
+#interface p + div.top,
+#interface h1 + div.top,
+#interface h2 + div.top,
+#interface h3 + div.top,
+#interface h4 + div.top,
+#interface h5 + div.top {
+	margin-top: 1em;
+}
+#interface .src .selflink,
+#interface .src .link {
+  float: right;
+  color: #888;
+  padding: 0 7px;
+  -moz-user-select: none;
+  font-weight: bold;
+  line-height: 30px;
+}
+#interface .src .selflink {
+  margin: 0 -0.5em 0 0.5em;
+}
+
+#interface span.fixity {
+  color: #919191;
+  border-left: 1px solid #919191;
+  padding: 0.2em 0.5em 0.2em 0.5em;
+  margin: 0 -1em 0 1em;
+}
+
+#interface span.rightedge {
+  border-left: 1px solid #919191;
+  padding: 0.2em 0 0.2em 0;
+  margin: 0 0 0 1em;
+}
+
+#interface table { border-spacing: 2px; }
+#interface td {
+  vertical-align: top;
+  padding-left: 0.5em;
+}
+
+#interface td.doc p {
+  margin: 0;
+}
+#interface td.doc p + p {
+  margin-top: 0.8em;
+}
+
+.doc table {
+  border-collapse: collapse;
+  border-spacing: 0px;
+}
+
+.doc th,
+.doc td {
+  padding: 5px;
+  border: 1px solid #ddd;
+}
+
+.doc th {
+  background-color: #f0f0f0;
+}
+
+.clearfix:after {
+  clear: both;
+  content: " ";
+  display: block;
+  height: 0;
+  visibility: hidden;
+}
+
+.subs, .top > .doc, .subs > .doc {
+  padding-left: 1em;
+  border-left: 1px solid gainsboro;
+  margin-bottom: 1em;
+}
+
+.top .subs {
+  margin-bottom: 0.6em;
+}
+
+.subs.fields ul {
+  list-style: none;
+  display: table;
+  margin: 0;
+}
+
+.subs.fields ul li {
+  display: table-row;
+}
+
+.subs ul li dfn {
+  display: table-cell;
+  font-style: normal;
+  font-weight: bold;
+  margin: 1px 0;
+  white-space: nowrap;
+}
+
+.subs ul li > .doc {
+  display: table-cell;
+  padding-left: 0.5em;
+  margin-bottom: 0.5em;
+}
+
+.subs ul li > .doc p {
+  margin: 0;
+}
+
+.subs .subs p.src {
+  border: none;
+  background-color: #f8f8f8;
+}
+
+.subs .subs .caption {
+  margin-top: 1em ;
+  margin-bottom: 0px;
+}
+
+.subs p.caption {
+    margin-top: 0;
+}
+
+.subs .subs .caption + .src {
+  margin: 0px;
+  margin-top: 8px;
+}
+
+.subs .subs .src + .src {
+  margin: 7px 0 0 0;
+}
+
+/* Render short-style data instances */
+.inst ul {
+  height: 100%;
+  padding: 0.5em;
+  margin: 0;
+}
+
+.inst, .inst li {
+  list-style: none;
+  margin-left: 1em;
+}
+
+/* Workaround for bug in Firefox (issue #384) */
+.inst-left {
+  float: left;
+}
+
+.top p.src {
+  border-bottom: 3px solid #e5e5e5;
+  line-height: 2rem;
+  margin-bottom: 1em;
+}
+
+.warning {
+  color: red;
+}
+
+.arguments {
+  margin-top: -0.4em;
+}
+.arguments .caption {
+  display: none;
+}
+
+.fields { padding-left: 1em; }
+
+.fields .caption { display: none; }
+
+.fields p { margin: 0 0; }
+
+/* this seems bulky to me
+.methods, .constructors {
+  background: #f8f8f8;
+  border: 1px solid #eee;
+}
+*/
+
+/* @end */
+
+/* @group Auxillary Pages */
+
+
+.extension-list {
+    list-style-type: none;
+    margin-left: 0;
+}
+
+#mini {
+  margin: 0 auto;
+  padding: 0 1em 1em;
+}
+
+#mini > * {
+  font-size: 93%; /* 12pt */
+}
+
+#mini #module-list .caption,
+#mini #module-header .caption {
+  font-size: 125%; /* 15pt */
+}
+
+#mini #interface h1,
+#mini #interface h2,
+#mini #interface h3,
+#mini #interface h4 {
+  font-size: 109%; /* 13pt */
+  margin: 1em 0 0;
+}
+
+#mini #interface .top,
+#mini #interface .src {
+  margin: 0;
+}
+
+#mini #module-list ul {
+  list-style: none;
+  margin: 0;
+}
+
+#alphabet ul {
+	list-style: none;
+	padding: 0;
+	margin: 0.5em 0 0;
+	text-align: center;
+}
+
+#alphabet li {
+	display: inline;
+	margin: 0 0.25em;
+}
+
+#alphabet a {
+	font-weight: bold;
+}
+
+#index .caption,
+#module-list .caption { font-size: 131%; /* 17pt */ }
+
+#index table {
+  margin-left: 2em;
+}
+
+#index .src {
+  font-weight: bold;
+}
+#index .alt {
+  font-size: 77%; /* 10pt */
+  font-style: italic;
+  padding-left: 2em;
+}
+
+#index td + td {
+  padding-left: 1em;
+}
+
+#module-list ul {
+  list-style: none;
+  margin: 0 0 0 2em;
+}
+
+#module-list li {
+  clear: right;
+}
+
+#module-list span.collapser,
+#module-list span.expander {
+  background-position: 0 0.3em;
+}
+
+#module-list .package {
+  float: right;
+}
+
+:target {
+  background: -webkit-linear-gradient(top, transparent 0%, transparent 65%, #fbf36d 60%, #fbf36d 100%);
+  background: -moz-linear-gradient(top, transparent 0%, transparent 65%, #fbf36d 60%, #fbf36d 100%);
+  background: -o-linear-gradient(top, transparent 0%, transparent 65%, #fbf36d 60%, #fbf36d 100%);
+  background: -ms-linear-gradient(top, transparent 0%, transparent 65%, #fbf36d 60%, #fbf36d 100%);
+  background: linear-gradient(to bottom, transparent 0%, transparent 65%, #fbf36d 60%, #fbf36d 100%);
+}
+
+:target:hover {
+  background: -webkit-linear-gradient(top, transparent 0%, transparent 0%, #fbf36d 0%, #fbf36d 100%);
+  background: -moz-linear-gradient(top, transparent 0%, transparent 0%, #fbf36d 0%, #fbf36d 100%);
+  background: -o-linear-gradient(top, transparent 0%, transparent 0%, #fbf36d 0%, #fbf36d 100%);
+  background: -ms-linear-gradient(top, transparent 0%, transparent 0%, #fbf36d 0%, #fbf36d 100%);
+  background: linear-gradient(to bottom, transparent 0%, transparent 0%, #fbf36d 0%, #fbf36d 100%);
+}
+
+/* @end */
+
+/* @group Dropdown menus */
+
+#preferences-menu, #style-menu {
+  width: 25em;
+  overflow-y: auto;
+}
+
+/* @end */
diff --git a/utils/haddock/haddock-api/resources/html/Linuwial.std-theme/synopsis.png b/utils/haddock/haddock-api/resources/html/Linuwial.std-theme/synopsis.png
new file mode 100644
index 0000000000000000000000000000000000000000..85fb86ec84907bcc86531dc82871948ff4d471fa
Binary files /dev/null and b/utils/haddock/haddock-api/resources/html/Linuwial.std-theme/synopsis.png differ
diff --git a/utils/haddock/haddock-api/resources/html/Ocean.theme/hslogo-16.png b/utils/haddock/haddock-api/resources/html/Ocean.theme/hslogo-16.png
new file mode 100644
index 0000000000000000000000000000000000000000..0ff8579fbd897417b0d6dad6e920f8882138a7c0
Binary files /dev/null and b/utils/haddock/haddock-api/resources/html/Ocean.theme/hslogo-16.png differ
diff --git a/utils/haddock/haddock-api/resources/html/Ocean.theme/minus.gif b/utils/haddock/haddock-api/resources/html/Ocean.theme/minus.gif
new file mode 100644
index 0000000000000000000000000000000000000000..1deac2fe1a42e35b994f1b855488f392c50f6a89
Binary files /dev/null and b/utils/haddock/haddock-api/resources/html/Ocean.theme/minus.gif differ
diff --git a/utils/haddock/haddock-api/resources/html/Ocean.theme/ocean.css b/utils/haddock/haddock-api/resources/html/Ocean.theme/ocean.css
new file mode 100644
index 0000000000000000000000000000000000000000..32c689275b4b39c61ccbd708bb69a409512a83d0
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/Ocean.theme/ocean.css
@@ -0,0 +1,647 @@
+/* @group Fundamentals */
+
+* { margin: 0; padding: 0 }
+
+/* Is this portable? */
+html {
+  background-color: white;
+  width: 100%;
+  height: 100%;
+}
+
+body {
+  background: white;
+  color: black;
+  text-align: left;
+  min-height: 100%;
+  position: relative;
+}
+
+p {
+  margin: 0.8em 0;
+}
+
+ul, ol {
+  margin: 0.8em 0 0.8em 2em;
+}
+
+dl {
+  margin: 0.8em 0;
+}
+
+dt {
+  font-weight: bold;
+}
+dd {
+  margin-left: 2em;
+}
+
+a { text-decoration: none; }
+a[href]:link { color: rgb(196,69,29); }
+a[href]:visited { color: rgb(171,105,84); }
+a[href]:hover { text-decoration:underline; }
+
+a[href].def:link, a[href].def:visited { color: black; }
+a[href].def:hover { color: rgb(78, 98, 114); }
+
+/* @end */
+
+/* @group Show and hide with JS */
+
+body.js-enabled .hide-when-js-enabled {
+  display: none;
+}
+
+/* @end */
+
+/* @group Fonts & Sizes */
+
+/* Basic technique & IE workarounds from YUI 3
+   For reasons, see:
+      http://yui.yahooapis.com/3.1.1/build/cssfonts/fonts.css
+ */
+
+body {
+	font:13px/1.4 sans-serif;
+	*font-size:small; /* for IE */
+	*font:x-small; /* for IE in quirks mode */
+}
+
+h1 { font-size: 146.5%; /* 19pt */ }
+h2 { font-size: 131%;   /* 17pt */ }
+h3 { font-size: 116%;   /* 15pt */ }
+h4 { font-size: 100%;   /* 13pt */ }
+h5 { font-size: 100%;   /* 13pt */ }
+
+select, input, button, textarea {
+	font:99% sans-serif;
+}
+
+table {
+	font-size:inherit;
+	font:100%;
+}
+
+pre, code, kbd, samp, tt, .src {
+	font-family:monospace;
+	*font-size:108%;
+	line-height: 124%;
+}
+
+.links, .link {
+  font-size: 85%; /* 11pt */
+}
+
+#module-header .caption {
+  font-size: 182%; /* 24pt */
+}
+
+#module-header .caption sup {
+  font-size: 70%;
+  font-weight: normal;
+}
+
+.info  {
+  font-size: 85%; /* 11pt */
+}
+
+#table-of-contents, #synopsis  {
+  /* font-size: 85%; /* 11pt */
+}
+
+
+/* @end */
+
+/* @group Common */
+
+.caption, h1, h2, h3, h4, h5, h6, summary {
+  font-weight: bold;
+  color: rgb(78,98,114);
+  margin: 0.8em 0 0.4em;
+}
+
+* + h1, * + h2, * + h3, * + h4, * + h5, * + h6 {
+  margin-top: 2em;
+}
+
+h1 + h2, h2 + h3, h3 + h4, h4 + h5, h5 + h6 {
+  margin-top: inherit;
+}
+
+ul.links {
+  list-style: none;
+  text-align: left;
+  float: right;
+  display: inline-table;
+  margin: 0 0 0 1em;
+}
+
+ul.links li {
+  display: inline;
+  border-left: 1px solid #d5d5d5;
+  white-space: nowrap;
+  padding: 0;
+}
+
+ul.links li a {
+  padding: 0.2em 0.5em;
+}
+
+.hide { display: none; }
+.show { display: inherit; }
+.clear { clear: both; }
+
+.collapser {
+  background-image: url(minus.gif);
+  background-repeat: no-repeat;
+}
+.expander {
+  background-image: url(plus.gif);
+  background-repeat: no-repeat;
+}
+.collapser, .expander {
+  padding-left: 14px;
+  margin-left: -14px;
+  cursor: pointer;
+}
+p.caption.collapser,
+p.caption.expander {
+  background-position: 0 0.4em;
+}
+
+.instance.collapser, .instance.expander {
+  margin-left: 0px;
+  background-position: left center;
+  min-width: 9px;
+  min-height: 9px;
+}
+
+summary {
+  cursor: pointer;
+  outline: none;
+  list-style-image: url(plus.gif);
+  list-style-position: outside;
+}
+
+details[open] > summary {
+  list-style-image: url(minus.gif);
+}
+
+pre {
+  padding: 0.25em;
+  margin: 0.8em 0;
+  background: rgb(229,237,244);
+  overflow: auto;
+  border-bottom: 0.25em solid white;
+  /* white border adds some space below the box to compensate
+     for visual extra space that paragraphs have between baseline
+     and the bounding box */
+}
+
+.src {
+  background: #f0f0f0;
+  padding: 0.2em 0.5em;
+}
+
+.keyword { font-weight: normal; }
+.def { font-weight: bold; }
+
+@media print {
+  #footer { display: none; }
+}
+
+/* @end */
+
+/* @group Page Structure */
+
+#content {
+  margin: 0 auto;
+  padding: 0 2em 6em;
+}
+
+#package-header {
+  background: rgb(41,56,69);
+  border-top: 5px solid rgb(78,98,114);
+  color: #ddd;
+  padding: 0.2em;
+  position: relative;
+  text-align: left;
+}
+
+#package-header .caption {
+  background: url(hslogo-16.png) no-repeat 0em;
+  color: white;
+  margin: 0 2em;
+  font-weight: normal;
+  font-style: normal;
+  padding-left: 2em;
+}
+
+#package-header a:link, #package-header a:visited { color: white; }
+#package-header a:hover { background: rgb(78,98,114); }
+
+#module-header .caption {
+  color: rgb(78,98,114);
+  font-weight: bold;
+  border-bottom: 1px solid #ddd;
+}
+
+table.info {
+  float: right;
+  padding: 0.5em 1em;
+  border: 1px solid #ddd;
+  color: rgb(78,98,114);
+  background-color: #fff;
+  max-width: 40%;
+  border-spacing: 0;
+  position: relative;
+  top: -0.5em;
+  margin: 0 0 0 2em;
+}
+
+.info th {
+	padding: 0 1em 0 0;
+}
+
+div#style-menu-holder {
+  position: relative;
+  z-index: 2;
+  display: inline;
+}
+
+#style-menu {
+  position: absolute;
+  z-index: 1;
+  overflow: visible;
+  background: #374c5e;
+  margin: 0;
+  text-align: center;
+  right: 0;
+  padding: 0;
+  top: 1.25em;
+}
+
+#style-menu li {
+	display: list-item;
+	border-style: none;
+	margin: 0;
+	padding: 0;
+	color: #000;
+	list-style-type: none;
+}
+
+#style-menu li + li {
+	border-top: 1px solid #919191;
+}
+
+#style-menu a {
+  width: 6em;
+  padding: 3px;
+  display: block;
+}
+
+#footer {
+  background: #ddd;
+  border-top: 1px solid #aaa;
+  padding: 0.5em 0;
+  color: #666;
+  text-align: center;
+  position: absolute;
+  bottom: 0;
+  width: 100%;
+  height: 3em;
+}
+
+/* @end */
+
+/* @group Front Matter */
+
+#table-of-contents {
+  float: right;
+  clear: right;
+  background: #faf9dc;
+  border: 1px solid #d8d7ad;
+  padding: 0.5em 1em;
+  max-width: 20em;
+  margin: 0.5em 0 1em 1em;
+}
+
+#table-of-contents .caption {
+  text-align: center;
+  margin: 0;
+}
+
+#table-of-contents ul {
+  list-style: none;
+  margin: 0;
+}
+
+#table-of-contents ul ul {
+  margin-left: 2em;
+}
+
+#description .caption {
+  display: none;
+}
+
+#synopsis {
+  display: block;
+  position: fixed;
+  right: 0;
+  height: 80%;
+  top: 10%;
+  padding: 0;
+  max-width: 75%;
+  /* Ensure that synopsis covers everything (including MathJAX markup) */
+  z-index: 1;
+}
+
+#synopsis summary {
+  display: block;
+  float: left;
+  width: 29px;
+  color: rgba(255,255,255,0);
+  height: 110px;
+  margin: 0;
+  font-size: 1px;
+  padding: 0;
+  background: url(synopsis.png) no-repeat 0px -8px;
+}
+
+#synopsis details[open] > summary {
+  background: url(synopsis.png) no-repeat -64px -8px;
+}
+
+#synopsis ul {
+  height: 100%;
+  overflow: auto;
+  padding: 0.5em;
+  margin: 0;
+}
+
+#synopsis ul ul {
+  overflow: hidden;
+}
+
+#synopsis ul,
+#synopsis ul li.src {
+  background-color: #faf9dc;
+  white-space: nowrap;
+  list-style: none;
+  margin-left: 0;
+}
+
+/* @end */
+
+/* @group Main Content */
+
+#interface div.top { margin: 2em 0; }
+#interface h1 + div.top,
+#interface h2 + div.top,
+#interface h3 + div.top,
+#interface h4 + div.top,
+#interface h5 + div.top {
+	margin-top: 1em;
+}
+#interface .src .selflink,
+#interface .src .link {
+  float: right;
+  color: #919191;
+  background: #f0f0f0;
+  padding: 0 0.5em 0.2em;
+  margin: 0 -0.5em 0 0;
+  -moz-user-select: none;
+}
+#interface .src .selflink {
+  border-left: 1px solid #919191;
+  margin: 0 -0.5em 0 0.5em;
+}
+
+#interface span.fixity {
+  color: #919191;
+  border-left: 1px solid #919191;
+  padding: 0.2em 0.5em 0.2em 0.5em;
+  margin: 0 -1em 0 1em;
+}
+
+#interface span.rightedge {
+  border-left: 1px solid #919191;
+  padding: 0.2em 0 0.2em 0;
+  margin: 0 0 0 1em;
+}
+
+#interface table { border-spacing: 2px; }
+#interface td {
+  vertical-align: top;
+  padding-left: 0.5em;
+}
+
+#interface td.doc p {
+  margin: 0;
+}
+#interface td.doc p + p {
+  margin-top: 0.8em;
+}
+
+.doc table {
+  border-collapse: collapse;
+  border-spacing: 0px;
+}
+
+.doc th,
+.doc td {
+  padding: 5px;
+  border: 1px solid #ddd;
+}
+
+.doc th {
+  background-color: #f0f0f0;
+}
+
+.clearfix:after {
+  clear: both;
+  content: " ";
+  display: block;
+  height: 0;
+  visibility: hidden;
+}
+
+.subs.fields ul {
+  list-style: none;
+  display: table;
+  margin: 0;
+}
+
+.subs.fields ul li {
+  display: table-row;
+}
+
+.subs ul li dfn {
+  display: table-cell;
+  font-style: normal;
+  font-weight: bold;
+  margin: 1px 0;
+  white-space: nowrap;
+}
+
+.subs ul li > .doc {
+  display: table-cell;
+  padding-left: 0.5em;
+  margin-bottom: 0.5em;
+}
+
+.subs ul li > .doc p {
+  margin: 0;
+}
+
+/* Render short-style data instances */
+.inst ul {
+  height: 100%;
+  padding: 0.5em;
+  margin: 0;
+}
+
+.inst, .inst li {
+  list-style: none;
+  margin-left: 1em;
+}
+
+/* Workaround for bug in Firefox (issue #384) */
+.inst-left {
+  float: left;
+}
+
+.top p.src {
+  border-top: 1px solid #ccc;
+}
+
+.subs, .doc {
+  /* use this selector for one level of indent */
+  padding-left: 2em;
+}
+
+.warning {
+  color: red;
+}
+
+.arguments {
+  margin-top: -0.4em;
+}
+.arguments .caption {
+  display: none;
+}
+
+.fields { padding-left: 1em; }
+
+.fields .caption { display: none; }
+
+.fields p { margin: 0 0; }
+
+/* this seems bulky to me
+.methods, .constructors {
+  background: #f8f8f8;
+  border: 1px solid #eee;
+}
+*/
+
+/* @end */
+
+/* @group Auxillary Pages */
+
+
+.extension-list {
+    list-style-type: none;
+    margin-left: 0;
+}
+
+#mini {
+  margin: 0 auto;
+  padding: 0 1em 1em;
+}
+
+#mini > * {
+  font-size: 93%; /* 12pt */
+}
+
+#mini #module-list .caption,
+#mini #module-header .caption {
+  font-size: 125%; /* 15pt */
+}
+
+#mini #interface h1,
+#mini #interface h2,
+#mini #interface h3,
+#mini #interface h4 {
+  font-size: 109%; /* 13pt */
+  margin: 1em 0 0;
+}
+
+#mini #interface .top,
+#mini #interface .src {
+  margin: 0;
+}
+
+#mini #module-list ul {
+  list-style: none;
+  margin: 0;
+}
+
+#alphabet ul {
+	list-style: none;
+	padding: 0;
+	margin: 0.5em 0 0;
+	text-align: center;
+}
+
+#alphabet li {
+	display: inline;
+	margin: 0 0.25em;
+}
+
+#alphabet a {
+	font-weight: bold;
+}
+
+#index .caption,
+#module-list .caption { font-size: 131%; /* 17pt */ }
+
+#index table {
+  margin-left: 2em;
+}
+
+#index .src {
+  font-weight: bold;
+}
+#index .alt {
+  font-size: 77%; /* 10pt */
+  font-style: italic;
+  padding-left: 2em;
+}
+
+#index td + td {
+  padding-left: 1em;
+}
+
+#module-list ul {
+  list-style: none;
+  margin: 0 0 0 2em;
+}
+
+#module-list li {
+  clear: right;
+}
+
+#module-list span.collapser,
+#module-list span.expander {
+  background-position: 0 0.3em;
+}
+
+#module-list .package {
+  float: right;
+}
+
+:target {
+  background-color: #ffff00;
+}
+
+/* @end */
diff --git a/utils/haddock/haddock-api/resources/html/Ocean.theme/plus.gif b/utils/haddock/haddock-api/resources/html/Ocean.theme/plus.gif
new file mode 100644
index 0000000000000000000000000000000000000000..2d15c14173d23f664b955cd24f51c82f5f09d91d
Binary files /dev/null and b/utils/haddock/haddock-api/resources/html/Ocean.theme/plus.gif differ
diff --git a/utils/haddock/haddock-api/resources/html/Ocean.theme/synopsis.png b/utils/haddock/haddock-api/resources/html/Ocean.theme/synopsis.png
new file mode 100644
index 0000000000000000000000000000000000000000..85fb86ec84907bcc86531dc82871948ff4d471fa
Binary files /dev/null and b/utils/haddock/haddock-api/resources/html/Ocean.theme/synopsis.png differ
diff --git a/utils/haddock/haddock-api/resources/html/README.md b/utils/haddock/haddock-api/resources/html/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..d555989dd7b8481c61d8f6db9b51e0bf8f5a151c
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/README.md
@@ -0,0 +1,22 @@
+# Compiling
+
+* Install [node](https://nodejs.org/) and [npm](https://www.npmjs.com)
+* Run `npm install` and `npm install gulp-cli -g` in this directory.
+* Run `gulp` in this directory. This rebuilds the minified JS files.
+
+# Development and manual testing
+
+Generate Haddock docs for some Haskell project. Start an HTTP server in the Haddock docs directory.
+(The `file://` protocol doesn't work since it doesn't allow AJAX requests.)
+
+After each change to the TypeScript sources, compile and copy the generated files (JS and sourcemaps for better debugging) to the Haddock directory:
+
+```
+gulp && cp *.min.js path-to/generated-haddock-docs && cp *.js.map path-to/generated-haddock-docs
+```
+
+If you are editing the CSS, you'll also need to copy the edited CSS files. E.g. if you are editing the global/default quick-jump.css and the Linuwial theme's CSS, then
+
+```
+cp quick-jump.css Linuwial.std-theme/linuwial.css path-to/generated-haddock-docs
+```
diff --git a/utils/haddock/haddock-api/resources/html/gulpfile.js b/utils/haddock/haddock-api/resources/html/gulpfile.js
new file mode 100644
index 0000000000000000000000000000000000000000..c456615f5b328dc42214d3e993d9850ce6696127
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/gulpfile.js
@@ -0,0 +1,28 @@
+const gulp = require('gulp');
+const uglify = require('gulp-uglify');
+const browserify = require('browserify');
+const source = require('vinyl-source-stream');
+const buffer = require('vinyl-buffer');
+const tsify = require('tsify');
+const sourcemaps = require('gulp-sourcemaps');
+
+function buildJS(targetFileName, files) {
+  var b = browserify({ entries: files, debug: true });
+  return b
+    .plugin(tsify)
+    .bundle()
+    .pipe(source(targetFileName))
+    .pipe(buffer())
+    .pipe(sourcemaps.init({loadMaps: true}))
+    .pipe(uglify().on('error', function(e) { console.log(e); }))
+    .pipe(sourcemaps.write('.'))
+    .pipe(gulp.dest('.'));
+}
+
+gulp.task('build-js', function(done) {
+  buildJS('quick-jump.min.js', ['./js-src/quick-jump.tsx']);
+  buildJS('haddock-bundle.min.js', ['./js-src/init.ts']);
+  done();
+});
+
+gulp.task('default', gulp.series('build-js'));
diff --git a/utils/haddock/haddock-api/resources/html/haddock-bundle.min.js b/utils/haddock/haddock-api/resources/html/haddock-bundle.min.js
new file mode 100644
index 0000000000000000000000000000000000000000..23de16952b9c6bf4be1cbcd2306dbcde4805f555
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/haddock-bundle.min.js
@@ -0,0 +1,2 @@
+!function i(s,a,l){function c(t,e){if(!a[t]){if(!s[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(u)return u(t,!0);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}var r=a[t]={exports:{}};s[t][0].call(r.exports,function(e){return c(s[t][1][e]||e)},r,r.exports,i,s,a,l)}return a[t].exports}for(var u="function"==typeof require&&require,e=0;e<l.length;e++)c(l[e]);return c}({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.setCookie=function(e,t){document.cookie=e+"="+encodeURIComponent(t)+";path=/;"},n.clearCookie=function(e){document.cookie=e+"=;path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT;"},n.getCookie=function(e){for(var t=e+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){for(var r=n[o];" "==r.charAt(0);)r=r.substring(1,r.length);if(0==r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}return null}},{}],2:[function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var i,s,a=e("preact"),l=a.h,c=a.Component;(s=i||(i={}))[s.Closed=0]="Closed",s[s.Open=1]="Open";var u={defaultInstanceState:i.Open,rememberToggles:!0},d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.render=function(t){return l("li",null,l("a",{href:"#",onClick:function(e){e.preventDefault(),t.onClick()}},t.title))},t}(c);function h(e){var t=document.querySelector("#page-menu"),n=document.createElement("li");t.insertBefore(n,t.firstChild),a.render(l(d,{onClick:e,title:"Instances"}),t,n)}var p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.componentWillMount=function(){var t=this;document.addEventListener("mousedown",this.hide.bind(this)),document.addEventListener("keydown",function(e){t.state.isVisible&&"Escape"===e.key&&t.hide()})},t.prototype.hide=function(){this.setState({isVisible:!1})},t.prototype.show=function(){this.state.isVisible||this.setState({isVisible:!0})},t.prototype.toggleVisibility=function(){this.state.isVisible?this.hide():this.show()},t.prototype.componentDidMount=function(){this.props.showHideTrigger(this.toggleVisibility.bind(this))},t.prototype.render=function(e,t){return l("div",{id:"preferences",class:t.isVisible?"":"hidden"},l("div",{id:"preferences-menu",class:"dropdown-menu",onMouseDown:function(e){e.stopPropagation()}},l(b,null)))},t}(c);function f(){var e=JSON.stringify(u);try{localStorage.setItem("global",e)}catch(e){}}var v=!1;function g(){if(!v){v=!0;var e=localStorage.getItem("global");if(e)try{var t=JSON.parse(e);u.defaultInstanceState=t.defaultInstanceState,u.rememberToggles=t.rememberToggles}catch(e){if(!(e instanceof SyntaxError||e instanceof TypeError))throw e;localStorage.removeItem("global")}}}function m(t){return function(e){u.defaultInstanceState=t,A(),f(),E(),O()}}function y(e){var t=e.target.checked;u.rememberToggles=t,f(),E(),O()}function _(e){var t=document.getElementById("default-collapse-instances");null!==t&&(t.checked?m(i.Closed)(e):m(i.Open)(e))}function b(){return g(),l("div",null,l("div",null,l("button",{type:"button",onClick:j},"Expand All Instances"),l("button",{type:"button",onClick:P},"Collapse All Instances")),l("div",null,l("input",{type:"checkbox",id:"default-collapse-instances",name:"default-instance-state",checked:u.defaultInstanceState===i.Closed,onClick:_}),l("span",null,"Collapse All Instances By Default")),l("div",null,l("input",{type:"checkbox",id:"remember-toggles",name:"remember-toggles",checked:u.rememberToggles,onClick:y}),l("label",{for:"remember-toggles"},"Remember Manually Collapsed/Expanded Instances")))}var k={};function S(e){var t=k[e];if(null==t)throw new Error("could not find <details> element with id '"+e+"'");return t}function x(){return u.defaultInstanceState==i.Open}function w(e){for(var t=S(e.target.id),n=t.element.open,o=0,r=t.toggles;o<r.length;o++){var i=r[o];i.classList.contains("details-toggle-control")&&(i.classList.add(n?"collapser":"expander"),i.classList.remove(n?"expander":"collapser"))}}function C(e){var t=e.getAttribute("data-details-id");if(!t)throw new Error("element with class "+e+" has no 'data-details-id' attribute!");return t}function L(e){var t=S(C(e)).element;t.open=!t.open}var M="local-details-config:";function I(){return M+document.location.pathname}function E(){for(var e=[],t=0;t<localStorage.length;++t){var n=localStorage.key(t);null!==n&&n.startsWith(M)&&e.push(n)}e.forEach(function(e){localStorage.removeItem(e)})}function O(){if(u.rememberToggles){var e=Array.prototype.slice.call(document.getElementsByClassName("instances details-toggle details-toggle-control")),n=[];e.forEach(function(e){var t=C(e);document.getElementById(t).open!=x()&&n.push(t)});var t=JSON.stringify(n);try{localStorage.setItem(I(),t)}catch(e){}}}function A(){switch(u.defaultInstanceState){case i.Closed:N(!0);break;case i.Open:N(!1)}}function T(e){L(e.currentTarget),O()}function N(o){var e=document.getElementsByClassName("subs instances");[].forEach.call(e,function(e){var t=o?"collapser":"expander",n=e.getElementsByClassName("instances "+t)[0];n&&L(n)})}function P(){N(!0),O()}function j(){N(!1),O()}n.init=function(e){!function(){for(var e=0,t=Array.prototype.slice.call(document.getElementsByTagName("details"));e<t.length;e++){var n=t[e];"string"==typeof n.id&&0<n.id.length&&(k[n.id]={element:n,toggles:[]},n.addEventListener("toggle",w))}}(),Array.prototype.slice.call(document.getElementsByClassName("details-toggle")).forEach(function(e){var t=S(C(e));t.toggles.push(e),e.addEventListener("click",T),e.classList.contains("details-toggle-control")&&e.classList.add(t.element.open?"collapser":"expander")}),function(){if(g(),A(),u.rememberToggles){var e=localStorage.getItem(I());if(e)try{JSON.parse(e).forEach(function(e){S(e).element.open=!x()})}catch(e){if(!(e instanceof SyntaxError||e instanceof TypeError))throw e;localStorage.removeItem(I())}}}(),a.render(l(p,{showHideTrigger:e||h}),document.body)}},{preact:7}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o,r=e("./style-menu"),i=e("./details-helper"),s=e("./quick-jump");o=function(){document.body.classList.add("js-enabled"),r.init(),i.init();var e=document.getElementById("head"),t=".";null!==e&&(t=e.getAttribute("data-base-url")||"."),s.init(t)},"interactive"===document.readyState?o():document.addEventListener("readystatechange",function(){"interactive"===document.readyState&&o()})},{"./details-helper":2,"./quick-jump":4,"./style-menu":5}],4:[function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var i=e("fuse.js"),s=e("preact"),a=s.h,l=s.Component;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.render=function(t){return a("li",null,a("a",{href:"#",onClick:function(e){e.preventDefault(),t.onClick()}},t.title))},t}(l);function u(e,t){return t.length<=e?t:t.slice(0,e)}var d=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.linkIndex=0,e.focusPlease=!1,e.navigatedByKeyboard=!1,e}return r(e,t),e.prototype.componentWillMount=function(){var e,t,n,o,r=this;this.setState({searchString:"",isVisible:!1,expanded:{},activeLinkIndex:-1,moduleResults:[]}),e=this.props.baseUrl+"/doc-index.json",t=function(e){r.setState({fuse:new i(e,{threshold:.25,caseSensitive:!0,includeScore:!0,tokenize:!0,keys:[{name:"name",weight:.7},{name:"module",weight:.3}]}),moduleResults:[]})},n=function(e){console&&console.error("could not load 'doc-index.json' for searching",e),r.setState({failedLoading:!0})},(o=new XMLHttpRequest).onreadystatechange=function(){if(o.readyState===XMLHttpRequest.DONE)if(200===o.status){if(t)try{t(JSON.parse(o.responseText))}catch(e){n(o)}}else n&&n(o)},o.open("GET",e,!0),o.send(),document.addEventListener("mousedown",this.hide.bind(this)),document.addEventListener("keydown",function(e){r.state.isVisible&&("Escape"===e.key?r.hide():"ArrowUp"===e.key||"k"===e.key&&e.ctrlKey?(e.preventDefault(),r.navigateLinks(-1)):"ArrowDown"===e.key||"j"===e.key&&e.ctrlKey?(e.preventDefault(),r.navigateLinks(1)):"Enter"===e.key&&0<=r.state.activeLinkIndex&&r.followActiveLink()),"s"===e.key&&"input"!==e.target.tagName.toLowerCase()&&(e.preventDefault(),r.show())})},e.prototype.hide=function(){this.setState({isVisible:!1,searchString:""})},e.prototype.show=function(){this.state.isVisible||(this.focusPlease=!0,this.setState({isVisible:!0,activeLinkIndex:-1}))},e.prototype.toggleVisibility=function(){this.state.isVisible?this.hide():this.show()},e.prototype.navigateLinks=function(e){var t=Math.max(-1,Math.min(this.linkIndex-1,this.state.activeLinkIndex+e));this.navigatedByKeyboard=!0,this.setState({activeLinkIndex:t})},e.prototype.followActiveLink=function(){this.activeLinkAction&&this.activeLinkAction()},e.prototype.updateResults=function(){var e=this.input&&this.input.value||"",t=this.state.fuse.search(e),o={};t.forEach(function(e){var t=e.item.module;(o[t]||(o[t]=[])).push(e)});var r=[],n=function(e){var t=o[e],n=0;t.forEach(function(e){n+=1/e.score}),r.push({module:e,totalScore:1/n,items:t})};for(var i in o)n(i);r.sort(function(e,t){return e.totalScore-t.totalScore}),this.setState({searchString:e,isVisible:!0,moduleResults:r})},e.prototype.componentDidUpdate=function(){if(this.searchResults&&this.activeLink&&this.navigatedByKeyboard){var e=this.activeLink.getClientRects()[0],t=this.searchResults.getClientRects()[0].top;e.bottom>window.innerHeight?this.searchResults.scrollTop+=e.bottom-window.innerHeight+80:e.top<t&&(this.searchResults.scrollTop-=t-e.top+80)}this.focusPlease&&this.input&&this.input.focus(),this.navigatedByKeyboard=!1,this.focusPlease=!1},e.prototype.componentDidMount=function(){this.props.showHideTrigger(this.toggleVisibility.bind(this))},e.prototype.render=function(e,t){var r=this;if(t.failedLoading){var n="file:"==window.location.protocol;return a("div",{id:"search",class:t.isVisible?"":"hidden"},a("div",{id:"search-results"},a("p",{class:"error"},"Failed to load file 'doc-index.json' containing definitions in this package."),n?a("p",{class:"error"},"To use quick jump, load this page with HTTP (from a local static file web server) instead of using the ",a("code",null,"file://")," protocol. (For security reasons, it is not possible to fetch auxiliary files using JS in a HTML page opened with ",a("code",null,"file://"),".)"):[]))}this.linkIndex=0;var o=function(e){e.stopPropagation()},i=u(10,t.moduleResults).map(function(e){return r.renderResultsInModule(e)});return a("div",{id:"search",class:t.isVisible?"":"hidden"},a("div",{id:"search-form",onMouseDown:o},a("input",{placeholder:"Search in package by name",ref:function(e){r.input=e},onFocus:this.show.bind(this),onClick:this.show.bind(this),onInput:this.updateResults.bind(this)})),a("div",{id:"search-results",ref:function(e){r.searchResults=e},onMouseDown:o,onMouseOver:function(e){for(var t=e.target;t&&"function"==typeof t.getAttribute;){var n=t.getAttribute("data-link-index");if("string"==typeof n){var o=parseInt(n,10);r.setState({activeLinkIndex:o});break}t=t.parentNode}}},""===t.searchString?[a(f,null),a(p,null)]:0==i.length?a(v,{searchString:t.searchString}):a("ul",null,i)))},e.prototype.renderResultsInModule=function(e){var n=this,t=e.items,o=e.module,r=this.state.expanded[o]||t.length<=10,i=r?t:u(8,t);return a("li",{class:"search-module"},a("h4",null,o),a("ul",null,i.map(function(e){return t=e.item,a("li",{class:"search-result"},n.navigationLink(n.props.baseUrl+"/"+t.link,{},a(h,{html:t.display_html})));var t}),r?[]:a("li",{class:"more-results"},this.actionLink(function(){var e=Object.assign({},n.state.expanded);e[o]=!0,n.setState({expanded:e})},{},"show "+(t.length-i.length)+" more results from this module"))))},e.prototype.navigationLink=function(e,t){for(var n=this,o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];var i=Object.assign({href:e,onClick:this.hide.bind(this)},t);return this.menuLink.apply(this,[i,function(){window.location.href=e,n.hide()}].concat(o))},e.prototype.actionLink=function(t,e){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=Object.assign({href:"#",onClick:function(e){e.preventDefault(),t()}},e);return this.menuLink.apply(this,[r,t].concat(n))},e.prototype.menuLink=function(e,t){for(var n=this,o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];var i=this.linkIndex;i===this.state.activeLinkIndex&&(e.class=(e.class?e.class+" ":"")+"active-link",e.ref=function(e){e&&(n.activeLink=e)},this.activeLinkAction=t);var s=Object.assign({"data-link-index":i},e);return this.linkIndex+=1,a.apply(void 0,["a",s].concat(o))},e}(l),h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.shouldComponentUpdate=function(e){return this.props.html!==e.html},t.prototype.render=function(e){return a("div",{dangerouslySetInnerHTML:{__html:e.html}})},t}(l);function p(){return a("table",{class:"keyboard-shortcuts"},a("tr",null,a("th",null,"Key"),a("th",null,"Shortcut")),a("tr",null,a("td",null,a("span",{class:"key"},"s")),a("td",null,"Open this search box")),a("tr",null,a("td",null,a("span",{class:"key"},"esc")),a("td",null,"Close this search box")),a("tr",null,a("td",null,a("span",{class:"key"},"↓"),",",a("span",{class:"key"},"ctrl")," + ",a("span",{class:"key"},"j")),a("td",null,"Move down in search results")),a("tr",null,a("td",null,a("span",{class:"key"},"↑"),",",a("span",{class:"key"},"ctrl")," + ",a("span",{class:"key"},"k")),a("td",null,"Move up in search results")),a("tr",null,a("td",null,a("span",{class:"key"},"↵")),a("td",null,"Go to active search result")))}function f(){return a("p",null,"You can find any exported type, constructor, class, function or pattern defined in this package by (approximate) name.")}function v(e){var t=[a("p",null,"Your search for '",e.searchString,"' produced the following list of results: ",a("code",null,"[]"),"."),a("p",null,a("code",null,"Nothing")," matches your query for '",e.searchString,"'."),a("p",null,a("code",null,"Left \"no matches for '",e.searchString,"'\" :: Either String (NonEmpty SearchResult)"))];return t[(e.searchString||"a").charCodeAt(0)%t.length]}function g(e,t){var n,o=document.getElementById("quick-jump-button");o&&s.render(a(d,{baseUrl:e||".",showHideTrigger:t||(n=o,function(e){var t=document.querySelector("#page-menu");s.render(a(c,{onClick:e,title:"Quick Jump"}),t,n)})}),document.body)}n.init=g,window.quickNav={init:g}},{"fuse.js":6,preact:7}],5:[function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var i=e("./cookies"),s=e("preact"),a=s.h,l=s.Component;function c(){return Array.prototype.slice.call(document.getElementsByTagName("link")).filter(function(e){return-1!=e.rel.indexOf("style")&&e.title})}function u(e){for(var t=c(),n=null,o=0;o<t.length;o++){var r=t[o];r.disabled=!0,r.title==e&&(n=r)}n?(n.disabled=!1,i.setCookie("haddock-style",e)):(t[0].disabled=!1,i.clearCookie("haddock-style"))}var d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.render=function(t){return a("li",null,a("a",{href:"#",onClick:function(e){e.preventDefault(),t.onClick()}},t.title))},t}(l);var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.componentWillMount=function(){var t=this;document.addEventListener("mousedown",this.hide.bind(this)),document.addEventListener("keydown",function(e){t.state.isVisible&&"Escape"===e.key&&t.hide()})},t.prototype.hide=function(){this.setState({isVisible:!1})},t.prototype.show=function(){this.state.isVisible||this.setState({isVisible:!0})},t.prototype.toggleVisibility=function(){this.state.isVisible?this.hide():this.show()},t.prototype.componentDidMount=function(){this.props.showHideTrigger(this.toggleVisibility.bind(this))},t.prototype.render=function(e,t){var n=this;return a("div",{id:"style",class:t.isVisible?"":"hidden"},a("div",{id:"style-menu",class:"dropdown-menu",onMouseDown:function(e){e.stopPropagation()}},e.styles.map(function(t){return a("button",{type:"button",onClick:function(e){n.hide(),u(t)}},t)})))},t}(l);n.init=function(e){var t,n=c().map(function(e){return e.title});(t=i.getCookie("haddock-style"))&&u(t),s.render(a(h,{showHideTrigger:e||function(e){return function(e,t){if(1<e.length){var n=document.querySelector("#page-menu"),o=document.createElement("li");n.appendChild(o),s.render(a(d,{onClick:t,title:"Styles"}),n,o)}}(n,e)},styles:n}),document.body)}},{"./cookies":1,preact:7}],6:[function(e,t,n){var o,r;o=this,r=function(){return function(n){var o={};function r(e){if(o[e])return o[e].exports;var t=o[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,r),t.l=!0,t.exports}return r.m=n,r.c=o,r.i=function(e){return e},r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=8)}([function(e,t,n){"use strict";e.exports=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";var o=function(){function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}}();var u=n(5),d=n(7),_=n(4),r=function(){function y(e,t){var n=t.location,o=void 0===n?0:n,r=t.distance,i=void 0===r?100:r,s=t.threshold,a=void 0===s?.6:s,l=t.maxPatternLength,c=void 0===l?32:l,u=t.isCaseSensitive,d=void 0!==u&&u,h=t.tokenSeparator,p=void 0===h?/ +/g:h,f=t.findAllMatches,v=void 0!==f&&f,g=t.minMatchCharLength,m=void 0===g?1:g;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,y),this.options={location:o,distance:i,threshold:a,maxPatternLength:c,isCaseSensitive:d,tokenSeparator:p,findAllMatches:v,minMatchCharLength:m},this.pattern=this.options.isCaseSensitive?e:e.toLowerCase(),this.pattern.length<=c&&(this.patternAlphabet=_(this.pattern))}return o(y,[{key:"search",value:function(e){if(this.options.isCaseSensitive||(e=e.toLowerCase()),this.pattern===e)return{isMatch:!0,score:0,matchedIndices:[[0,e.length-1]]};var t=this.options,n=t.maxPatternLength,o=t.tokenSeparator;if(this.pattern.length>n)return u(e,this.pattern,o);var r=this.options,i=r.location,s=r.distance,a=r.threshold,l=r.findAllMatches,c=r.minMatchCharLength;return d(e,this.pattern,this.patternAlphabet,{location:i,distance:s,threshold:a,findAllMatches:l,minMatchCharLength:c})}}]),y}();e.exports=r},function(e,t,n){"use strict";var u=n(0);e.exports=function(e,t){return function e(t,n,o){if(n){var r=n.indexOf("."),i=n,s=null;-1!==r&&(i=n.slice(0,r),s=n.slice(r+1));var a=t[i];if(null!=a)if(s||"string"!=typeof a&&"number"!=typeof a)if(u(a))for(var l=0,c=a.length;l<c;l+=1)e(a[l],s,o);else s&&e(a,s,o);else o.push(a.toString())}else o.push(t);return o}(e,t,[])}},function(e,t,n){"use strict";e.exports=function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=[],o=-1,r=-1,i=0,s=e.length;i<s;i+=1){var a=e[i];a&&-1===o?o=i:a||-1===o||(t<=(r=i-1)-o+1&&n.push([o,r]),o=-1)}return e[i-1]&&t<=i-o&&n.push([o,i-1]),n}},function(e,t,n){"use strict";e.exports=function(e){for(var t={},n=e.length,o=0;o<n;o+=1)t[e.charAt(o)]=0;for(var r=0;r<n;r+=1)t[e.charAt(r)]|=1<<n-r-1;return t}},function(e,t,n){"use strict";var u=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:/ +/g,o=new RegExp(t.replace(u,"\\$&").replace(n,"|")),r=e.match(o),i=!!r,s=[];if(i)for(var a=0,l=r.length;a<l;a+=1){var c=r[a];s.push([e.indexOf(c),c.length-1])}return{score:i?.5:1,isMatch:i,matchedIndices:s}}},function(e,t,n){"use strict";e.exports=function(e,t){var n=t.errors,o=void 0===n?0:n,r=t.currentLocation,i=void 0===r?0:r,s=t.expectedLocation,a=void 0===s?0:s,l=t.distance,c=void 0===l?100:l,u=o/e.length,d=Math.abs(a-i);return c?u+d/c:d?1:u}},function(e,t,n){"use strict";var V=n(6),D=n(3);e.exports=function(e,t,n,o){for(var r=o.location,i=void 0===r?0:r,s=o.distance,a=void 0===s?100:s,l=o.threshold,c=void 0===l?.6:l,u=o.findAllMatches,d=void 0!==u&&u,h=o.minMatchCharLength,p=void 0===h?1:h,f=i,v=e.length,g=c,m=e.indexOf(t,f),y=t.length,_=[],b=0;b<v;b+=1)_[b]=0;if(-1!==m){var k=V(t,{errors:0,currentLocation:m,expectedLocation:f,distance:a});if(g=Math.min(k,g),-1!==(m=e.lastIndexOf(t,f+y))){var S=V(t,{errors:0,currentLocation:m,expectedLocation:f,distance:a});g=Math.min(S,g)}}m=-1;for(var x=[],w=1,C=y+v,L=1<<y-1,M=0;M<y;M+=1){for(var I=0,E=C;I<E;){V(t,{errors:M,currentLocation:f+E,expectedLocation:f,distance:a})<=g?I=E:C=E,E=Math.floor((C-I)/2+I)}C=E;var O=Math.max(1,f-E+1),A=d?v:Math.min(f+E,v)+y,T=Array(A+2);T[A+1]=(1<<M)-1;for(var N=A;O<=N;N-=1){var P=N-1,j=n[e.charAt(P)];if(j&&(_[P]=1),T[N]=(T[N+1]<<1|1)&j,0!==M&&(T[N]|=(x[N+1]|x[N])<<1|1|x[N+1]),T[N]&L&&(w=V(t,{errors:M,currentLocation:P,expectedLocation:f,distance:a}))<=g){if(g=w,(m=P)<=f)break;O=Math.max(1,2*f-m)}}if(g<V(t,{errors:M+1,currentLocation:f,expectedLocation:f,distance:a}))break;x=T}return{isMatch:0<=m,score:0===w?.001:w,matchedIndices:D(_,p)}}},function(e,t,n){"use strict";var o=function(){function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}}();var i=n(1),R=n(2),V=n(0),r=function(){function U(e,t){var n=t.location,o=void 0===n?0:n,r=t.distance,i=void 0===r?100:r,s=t.threshold,a=void 0===s?.6:s,l=t.maxPatternLength,c=void 0===l?32:l,u=t.caseSensitive,d=void 0!==u&&u,h=t.tokenSeparator,p=void 0===h?/ +/g:h,f=t.findAllMatches,v=void 0!==f&&f,g=t.minMatchCharLength,m=void 0===g?1:g,y=t.id,_=void 0===y?null:y,b=t.keys,k=void 0===b?[]:b,S=t.shouldSort,x=void 0===S||S,w=t.getFn,C=void 0===w?R:w,L=t.sortFn,M=void 0===L?function(e,t){return e.score-t.score}:L,I=t.tokenize,E=void 0!==I&&I,O=t.matchAllTokens,A=void 0!==O&&O,T=t.includeMatches,N=void 0!==T&&T,P=t.includeScore,j=void 0!==P&&P,V=t.verbose,D=void 0!==V&&V;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,U),this.options={location:o,distance:i,threshold:a,maxPatternLength:c,isCaseSensitive:d,tokenSeparator:p,findAllMatches:v,minMatchCharLength:m,id:_,keys:k,includeMatches:N,includeScore:j,shouldSort:x,getFn:C,sortFn:M,verbose:D,tokenize:E,matchAllTokens:A},this.setCollection(e)}return o(U,[{key:"setCollection",value:function(e){return this.list=e}},{key:"search",value:function(e){this._log('---------\nSearch pattern: "'+e+'"');var t=this._prepareSearchers(e),n=t.tokenSearchers,o=t.fullSearcher,r=this._search(n,o),i=r.weights,s=r.results;return this._computeScore(i,s),this.options.shouldSort&&this._sort(s),this._format(s)}},{key:"_prepareSearchers",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=[];if(this.options.tokenize)for(var n=e.split(this.options.tokenSeparator),o=0,r=n.length;o<r;o+=1)t.push(new i(n[o],this.options));return{tokenSearchers:t,fullSearcher:new i(e,this.options)}}},{key:"_search",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],n=this.list,o={},r=[];if("string"==typeof n[0]){for(var i=0,s=n.length;i<s;i+=1)this._analyze({key:"",value:n[i],record:i,index:i},{resultMap:o,results:r,tokenSearchers:e,fullSearcher:t});return{weights:null,results:r}}for(var a={},l=0,c=n.length;l<c;l+=1)for(var u=n[l],d=0,h=this.options.keys.length;d<h;d+=1){var p=this.options.keys[d];if("string"!=typeof p){if(a[p.name]={weight:1-p.weight||1},p.weight<=0||1<p.weight)throw new Error("Key weight has to be > 0 and <= 1");p=p.name}else a[p]={weight:1};this._analyze({key:p,value:this.options.getFn(u,p),record:u,index:l},{resultMap:o,results:r,tokenSearchers:e,fullSearcher:t})}return{weights:a,results:r}}},{key:"_analyze",value:function(e,t){var n=e.key,o=e.arrayIndex,r=void 0===o?-1:o,i=e.value,s=e.record,a=e.index,l=t.tokenSearchers,c=void 0===l?[]:l,u=t.fullSearcher,d=void 0===u?[]:u,h=t.resultMap,p=void 0===h?{}:h,f=t.results,v=void 0===f?[]:f;if(null!=i){var g=!1,m=-1,y=0;if("string"==typeof i){this._log("\nKey: "+(""===n?"-":n));var _=d.search(i);if(this._log('Full text: "'+i+'", score: '+_.score),this.options.tokenize){for(var b=i.split(this.options.tokenSeparator),k=[],S=0;S<c.length;S+=1){var x=c[S];this._log('\nPattern: "'+x.pattern+'"');for(var w=!1,C=0;C<b.length;C+=1){var L=b[C],M=x.search(L),I={};M.isMatch?(I[L]=M.score,w=g=!0,k.push(M.score)):(I[L]=1,this.options.matchAllTokens||k.push(1)),this._log('Token: "'+L+'", score: '+I[L])}w&&(y+=1)}m=k[0];for(var E=k.length,O=1;O<E;O+=1)m+=k[O];m/=E,this._log("Token score average:",m)}var A=_.score;-1<m&&(A=(A+m)/2),this._log("Score average:",A);var T=!this.options.tokenize||!this.options.matchAllTokens||y>=c.length;if(this._log("\nCheck Matches: "+T),(g||_.isMatch)&&T){var N=p[a];N?N.output.push({key:n,arrayIndex:r,value:i,score:A,matchedIndices:_.matchedIndices}):(p[a]={item:s,output:[{key:n,arrayIndex:r,value:i,score:A,matchedIndices:_.matchedIndices}]},v.push(p[a]))}}else if(V(i))for(var P=0,j=i.length;P<j;P+=1)this._analyze({key:n,arrayIndex:P,value:i[P],record:s,index:a},{resultMap:p,results:v,tokenSearchers:c,fullSearcher:d})}}},{key:"_computeScore",value:function(e,t){this._log("\n\nComputing score:\n");for(var n=0,o=t.length;n<o;n+=1){for(var r=t[n].output,i=r.length,s=1,a=1,l=0;l<i;l+=1){var c=e?e[r[l].key].weight:1,u=(1===c?r[l].score:r[l].score||.001)*c;1!==c?a=Math.min(a,u):s*=r[l].nScore=u}t[n].score=1===a?s:a,this._log(t[n])}}},{key:"_sort",value:function(e){this._log("\n\nSorting...."),e.sort(this.options.sortFn)}},{key:"_format",value:function(e){var t=[];this.options.verbose&&this._log("\n\nOutput:\n\n",JSON.stringify(e));var n=[];this.options.includeMatches&&n.push(function(e,t){var n=e.output;t.matches=[];for(var o=0,r=n.length;o<r;o+=1){var i=n[o];if(0!==i.matchedIndices.length){var s={indices:i.matchedIndices,value:i.value};i.key&&(s.key=i.key),i.hasOwnProperty("arrayIndex")&&-1<i.arrayIndex&&(s.arrayIndex=i.arrayIndex),t.matches.push(s)}}}),this.options.includeScore&&n.push(function(e,t){t.score=e.score});for(var o=0,r=e.length;o<r;o+=1){var i=e[o];if(this.options.id&&(i.item=this.options.getFn(i.item,this.options.id)[0]),n.length){for(var s={item:i.item},a=0,l=n.length;a<l;a+=1)n[a](i,s);t.push(s)}else t.push(i.item)}return t}},{key:"_log",value:function(){var e;this.options.verbose&&(e=console).log.apply(e,arguments)}}]),U}();e.exports=r}])},"object"==typeof n&&"object"==typeof t?t.exports=r():"function"==typeof define&&define.amd?define("Fuse",[],r):"object"==typeof n?n.Fuse=r():o.Fuse=r()},{}],7:[function(e,y,t){!function(){"use strict";function n(e,t){var n,o,r,i,s=d;for(i=arguments.length;2<i--;)u.push(arguments[i]);for(t&&null!=t.children&&(u.length||u.push(t.children),delete t.children);u.length;)if((o=u.pop())&&void 0!==o.pop)for(i=o.length;i--;)u.push(o[i]);else"boolean"==typeof o&&(o=null),(r="function"!=typeof e)&&(null==o?o="":"number"==typeof o?o=String(o):"string"!=typeof o&&(r=!1)),r&&n?s[s.length-1]+=o:s===d?s=[o]:s.push(o),n=r;var a=new c;return a.nodeName=e,a.children=s,a.attributes=null==t?void 0:t,a.key=null==t?void 0:t.key,void 0!==D.vnode&&D.vnode(a),a}function L(e,t){for(var n in t)e[n]=t[n];return e}function i(e){!e.__d&&(e.__d=!0)&&1==p.push(e)&&(D.debounceRendering||r)(t)}function t(){var e,t=p;for(p=[];e=t.pop();)e.__d&&j(e)}function C(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function M(e){var t=L({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var o in n)void 0===t[o]&&(t[o]=n[o]);return t}function I(e){var t=e.parentNode;t&&t.removeChild(e)}function v(e,t,n,o,r){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)n&&n(null),o&&o(e);else if("class"!==t||r)if("style"===t){if(o&&"string"!=typeof o&&"string"!=typeof n||(e.style.cssText=o||""),o&&"object"==typeof o){if("string"!=typeof n)for(var i in n)i in o||(e.style[i]="");for(var i in o)e.style[i]="number"==typeof o[i]&&!1===h.test(i)?o[i]+"px":o[i]}}else if("dangerouslySetInnerHTML"===t)o&&(e.innerHTML=o.__html||"");else if("o"==t[0]&&"n"==t[1]){var s=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),o?n||e.addEventListener(t,l,s):e.removeEventListener(t,l,s),(e.__l||(e.__l={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e){try{e[t]=null==o?"":o}catch(e){}null!=o&&!1!==o||"spellcheck"==t||e.removeAttribute(t)}else{var a=r&&t!==(t=t.replace(/^xlink:?/,""));null==o||!1===o?a?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof o&&(a?e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),o):e.setAttribute(t,o))}else e.className=o||""}function l(e){return this.__l[e.type](D.event&&D.event(e)||e)}function E(){for(var e;e=U.pop();)D.afterMount&&D.afterMount(e),e.componentDidMount&&e.componentDidMount()}function O(e,t,n,o,r,i){R++||(g=null!=r&&void 0!==r.ownerSVGElement,m=null!=e&&!("__preactattr_"in e));var s=A(e,t,n,o,i);return r&&s.parentNode!==r&&r.appendChild(s),--R||(m=!1,i||E()),s}function A(e,t,n,o,r){var i=e,s=g;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||r)?e.nodeValue!=t&&(e.nodeValue=t):(i=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(i,e),T(e,!0))),i.__preactattr_=!0,i;var a,l,c=t.nodeName;if("function"==typeof c)return function(e,t,n,o){var r=e&&e._component,i=r,s=e,a=r&&e._componentConstructor===t.nodeName,l=a,c=M(t);for(;r&&!l&&(r=r.__u);)l=r.constructor===t.nodeName;r&&l&&(!o||r._component)?(P(r,c,3,n,o),e=r.base):(i&&!a&&(V(i),e=s=null),r=N(t.nodeName,c,n),e&&!r.__b&&(r.__b=e,s=null),P(r,c,1,n,o),e=r.base,s&&e!==s&&(s._component=null,T(s,!1)));return e}(e,t,n,o);if(g="svg"===c||"foreignObject"!==c&&g,c=String(c),(!e||!C(e,c))&&(a=c,(l=g?document.createElementNS("http://www.w3.org/2000/svg",a):document.createElement(a)).__n=a,i=l,e)){for(;e.firstChild;)i.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(i,e),T(e,!0)}var u=i.firstChild,d=i.__preactattr_,h=t.children;if(null==d){d=i.__preactattr_={};for(var p=i.attributes,f=p.length;f--;)d[p[f].name]=p[f].value}return!m&&h&&1===h.length&&"string"==typeof h[0]&&null!=u&&void 0!==u.splitText&&null==u.nextSibling?u.nodeValue!=h[0]&&(u.nodeValue=h[0]):(h&&h.length||null!=u)&&function(e,t,n,o,r){var i,s,a,l,c,u=e.childNodes,d=[],h={},p=0,f=0,v=u.length,g=0,m=t?t.length:0;if(0!==v)for(var y=0;y<v;y++){var _=u[y],b=_.__preactattr_,k=m&&b?_._component?_._component.__k:b.key:null;null!=k?(p++,h[k]=_):(b||(void 0!==_.splitText?!r||_.nodeValue.trim():r))&&(d[g++]=_)}if(0!==m)for(var y=0;y<m;y++){l=t[y],c=null;var k=l.key;if(null!=k)p&&void 0!==h[k]&&(c=h[k],h[k]=void 0,p--);else if(f<g)for(i=f;i<g;i++)if(void 0!==d[i]&&(S=s=d[i],w=r,"string"==typeof(x=l)||"number"==typeof x?void 0!==S.splitText:"string"==typeof x.nodeName?!S._componentConstructor&&C(S,x.nodeName):w||S._componentConstructor===x.nodeName)){c=s,d[i]=void 0,i===g-1&&g--,i===f&&f++;break}c=A(c,l,n,o),a=u[y],c&&c!==e&&c!==a&&(null==a?e.appendChild(c):c===a.nextSibling?I(a):e.insertBefore(c,a))}var S,x,w;if(p)for(var y in h)void 0!==h[y]&&T(h[y],!1);for(;f<=g;)void 0!==(c=d[g--])&&T(c,!1)}(i,h,n,o,m||null!=d.dangerouslySetInnerHTML),function(e,t,n){var o;for(o in n)t&&null!=t[o]||null==n[o]||v(e,o,n[o],n[o]=void 0,g);for(o in t)"children"===o||"innerHTML"===o||o in n&&t[o]===("value"===o||"checked"===o?e[o]:n[o])||v(e,o,n[o],n[o]=t[o],g)}(i,t.attributes,d),g=s,i}function T(e,t){var n=e._component;n?V(n):(null!=e.__preactattr_&&e.__preactattr_.ref&&e.__preactattr_.ref(null),!1!==t&&null!=e.__preactattr_||I(e),o(e))}function o(e){for(e=e.lastChild;e;){var t=e.previousSibling;T(e,!0),e=t}}function N(e,t,n){var o,r=f.length;for(e.prototype&&e.prototype.render?(o=new e(t,n),a.call(o,t,n)):((o=new a(t,n)).constructor=e,o.render=s);r--;)if(f[r].constructor===e)return o.__b=f[r].__b,f.splice(r,1),o;return o}function s(e,t,n){return this.constructor(e,n)}function P(e,t,n,o,r){e.__x||(e.__x=!0,e.__r=t.ref,e.__k=t.key,delete t.ref,delete t.key,void 0===e.constructor.getDerivedStateFromProps&&(!e.base||r?e.componentWillMount&&e.componentWillMount():e.componentWillReceiveProps&&e.componentWillReceiveProps(t,o)),o&&o!==e.context&&(e.__c||(e.__c=e.context),e.context=o),e.__p||(e.__p=e.props),e.props=t,e.__x=!1,0!==n&&(1!==n&&!1===D.syncComponentUpdates&&e.base?i(e):j(e,1,r)),e.__r&&e.__r(e))}function j(e,t,n,o){if(!e.__x){var r,i,s,a=e.props,l=e.state,c=e.context,u=e.__p||a,d=e.__s||l,h=e.__c||c,p=e.base,f=e.__b,v=p||f,g=e._component,m=!1,y=h;if(e.constructor.getDerivedStateFromProps&&(l=L(L({},l),e.constructor.getDerivedStateFromProps(a,l)),e.state=l),p&&(e.props=u,e.state=d,e.context=h,2!==t&&e.shouldComponentUpdate&&!1===e.shouldComponentUpdate(a,l,c)?m=!0:e.componentWillUpdate&&e.componentWillUpdate(a,l,c),e.props=a,e.state=l,e.context=c),e.__p=e.__s=e.__c=e.__b=null,e.__d=!1,!m){r=e.render(a,l,c),e.getChildContext&&(c=L(L({},c),e.getChildContext())),p&&e.getSnapshotBeforeUpdate&&(y=e.getSnapshotBeforeUpdate(u,d));var _,b,k=r&&r.nodeName;if("function"==typeof k){var S=M(r);(i=g)&&i.constructor===k&&S.key==i.__k?P(i,S,1,c,!1):(_=i,e._component=i=N(k,S,c),i.__b=i.__b||f,i.__u=e,P(i,S,0,c,!1),j(i,1,n,!0)),b=i.base}else s=v,(_=g)&&(s=e._component=null),(v||1===t)&&(s&&(s._component=null),b=O(s,r,c,n||!p,v&&v.parentNode,!0));if(v&&b!==v&&i!==g){var x=v.parentNode;x&&b!==x&&(x.replaceChild(b,v),_||(v._component=null,T(v,!1)))}if(_&&V(_),(e.base=b)&&!o){for(var w=e,C=e;C=C.__u;)(w=C).base=b;b._component=w,b._componentConstructor=w.constructor}}for(!p||n?U.unshift(e):m||(e.componentDidUpdate&&e.componentDidUpdate(u,d,y),D.afterUpdate&&D.afterUpdate(e));e.__h.length;)e.__h.pop().call(e);R||o||E()}}function V(e){D.beforeUnmount&&D.beforeUnmount(e);var t=e.base;e.__x=!0,e.componentWillUnmount&&e.componentWillUnmount(),e.base=null;var n=e._component;n?V(n):t&&(t.__preactattr_&&t.__preactattr_.ref&&t.__preactattr_.ref(null),I(e.__b=t),f.push(e),o(t)),e.__r&&e.__r(null)}function a(e,t){this.__d=!0,this.context=t,this.props=e,this.state=this.state||{},this.__h=[]}var c=function(){},D={},u=[],d=[],r="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout,h=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,p=[],U=[],R=0,g=!1,m=!1,f=[];L(a.prototype,{setState:function(e,t){this.__s||(this.__s=this.state),this.state=L(L({},this.state),"function"==typeof e?e(this.state,this.props):e),t&&this.__h.push(t),i(this)},forceUpdate:function(e){e&&this.__h.push(e),j(this,2)},render:function(){}});var e={h:n,createElement:n,cloneElement:function(e,t){return n(e.nodeName,L(L({},e.attributes),t),2<arguments.length?[].slice.call(arguments,2):e.children)},Component:a,render:function(e,t,n){return O(n,e,{},!1,t,!1)},rerender:t,options:D};void 0!==y?y.exports=e:self.preact=e}()},{}]},{},[3]);
+//# sourceMappingURL=haddock-bundle.min.js.map
diff --git a/utils/haddock/haddock-api/resources/html/highlight.js b/utils/haddock/haddock-api/resources/html/highlight.js
new file mode 100644
index 0000000000000000000000000000000000000000..1e903bd0c59db043568d2e9eda09c4351ce14d11
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/highlight.js
@@ -0,0 +1,27 @@
+
+var highlight = function (on) {
+	return function () {
+		var links = document.getElementsByTagName('a');
+		for (var i = 0; i < links.length; i++) {
+			var that = links[i];
+
+			if (this.href != that.href) {
+				continue;
+			}
+
+			if (on) {
+				that.classList.add("hover-highlight");
+			} else {
+				that.classList.remove("hover-highlight");
+			}
+		}
+	}
+};
+
+window.onload = function () {
+	var links = document.getElementsByTagName('a');
+	for (var i = 0; i < links.length; i++) {
+		links[i].onmouseover = highlight(true);
+		links[i].onmouseout = highlight(false);
+	}
+};
diff --git a/utils/haddock/haddock-api/resources/html/js-src/cookies.ts b/utils/haddock/haddock-api/resources/html/js-src/cookies.ts
new file mode 100644
index 0000000000000000000000000000000000000000..3b68d6d87650b0e1c21abd064a5f571c4d397fce
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/js-src/cookies.ts
@@ -0,0 +1,20 @@
+export function setCookie(name: string, value: string) {
+  document.cookie = name + "=" + encodeURIComponent(value) + ";path=/;";
+}
+
+export function clearCookie(name: string) {
+  document.cookie = name + "=;path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT;";
+}
+
+export function getCookie(name: string) {
+  const nameEQ = name + "=";
+  const ca = document.cookie.split(';');
+  for (let i = 0; i < ca.length; i++) {
+    let c = ca[i];
+    while (c.charAt(0)==' ') c = c.substring(1,c.length);
+    if (c.indexOf(nameEQ) == 0) {
+      return decodeURIComponent(c.substring(nameEQ.length,c.length));
+    }
+  }
+  return null;
+}
\ No newline at end of file
diff --git a/utils/haddock/haddock-api/resources/html/js-src/details-helper.tsx b/utils/haddock/haddock-api/resources/html/js-src/details-helper.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..411d38d7b906f5a82c4e544f0fea4d33a53e90db
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/js-src/details-helper.tsx
@@ -0,0 +1,463 @@
+// This file implements the UI and logic for collapsing and expanding
+// instance lists ("details").
+//
+// A configuration ('GlobalConfig') controlled by the UI is persisted
+// in local storage in the user's browser. The configuration includes:
+//
+// * a global default state ('defaultInstanceState') for all instance
+//   lists. The possible values for the global default are "collapsed"
+//   and "expanded".
+//
+// * a global boolean option ('rememberToggles') to remember which
+//   specific instance lists are not in the default state (e.g. which
+//   instance lists are expanded when the default is "collapsed").
+//
+// * a local / per-page record of which specific instance lists are
+//   not in the default state, when the global option
+//   ('rememberToggles') to remember this info is enabled.
+//
+// The UI consists of an Instances menu with buttons for expanding and
+// collapsing all instance lists in the current module, a checkbox for
+// setting the global default state, and a checkbox to enable
+// remembering which instance lists are not in the global default
+// state. Also, each instance list on each module page has buttons for
+// collapsing and expanding.
+//
+// The logic of the UI is as follows:
+//
+// * setting the global default state erases any record of which
+//   specific instances are in the non-default state, and collapses or
+//   expands all instance lists on the current page to be in the
+//   global default state.
+//
+// * changing boolean option for remembering which specific instance
+//   lists are not in the default state erases any existing record of
+//   which instances are not in the default state across all pages,
+//   and updates the record for the current page when the option is
+//   set to true. No collapsing or expanding is done.
+//
+// * toggling the collapse/expand state of a specific instance list
+//   causes the state of that specific instance list to be recorded in
+//   the persisted configuration iff the new state of that specific
+//   instance list is different from the global default state, and the
+//   option to remember instance list states is enabled. There are two
+//   ways to toggle the collapse/expand state of a specific instance,
+//   by clicking its collapse/expand button, and by clicking the
+//   "collapse all" or "expand all" button in the Instances menu.
+//
+// This file also implements an association between elements (with
+// class "details-toggle" and "details-toggle-control") that can be
+// clicked to expand/collapse <details> elements, and the details
+// elements themselves. Note that this covers both <details> elements
+// that list instances -- what the above explained UI and logic is
+// concerned with -- and details about individual instances themselves
+// -- which the above is not concerend with. The association includes
+// adding event listeners that change CSS classes back and forth
+// between "expander" and "collapser"; these classes determine whether
+// an element is adorned with a right arrow ("expander") or a down
+// arrow ("collapser"). I don't understand why we don't directly use
+// the the HTML <summary> element type to allow the <details> elements
+// to be directly clickable.
+import preact = require("preact");
+
+const { h, Component } = preact;
+
+enum DefaultState { Closed, Open }
+
+interface GlobalConfig {
+  defaultInstanceState: DefaultState
+  rememberToggles: boolean
+}
+
+// Hackage domain-wide config
+const globalConfig: GlobalConfig = {
+  defaultInstanceState: DefaultState.Open,
+  rememberToggles: true,
+};
+
+class PreferencesButton extends Component<any, any> {
+  render(props: { title: string, onClick: () => void }) {
+    function onClick(e: Event) {
+      e.preventDefault();
+      props.onClick();
+    }
+    return <li><a href="#" onClick={onClick}>{props.title}</a></li>;
+  }
+}
+
+function addPreferencesButton(action: () => void) {
+  const pageMenu = document.querySelector('#page-menu') as HTMLUListElement;
+  const dummy = document.createElement('li');
+  pageMenu.insertBefore(dummy, pageMenu.firstChild);
+  preact.render(<PreferencesButton onClick={action} title="Instances" />, pageMenu, dummy);
+}
+
+type PreferencesProps = {
+  showHideTrigger: (action: () => void) => void
+}
+
+type PreferencesState = {
+  isVisible: boolean
+}
+
+class Preferences extends Component<PreferencesProps, PreferencesState> {
+  componentWillMount() {
+    document.addEventListener('mousedown', this.hide.bind(this));
+
+    document.addEventListener('keydown', (e) => {
+      if (this.state.isVisible) {
+        if (e.key === 'Escape') {
+          this.hide();
+        }
+      }
+    })
+  }
+
+  hide() {
+    this.setState({ isVisible: false });
+  }
+
+  show() {
+    if (!this.state.isVisible) {
+      this.setState({ isVisible: true });
+    }
+  }
+
+  toggleVisibility() {
+    if (this.state.isVisible) {
+      this.hide();
+    } else {
+      this.show();
+    }
+  }
+
+  componentDidMount() {
+    this.props.showHideTrigger(this.toggleVisibility.bind(this));
+  }
+
+  render(props: PreferencesProps, state: PreferencesState) {
+    const stopPropagation = (e: Event) => { e.stopPropagation(); };
+
+    return <div id="preferences" class={state.isVisible ? '' : 'hidden'}>
+        <div id="preferences-menu" class="dropdown-menu" onMouseDown={stopPropagation}>
+          <PreferencesMenu />
+        </div>
+      </div>;
+  }
+}
+
+function storeGlobalConfig() {
+  const json = JSON.stringify(globalConfig);
+  try {
+    // https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem#Exceptions.
+    localStorage.setItem('global', json);
+  } catch (e) {}
+}
+
+var globalConfigLoaded: boolean = false;
+
+function loadGlobalConfig() {
+  if (globalConfigLoaded) { return; }
+  globalConfigLoaded = true;
+  const global = localStorage.getItem('global');
+  if (!global) { return; }
+  try {
+    const globalConfig_ = JSON.parse(global);
+    globalConfig.defaultInstanceState = globalConfig_.defaultInstanceState;
+    globalConfig.rememberToggles = globalConfig_.rememberToggles;
+  } catch(e) {
+    // Gracefully handle errors related to changed config format.
+    if (e instanceof SyntaxError || e instanceof TypeError) {
+      localStorage.removeItem('global');
+    } else {
+      throw e;
+    }
+  }
+}
+
+function setDefaultInstanceState(s: DefaultState) {
+  return (e: Event) => {
+    globalConfig.defaultInstanceState = s;
+    putInstanceListsInDefaultState();
+    storeGlobalConfig();
+    clearLocalStorage();
+    storeLocalConfig();
+  }
+}
+
+function setRememberToggles(e: Event) {
+  const checked: boolean = (e as any).target.checked;
+  globalConfig.rememberToggles = checked;
+  storeGlobalConfig();
+  clearLocalStorage();
+  storeLocalConfig();
+}
+
+// Click event consumer for "default collapse" instance menu check box.
+function defaultCollapseOnClick(e: Event) {
+  const us = document.getElementById('default-collapse-instances') as HTMLInputElement;
+  if (us !== null) {
+    if (us.checked) {
+      setDefaultInstanceState(DefaultState.Closed)(e);
+    } else {
+      setDefaultInstanceState(DefaultState.Open)(e);
+    }
+  }
+}
+
+// Instances menu.
+function PreferencesMenu() {
+  loadGlobalConfig();
+  return <div>
+      <div>
+        <button type="button"
+                onClick={expandAllInstances}>
+        Expand All Instances
+        </button>
+        <button type="button"
+                onClick={collapseAllInstances}>
+        Collapse All Instances
+        </button>
+      </div>
+      <div>
+        <input type="checkbox"
+               id="default-collapse-instances"
+               name="default-instance-state"
+               checked={globalConfig.defaultInstanceState===DefaultState.Closed}
+               onClick={defaultCollapseOnClick}></input>
+
+        <span>Collapse All Instances By Default</span>
+      </div>
+      <div>
+        <input type="checkbox"
+               id="remember-toggles"
+               name="remember-toggles"
+               checked={globalConfig.rememberToggles}
+               onClick={setRememberToggles}></input>
+        <label for="remember-toggles">Remember Manually Collapsed/Expanded Instances</label>
+      </div>
+    </div>;
+}
+
+interface HTMLDetailsElement extends HTMLElement {
+  open: boolean
+}
+
+interface DetailsInfo {
+  element: HTMLDetailsElement
+  // Here 'toggles' is the list of all elements of class
+  // 'details-toggle-control' that control toggling 'element'. I
+  // believe this list is always length zero or one.
+  toggles: HTMLElement[]
+}
+
+// Mapping from <details> elements to their info.
+const detailsRegistry: { [id: string]: DetailsInfo } = {};
+
+function lookupDetailsRegistry(id: string): DetailsInfo {
+  const info = detailsRegistry[id];
+  if (info == undefined) { throw new Error(`could not find <details> element with id '${id}'`); }
+  return info;
+}
+
+// Return true iff instance lists are open by default.
+function getDefaultOpenSetting(): boolean {
+  return globalConfig.defaultInstanceState == DefaultState.Open;
+}
+
+// Event handler for "toggle" events, which are triggered when a
+// <details> element's "open" property changes.  We don't deal with
+// any config stuff here, because we only change configs in response
+// to mouse clicks. In contrast, for example, this event is triggred
+// automatically once for every <details> element when the user clicks
+// the "collapse all elements" button.
+function onToggleEvent(ev: Event) {
+  const element = ev.target as HTMLDetailsElement;
+  const id = element.id;
+  const info = lookupDetailsRegistry(id);
+  const isOpen = info.element.open;
+  // Update the CSS of the toggle element users can click on to toggle
+  // 'element'. The "collapser" and "expander" classes control what
+  // kind of arrow appears next to the 'toggle' element.
+  for (const toggle of info.toggles) {
+    if (toggle.classList.contains('details-toggle-control')) {
+      toggle.classList.add(isOpen ? 'collapser' : 'expander');
+      toggle.classList.remove(isOpen ? 'expander' : 'collapser');
+    }
+  }
+}
+
+function gatherDetailsElements() {
+  const els: HTMLDetailsElement[] = Array.prototype.slice.call(document.getElementsByTagName('details'));
+  for (const el of els) {
+    if (typeof el.id == "string" && el.id.length > 0) {
+      detailsRegistry[el.id] = {
+        element: el,
+        toggles: [] // Populated later by 'initCollapseToggles'.
+      };
+      el.addEventListener('toggle', onToggleEvent);
+    }
+  }
+}
+
+// Return the id of the <details> element that the given 'toggle'
+// element toggles.
+function getDataDetailsId(toggle: Element): string {
+  const id = toggle.getAttribute('data-details-id');
+  if (!id) { throw new Error("element with class " + toggle + " has no 'data-details-id' attribute!"); }
+  return id;
+}
+
+// Toggle the "open" state of a <details> element when that element's
+// toggle element is clicked.
+function toggleDetails(toggle: Element) {
+  const id = getDataDetailsId(toggle);
+  const {element} = lookupDetailsRegistry(id);
+  element.open = !element.open;
+}
+
+// Prefix for local keys used with local storage. Idea is that other
+// modules could also use local storage with a different prefix and we
+// wouldn't step on each other's toes.
+//
+// NOTE: we're using the browser's "local storage" API via the
+// 'localStorage' object to store both "local" (to the current Haddock
+// page) and "global" (across all Haddock pages) configuration. Be
+// aware of these two different uses of the term "local".
+const localStoragePrefix: string = "local-details-config:";
+
+// Local storage key for the current page.
+function localStorageKey(): string {
+  return localStoragePrefix + document.location.pathname;
+}
+
+// Clear all local storage related to instance list configs.
+function clearLocalStorage() {
+  const keysToDelete: string[] = [];
+  for (var i = 0; i < localStorage.length; ++i) {
+    const key = localStorage.key(i);
+    if (key !== null && key.startsWith(localStoragePrefix)) {
+      keysToDelete.push(key);
+    }
+  }
+  keysToDelete.forEach(key => {
+    localStorage.removeItem(key);
+  });
+}
+
+// Compute and save the set of instance list ids that aren't in the
+// default state.
+function storeLocalConfig() {
+  if (!globalConfig.rememberToggles) return;
+  const instanceListToggles: HTMLElement[] =
+    // Restrict to 'details-toggle' elements for "instances"
+    // *plural*. These are the toggles that control instance lists and
+    // not the list of methods for individual instances.
+    Array.prototype.slice.call(document.getElementsByClassName(
+      'instances details-toggle details-toggle-control'));
+  const nonDefaultInstanceListIds: string[] = [];
+  instanceListToggles.forEach(toggle => {
+    const id = getDataDetailsId(toggle);
+    const details = document.getElementById(id) as HTMLDetailsElement;
+    if (details.open != getDefaultOpenSetting()) {
+      nonDefaultInstanceListIds.push(id);
+    }
+  });
+
+  const json = JSON.stringify(nonDefaultInstanceListIds);
+  try {
+    // https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem#Exceptions.
+    localStorage.setItem(localStorageKey(), json);
+  } catch (e) {}
+}
+
+function putInstanceListsInDefaultState() {
+  switch (globalConfig.defaultInstanceState) {
+    case DefaultState.Closed: _collapseAllInstances(true); break;
+    case DefaultState.Open: _collapseAllInstances(false); break;
+    default: break;
+  }
+}
+
+// Expand and collapse instance lists according to global and local
+// config.
+function restoreToggled() {
+  loadGlobalConfig();
+  putInstanceListsInDefaultState();
+  if (!globalConfig.rememberToggles) { return; }
+  const local = localStorage.getItem(localStorageKey());
+  if (!local) { return; }
+  try {
+    const nonDefaultInstanceListIds: string[] = JSON.parse(local);
+    nonDefaultInstanceListIds.forEach(id => {
+      const info = lookupDetailsRegistry(id);
+      info.element.open = ! getDefaultOpenSetting();
+    });
+  } catch(e) {
+    // Gracefully handle errors related to changed config format.
+    if (e instanceof SyntaxError || e instanceof TypeError) {
+      localStorage.removeItem(localStorageKey());
+    } else {
+      throw e;
+    }
+  }
+}
+
+// Handler for clicking on the "toggle" element that toggles the
+// <details> element with id given by the 'data-details-id' property
+// of the "toggle" element.
+function onToggleClick(ev: MouseEvent) {
+  const toggle = ev.currentTarget as HTMLElement;
+  toggleDetails(toggle);
+  storeLocalConfig();
+}
+
+// Set event handlers on elements responsible for expanding and
+// collapsing <details> elements.
+//
+// This applies to all 'details-toggle's, not just to to top-level
+// 'details-toggle's that control instance lists.
+function initCollapseToggles() {
+  const toggles: HTMLElement[] = Array.prototype.slice.call(document.getElementsByClassName('details-toggle'));
+  toggles.forEach(toggle => {
+    const id = getDataDetailsId(toggle);
+    const info = lookupDetailsRegistry(id);
+    info.toggles.push(toggle);
+    toggle.addEventListener('click', onToggleClick);
+    if (toggle.classList.contains('details-toggle-control')) {
+      toggle.classList.add(info.element.open ? 'collapser' : 'expander');
+    }
+  });
+}
+
+// Collapse or expand all instances.
+function _collapseAllInstances(collapse: boolean) {
+  const ilists = document.getElementsByClassName('subs instances');
+  [].forEach.call(ilists, function (ilist : Element) {
+    const toggleType = collapse ? 'collapser' : 'expander';
+    const toggle = ilist.getElementsByClassName('instances ' + toggleType)[0];
+    if (toggle) {
+      toggleDetails(toggle);
+    }
+  });
+}
+
+function collapseAllInstances() {
+  _collapseAllInstances(true);
+  storeLocalConfig();
+}
+
+function expandAllInstances() {
+  _collapseAllInstances(false);
+  storeLocalConfig();
+}
+
+export function init(showHide?: (action: () => void) => void) {
+  gatherDetailsElements();
+  initCollapseToggles();
+  restoreToggled();
+  preact.render(
+    <Preferences showHideTrigger={showHide || addPreferencesButton} />,
+    document.body
+  );
+}
diff --git a/utils/haddock/haddock-api/resources/html/js-src/init.ts b/utils/haddock/haddock-api/resources/html/js-src/init.ts
new file mode 100644
index 0000000000000000000000000000000000000000..4a58b86788e3ef2d687708b78cb874920ab91cfb
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/js-src/init.ts
@@ -0,0 +1,27 @@
+import * as styleMenu from "./style-menu";
+import * as detailsHelper from "./details-helper";
+import * as quickJump from "./quick-jump";
+
+function onDomReady(callback: () => void) {
+  if (document.readyState === 'interactive') {
+    callback();
+  } else {
+    document.addEventListener('readystatechange', () => {
+      if (document.readyState === 'interactive') {
+        callback();
+      }
+    });
+  }
+}
+
+onDomReady(() => {
+  document.body.classList.add('js-enabled');
+  styleMenu.init();
+  detailsHelper.init();
+  let head = document.getElementById('head');
+  let baseURL = ".";
+  if (head !== null) {
+    baseURL = head.getAttribute('data-base-url') || '.';
+  }
+  quickJump.init(baseURL);
+});
diff --git a/utils/haddock/haddock-api/resources/html/js-src/quick-jump.tsx b/utils/haddock/haddock-api/resources/html/js-src/quick-jump.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..ef02cbd2f12a3f9627379e09e887cfd6210460c7
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/js-src/quick-jump.tsx
@@ -0,0 +1,425 @@
+import Fuse = require('fuse.js');
+import preact = require("preact");
+
+const { h, Component } = preact;
+
+type DocItem = {
+  display_html: string
+  name: string
+  module: string
+  link: string
+}
+
+function loadJSON(path: string, success: (json: DocItem[]) => void, error: (xhr: XMLHttpRequest) => void) {
+  const xhr = new XMLHttpRequest();
+  xhr.onreadystatechange = () => {
+    if (xhr.readyState === XMLHttpRequest.DONE) {
+      if (xhr.status === 200) {
+        if (success) {
+          try {
+            success(JSON.parse(xhr.responseText));
+          } catch (exc) {
+            error(xhr);
+          }
+        }
+      } else {
+        if (error) { error(xhr); }
+      }
+    }
+  };
+  xhr.open("GET", path, true);
+  xhr.send();
+}
+
+// -------------------------------------------------------------------------- //
+
+class PageMenuButton extends Component<any, any> {
+
+  render(props: { title: string, onClick: () => void }) {
+    function onClick(e: Event) {
+      e.preventDefault();
+      props.onClick();
+    }
+    return <li><a href="#" onClick={onClick}>{props.title}</a></li>;
+  }
+
+}
+
+function addSearchPageMenuButton(quickJumpButton: HTMLLIElement) {
+  const showHide = function(action: () => void) {
+    const pageMenu = document.querySelector('#page-menu') as HTMLUListElement;
+    preact.render(<PageMenuButton onClick={action} title="Quick Jump" />, pageMenu, quickJumpButton);
+  };
+  return showHide;
+}
+
+// -------------------------------------------------------------------------- //
+
+function take<T>(n: number, arr: T[]) {
+  if (arr.length <= n) { return arr; }
+  return arr.slice(0, n);
+}
+
+type FuseResult<T> = {
+  score: number
+  item: T
+}
+
+type ResultsInModule = { module: string, totalScore: number, items: FuseResult<DocItem>[] }
+
+type QuickJumpProps = {
+  baseUrl: string
+  showHideTrigger: (action: () => void) => void
+}
+
+type QuickJumpState = {
+  searchString: string
+  isVisible: boolean
+  expanded: { [moduleName: string]: true }
+  activeLinkIndex: number
+  moduleResults: ResultsInModule[]
+  failedLoading?: boolean
+  fuse: Fuse<DocItem>
+}
+
+class QuickJump extends Component<QuickJumpProps, QuickJumpState> {
+
+  private linkIndex: number = 0;
+  private focusPlease: boolean = false;
+  private navigatedByKeyboard: boolean = false;
+  private activeLink: undefined | HTMLAnchorElement;
+  private activeLinkAction: undefined | (() => void);
+
+  private input: undefined | HTMLInputElement;
+  private searchResults: undefined | Element;
+
+  componentWillMount() {
+    this.setState({
+      searchString: '',
+      isVisible: false,
+      expanded: {},
+      activeLinkIndex: -1,
+      moduleResults: []
+    });
+    loadJSON(this.props.baseUrl + "/doc-index.json", (data) => {
+      this.setState({
+        fuse: new Fuse(data, {
+          threshold: 0.25,
+          caseSensitive: true,
+          includeScore: true,
+          tokenize: true,
+          keys: [ {
+                    name: "name",
+                    weight: 0.7
+                  },
+                  {
+                    name: "module",
+                    weight: 0.3
+                  }
+                ]
+        }),
+        moduleResults: []
+      });
+    }, (err) => {
+      if (console) {
+        console.error("could not load 'doc-index.json' for searching", err);
+      }
+      this.setState({ failedLoading: true });
+    });
+
+    document.addEventListener('mousedown', this.hide.bind(this));
+
+    document.addEventListener('keydown', (e) => {
+      if (this.state.isVisible) {
+        if (e.key === 'Escape') {
+          this.hide();
+        } else if (e.key === 'ArrowUp' || (e.key === 'k' && e.ctrlKey)) {
+          e.preventDefault();
+          this.navigateLinks(-1);
+        } else if (e.key === 'ArrowDown' || (e.key === 'j' && e.ctrlKey)) {
+          e.preventDefault();
+          this.navigateLinks(+1);
+        } else if (e.key === 'Enter' && this.state.activeLinkIndex >= 0) {
+          this.followActiveLink();
+        }
+      }
+
+      if (e.key === 's' && (e.target as HTMLElement).tagName.toLowerCase() !== 'input') {
+        e.preventDefault();
+        this.show();
+      }
+    })
+  }
+
+  hide() {
+    this.setState({ isVisible: false, searchString: '' });
+  }
+
+  show() {
+    if (!this.state.isVisible) {
+      this.focusPlease = true;
+      this.setState({ isVisible: true, activeLinkIndex: -1 });
+    }
+  }
+
+  toggleVisibility() {
+    if (this.state.isVisible) {
+      this.hide();
+    } else {
+      this.show();
+    }
+  }
+
+  navigateLinks(change: number) {
+    const newActiveLinkIndex = Math.max(-1, Math.min(this.linkIndex-1, this.state.activeLinkIndex + change));
+    this.navigatedByKeyboard = true;
+    this.setState({ activeLinkIndex: newActiveLinkIndex });
+  }
+
+  followActiveLink() {
+    if (!this.activeLinkAction) { return; }
+    this.activeLinkAction();
+  }
+
+  updateResults() {
+    const searchString = (this.input && this.input.value) || '';
+    const results: FuseResult<DocItem>[] = this.state.fuse.search(searchString) as any as FuseResult<DocItem>[];
+
+    const resultsByModule: { [name: string]: FuseResult<DocItem>[] } = {};
+
+    results.forEach((result) => {
+      const moduleName = result.item.module;
+      const resultsInModule = resultsByModule[moduleName] || (resultsByModule[moduleName] = []);
+      resultsInModule.push(result);
+    });
+
+    const moduleResults: ResultsInModule[] = [];
+    for (const moduleName in resultsByModule) {
+      const items = resultsByModule[moduleName];
+      let sumOfInverseScores = 0;
+      items.forEach((item) => { sumOfInverseScores += 1/item.score; });
+      moduleResults.push({ module: moduleName, totalScore: 1/sumOfInverseScores, items: items });
+    }
+
+    moduleResults.sort((a, b) => a.totalScore - b.totalScore);
+
+    this.setState({ searchString: searchString, isVisible: true, moduleResults: moduleResults });
+  }
+
+  componentDidUpdate() {
+    if (this.searchResults && this.activeLink && this.navigatedByKeyboard) {
+      const rect = this.activeLink.getClientRects()[0];
+      const searchResultsTop = this.searchResults.getClientRects()[0].top;
+      if (rect.bottom > window.innerHeight) {
+        this.searchResults.scrollTop += rect.bottom - window.innerHeight + 80;
+      } else if (rect.top < searchResultsTop) {
+        this.searchResults.scrollTop -= searchResultsTop - rect.top + 80;
+      }
+    }
+    if (this.focusPlease && this.input) {
+      this.input.focus();
+    }
+    this.navigatedByKeyboard = false;
+    this.focusPlease = false;
+  }
+
+  componentDidMount() {
+    this.props.showHideTrigger(this.toggleVisibility.bind(this));
+  }
+
+  render(props: any, state: QuickJumpState) {
+    if (state.failedLoading) {
+      const usingFileProtocol = window.location.protocol == 'file:';
+      return <div id="search" class={state.isVisible ? '' : 'hidden'}>
+        <div id="search-results">
+          <p class="error">Failed to load file 'doc-index.json' containing definitions in this package.</p>
+          {usingFileProtocol ? <p class="error">
+              To use quick jump, load this page with HTTP (from a local static file web server) instead of using the <code>file://</code> protocol.
+              (For security reasons, it is not possible to fetch auxiliary files using JS in a HTML page opened with <code>file://</code>.)
+            </p> : []
+          }
+        </div>
+      </div>;
+    }
+
+    this.linkIndex = 0;
+
+    const stopPropagation = (e: Event) => { e.stopPropagation(); };
+
+    const onMouseOver = (e: MouseEvent) => {
+      let target: null | Element = e.target as Element;
+      while (target && typeof target.getAttribute === 'function') {
+        const linkIndexString = target.getAttribute('data-link-index');
+        if (typeof linkIndexString == 'string') {
+          const linkIndex = parseInt(linkIndexString, 10);
+          this.setState({ activeLinkIndex: linkIndex });
+          break;
+        }
+        target = target.parentNode as null | Element;
+      }
+    };
+
+    const items = take(10, state.moduleResults).map((r) => this.renderResultsInModule(r));
+
+    return <div id="search" class={state.isVisible ? '' : 'hidden'}>
+      <div id="search-form" onMouseDown={stopPropagation}>
+        <input
+          placeholder="Search in package by name"
+          ref={(input) => { this.input = input as undefined | HTMLInputElement; }}
+          onFocus={this.show.bind(this)}
+          onClick={this.show.bind(this)}
+          onInput={this.updateResults.bind(this)}
+        />
+      </div>
+      <div id="search-results" ref={(el) => { this.searchResults = el; }}
+        onMouseDown={stopPropagation} onMouseOver={onMouseOver}>
+        {state.searchString === ''
+          ? [<IntroMsg />, <KeyboardShortcuts />]
+          : items.length == 0
+            ? <NoResultsMsg searchString={state.searchString} />
+            : <ul>{items}</ul>}
+      </div>
+    </div>;
+  }
+
+  renderResultsInModule(resultsInModule: ResultsInModule): JSX.Element {
+    const items = resultsInModule.items;
+    const moduleName = resultsInModule.module;
+    const showAll = this.state.expanded[moduleName] || items.length <= 10;
+    const visibleItems = showAll ? items : take(8, items);
+
+    const expand = () => {
+      const newExpanded = Object.assign({}, this.state.expanded);
+      newExpanded[moduleName] = true;
+      this.setState({ expanded: newExpanded });
+    };
+
+    const renderItem = (item: DocItem) => {
+      return <li class="search-result">
+        {this.navigationLink(this.props.baseUrl + "/" + item.link, {},
+          <DocHtml html={item.display_html} />
+        )}
+      </li>;
+    };
+
+    return <li class="search-module">
+      <h4>{moduleName}</h4>
+      <ul>
+        {visibleItems.map((item) => renderItem(item.item))}
+        {showAll
+          ? []
+          : <li class="more-results">
+              {this.actionLink(expand, {}, "show " + (items.length - visibleItems.length) + " more results from this module")}
+            </li>}
+      </ul>
+    </li>;
+  }
+
+  navigationLink(href: string, attrs: JSX.HTMLAttributes&JSX.SVGAttributes&{[propName: string]: any}, ...children: (JSX.Element|JSX.Element[]|string)[]) {
+    const fullAttrs = Object.assign({ href: href, onClick: this.hide.bind(this) }, attrs);
+    const action = () => { window.location.href = href; this.hide(); };
+    return this.menuLink(fullAttrs, action, ...children);
+  }
+
+  actionLink(callback: () => void, attrs: JSX.HTMLAttributes&JSX.SVGAttributes&{[propName: string]: any}, ...children: (JSX.Element|JSX.Element[]|string)[]) {
+    const onClick = (e: Event) => { e.preventDefault(); callback(); };
+    const fullAttrs = Object.assign({ href: '#', onClick: onClick }, attrs);
+    return this.menuLink(fullAttrs, callback, ...children);
+  }
+
+  menuLink(attrs: JSX.HTMLAttributes&JSX.SVGAttributes&{[propName: string]: any}, action: () => void, ...children: (JSX.Element|JSX.Element[]|string)[]) {
+    const linkIndex = this.linkIndex;
+    if (linkIndex === this.state.activeLinkIndex) {
+      attrs['class'] = (attrs['class'] ? attrs['class'] + ' ' : '') + 'active-link';
+      attrs.ref = (link?: Element) => { if (link) this.activeLink = link as HTMLAnchorElement; };
+      this.activeLinkAction = action;
+    }
+    const newAttrs = Object.assign({ 'data-link-index': linkIndex }, attrs);
+    this.linkIndex += 1;
+    return h('a', newAttrs, ...children);
+  }
+
+}
+
+class DocHtml extends Component<{ html: string }, {}> {
+
+  shouldComponentUpdate(newProps: { html: string }) {
+    return this.props.html !== newProps.html;
+  }
+
+  render(props: { html: string }) {
+    return <div dangerouslySetInnerHTML={{__html: props.html}} />;
+  }
+
+};
+
+function KeyboardShortcuts() {
+  return <table class="keyboard-shortcuts">
+    <tr>
+      <th>Key</th>
+      <th>Shortcut</th>
+    </tr>
+    <tr>
+      <td><span class="key">s</span></td>
+      <td>Open this search box</td>
+    </tr>
+    <tr>
+      <td><span class="key">esc</span></td>
+      <td>Close this search box</td>
+    </tr>
+    <tr>
+      <td>
+        <span class="key">↓</span>,
+        <span class="key">ctrl</span> + <span class="key">j</span>
+      </td>
+      <td>Move down in search results</td>
+    </tr>
+    <tr>
+      <td>
+        <span class="key">↑</span>,
+        <span class="key">ctrl</span> + <span class="key">k</span>
+      </td>
+      <td>Move up in search results</td>
+    </tr>
+    <tr>
+      <td><span class="key">↵</span></td>
+      <td>Go to active search result</td>
+    </tr>
+  </table>;
+}
+
+function IntroMsg() {
+  return <p>You can find any exported type, constructor, class, function or pattern defined in this package by (approximate) name.</p>;
+}
+
+function NoResultsMsg(props: { searchString: string }) {
+  const messages = [
+    <p>
+      Your search for '{props.searchString}' produced the following list of results: <code>[]</code>.
+    </p>,
+    <p>
+      <code>Nothing</code> matches your query for '{props.searchString}'.
+    </p>,
+    <p>
+      <code>
+        Left "no matches for '{props.searchString}'" :: Either String (NonEmpty SearchResult)
+      </code>
+    </p>
+  ];
+
+  return messages[(props.searchString || 'a').charCodeAt(0) % messages.length];
+}
+
+export function init(docBaseUrl?: string, showHide?: (action: () => void) => void) {
+  // A <li> element with this id should exist if --quickjump was set
+  const quickJumpButton = document.getElementById('quick-jump-button');
+  if (quickJumpButton)
+    preact.render(
+      <QuickJump baseUrl={docBaseUrl || "."} showHideTrigger={showHide ||
+        addSearchPageMenuButton(quickJumpButton as HTMLLIElement)} />,
+      document.body
+    );
+}
+
+// export to global object
+(window as any).quickNav = { init: init };
diff --git a/utils/haddock/haddock-api/resources/html/js-src/style-menu.tsx b/utils/haddock/haddock-api/resources/html/js-src/style-menu.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..2eb8344e1ca84ef6c8e0e9f59b51e4f61f16fdc0
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/js-src/style-menu.tsx
@@ -0,0 +1,135 @@
+// Haddock JavaScript utilities
+
+import {getCookie, setCookie, clearCookie} from "./cookies";
+import preact = require("preact");
+
+const { h, Component } = preact;
+
+// Get all of the styles that are available
+function styles(): HTMLLinkElement[] {
+  const es = Array.prototype.slice.call(document.getElementsByTagName("link"));
+  return es.filter((a: HTMLLinkElement) => a.rel.indexOf("style") != -1 && a.title);
+}
+
+// Set a style (including setting the cookie)
+function setActiveStyleSheet(title: string) {
+  const as = styles();
+  let found: null | HTMLLinkElement = null;
+  for(let i = 0; i < as.length; i++) {
+    const a = as[i];
+    a.disabled = true;
+          // need to do this always, some browsers are edge triggered
+    if(a.title == title) {
+      found = a;
+    }
+  }
+  if (found) {
+    found.disabled = false;
+    setCookie("haddock-style", title);
+  }
+  else {
+    as[0].disabled = false;
+    clearCookie("haddock-style");
+  }
+}
+
+// Reset the style based on the cookie
+function resetStyle() {
+  const s = getCookie("haddock-style");
+  if (s) setActiveStyleSheet(s);
+}
+
+class StylesButton extends Component<any, any> {
+  render(props: { title: string, onClick: () => void }) {
+    function onClick(e: Event) {
+      e.preventDefault();
+      props.onClick();
+    }
+    return <li><a href="#" onClick={onClick}>{props.title}</a></li>;
+  }
+}
+
+// Add the style menu button
+function addStyleMenu(stys: string[], action: () => void) {
+  if (stys.length > 1) {
+    const pageMenu = document.querySelector('#page-menu') as HTMLUListElement;
+    const dummy = document.createElement('li');
+    pageMenu.appendChild(dummy);
+    preact.render(<StylesButton onClick={action} title="Styles"/>, pageMenu, dummy);
+  }
+}
+
+type StyleProps = {
+  styles: string[]
+  showHideTrigger: (action: () => void) => void
+}
+
+type StyleState = {
+  isVisible: boolean
+}
+
+// Represents the full style dropdown
+class Styles extends Component<StyleProps, StyleState> {
+
+  componentWillMount() {
+    document.addEventListener('mousedown', this.hide.bind(this));
+
+    document.addEventListener('keydown', (e) => {
+      if (this.state.isVisible) {
+        if (e.key === 'Escape') {
+          this.hide();
+        }
+      }
+    })
+  }
+
+  hide() {
+    this.setState({ isVisible: false });
+  }
+
+  show() {
+    if (!this.state.isVisible) {
+      this.setState({ isVisible: true });
+    }
+  }
+
+  toggleVisibility() {
+    if (this.state.isVisible) {
+      this.hide();
+    } else {
+      this.show();
+    }
+  }
+
+  componentDidMount() {
+    this.props.showHideTrigger(this.toggleVisibility.bind(this));
+  }
+
+  render(props: StyleProps, state: StyleState) {
+    const stopPropagation = (e: Event) => { e.stopPropagation(); };
+
+    return <div id="style" class={state.isVisible ? '' : 'hidden'}>
+        <div id="style-menu" class="dropdown-menu" onMouseDown={stopPropagation}>
+          {
+            props.styles.map((sty) =>
+              <button type="button"
+                      onClick={(e) => { this.hide(); setActiveStyleSheet(sty) }}>
+                {sty}
+              </button>
+            )
+          }
+        </div>
+      </div>;
+  }
+}
+
+
+export function init(showHide?: (action: () => void) => void) {
+  const stys = styles().map((s) => s.title);
+  const addStylesButton = (action: () => void) => addStyleMenu(stys, action)
+  resetStyle();
+  preact.render(
+    <Styles showHideTrigger={showHide || addStylesButton} styles={stys} />,
+    document.body
+  );
+}
diff --git a/utils/haddock/haddock-api/resources/html/package-lock.json b/utils/haddock/haddock-api/resources/html/package-lock.json
new file mode 100644
index 0000000000000000000000000000000000000000..cd63cad8f67701a33b4f630e75193ba70f65a60a
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/package-lock.json
@@ -0,0 +1,10358 @@
+{
+  "name": "haddock-quick-jump",
+  "version": "0.1.0",
+  "lockfileVersion": 2,
+  "requires": true,
+  "packages": {
+    "": {
+      "name": "haddock-quick-jump",
+      "version": "0.1.0",
+      "dependencies": {
+        "fuse.js": "^3.3.0",
+        "preact": "^8.3.1"
+      },
+      "devDependencies": {
+        "browserify": "^14.5.0",
+        "gulp": "^4.0.2",
+        "gulp-sourcemaps": "^2.6.4",
+        "gulp-uglify": "^3.0.1",
+        "tsify": "^3.0.4",
+        "typescript": "^2.9.2",
+        "vinyl-buffer": "^1.0.1",
+        "vinyl-source-stream": "^2.0.0"
+      }
+    },
+    "node_modules/@gulp-sourcemaps/identity-map": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/identity-map/-/identity-map-1.0.2.tgz",
+      "integrity": "sha512-ciiioYMLdo16ShmfHBXJBOFm3xPC4AuwO4xeRpFeHz7WK9PYsWCmigagG2XyzZpubK4a3qNKoUBDhbzHfa50LQ==",
+      "dev": true,
+      "dependencies": {
+        "acorn": "^5.0.3",
+        "css": "^2.2.1",
+        "normalize-path": "^2.1.1",
+        "source-map": "^0.6.0",
+        "through2": "^2.0.3"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/@gulp-sourcemaps/identity-map/node_modules/acorn": {
+      "version": "5.7.4",
+      "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
+      "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
+      "dev": true,
+      "bin": {
+        "acorn": "bin/acorn"
+      },
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/@gulp-sourcemaps/identity-map/node_modules/source-map": {
+      "version": "0.6.1",
+      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+      "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/@gulp-sourcemaps/map-sources": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz",
+      "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=",
+      "dev": true,
+      "dependencies": {
+        "normalize-path": "^2.0.1",
+        "through2": "^2.0.3"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/acorn": {
+      "version": "6.4.2",
+      "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
+      "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==",
+      "dev": true,
+      "bin": {
+        "acorn": "bin/acorn"
+      },
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/acorn-dynamic-import": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
+      "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
+      "dev": true
+    },
+    "node_modules/acorn-node": {
+      "version": "1.6.1",
+      "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.6.1.tgz",
+      "integrity": "sha512-B+fHENiJB8X0lNQQ/auxOqBC1xWig8RpxUAomCrlLJmNx1Z141WyRjwcEK4Ux7YRq3133H5Q6GYXch0rOa47NQ==",
+      "dev": true,
+      "dependencies": {
+        "acorn": "^6.0.1",
+        "acorn-dynamic-import": "^4.0.0",
+        "acorn-walk": "^6.0.1",
+        "xtend": "^4.0.1"
+      }
+    },
+    "node_modules/acorn-walk": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.0.tgz",
+      "integrity": "sha512-ugTb7Lq7u4GfWSqqpwE0bGyoBZNMTok/zDBXxfEG0QM50jNlGhIWjRC1pPN7bvV1anhF+bs+/gNcRw+o55Evbg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/ansi-colors": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz",
+      "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==",
+      "dev": true,
+      "dependencies": {
+        "ansi-wrap": "^0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/ansi-gray": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz",
+      "integrity": "sha512-HrgGIZUl8h2EHuZaU9hTR/cU5nhKxpVE1V6kdGsQ8e4zirElJ5fvtfc8N7Q1oq1aatO275i8pUFUCpNWCAnVWw==",
+      "dev": true,
+      "dependencies": {
+        "ansi-wrap": "0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/ansi-regex": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
+      "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/ansi-wrap": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz",
+      "integrity": "sha512-ZyznvL8k/FZeQHr2T6LzcJ/+vBApDnMNZvfVFy3At0knswWd6rJ3/0Hhmpu8oqa6C92npmozs890sX9Dl6q+Qw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/any-promise": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
+      "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=",
+      "dev": true
+    },
+    "node_modules/anymatch": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz",
+      "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==",
+      "dev": true,
+      "dependencies": {
+        "micromatch": "^3.1.4",
+        "normalize-path": "^2.1.1"
+      }
+    },
+    "node_modules/append-buffer": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/append-buffer/-/append-buffer-1.0.2.tgz",
+      "integrity": "sha512-WLbYiXzD3y/ATLZFufV/rZvWdZOs+Z/+5v1rBZ463Jn398pa6kcde27cvozYnBoxXblGZTFfoPpsaEw0orU5BA==",
+      "dev": true,
+      "dependencies": {
+        "buffer-equal": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/archy": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz",
+      "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==",
+      "dev": true
+    },
+    "node_modules/arr-diff": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz",
+      "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/arr-filter": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/arr-filter/-/arr-filter-1.1.2.tgz",
+      "integrity": "sha512-A2BETWCqhsecSvCkWAeVBFLH6sXEUGASuzkpjL3GR1SlL/PWL6M3J8EAAld2Uubmh39tvkJTqC9LeLHCUKmFXA==",
+      "dev": true,
+      "dependencies": {
+        "make-iterator": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/arr-flatten": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
+      "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/arr-map": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/arr-map/-/arr-map-2.0.2.tgz",
+      "integrity": "sha512-tVqVTHt+Q5Xb09qRkbu+DidW1yYzz5izWS2Xm2yFm7qJnmUfz4HPzNxbHkdRJbz2lrqI7S+z17xNYdFcBBO8Hw==",
+      "dev": true,
+      "dependencies": {
+        "make-iterator": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/arr-union": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz",
+      "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/array-each": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz",
+      "integrity": "sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/array-initial": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/array-initial/-/array-initial-1.1.0.tgz",
+      "integrity": "sha512-BC4Yl89vneCYfpLrs5JU2aAu9/a+xWbeKhvISg9PT7eWFB9UlRvI+rKEtk6mgxWr3dSkk9gQ8hCrdqt06NXPdw==",
+      "dev": true,
+      "dependencies": {
+        "array-slice": "^1.0.0",
+        "is-number": "^4.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/array-initial/node_modules/is-number": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz",
+      "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/array-last": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/array-last/-/array-last-1.3.0.tgz",
+      "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==",
+      "dev": true,
+      "dependencies": {
+        "is-number": "^4.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/array-last/node_modules/is-number": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz",
+      "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/array-slice": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz",
+      "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/array-sort": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/array-sort/-/array-sort-1.0.0.tgz",
+      "integrity": "sha512-ihLeJkonmdiAsD7vpgN3CRcx2J2S0TiYW+IS/5zHBI7mKUq3ySvBdzzBfD236ubDBQFiiyG3SWCPc+msQ9KoYg==",
+      "dev": true,
+      "dependencies": {
+        "default-compare": "^1.0.0",
+        "get-value": "^2.0.6",
+        "kind-of": "^5.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/array-unique": {
+      "version": "0.3.2",
+      "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
+      "integrity": "sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/asn1.js": {
+      "version": "4.10.1",
+      "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz",
+      "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==",
+      "dev": true,
+      "dependencies": {
+        "bn.js": "^4.0.0",
+        "inherits": "^2.0.1",
+        "minimalistic-assert": "^1.0.0"
+      }
+    },
+    "node_modules/assert": {
+      "version": "1.4.1",
+      "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz",
+      "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=",
+      "dev": true,
+      "dependencies": {
+        "util": "0.10.3"
+      }
+    },
+    "node_modules/assert/node_modules/inherits": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
+      "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=",
+      "dev": true
+    },
+    "node_modules/assert/node_modules/util": {
+      "version": "0.10.3",
+      "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
+      "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
+      "dev": true,
+      "dependencies": {
+        "inherits": "2.0.1"
+      }
+    },
+    "node_modules/assign-symbols": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
+      "integrity": "sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/async-done": {
+      "version": "1.3.2",
+      "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.2.tgz",
+      "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==",
+      "dev": true,
+      "dependencies": {
+        "end-of-stream": "^1.1.0",
+        "once": "^1.3.2",
+        "process-nextick-args": "^2.0.0",
+        "stream-exhaust": "^1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/async-done/node_modules/process-nextick-args": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
+      "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
+      "dev": true
+    },
+    "node_modules/async-each": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz",
+      "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==",
+      "dev": true
+    },
+    "node_modules/async-settle": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/async-settle/-/async-settle-1.0.0.tgz",
+      "integrity": "sha512-VPXfB4Vk49z1LHHodrEQ6Xf7W4gg1w0dAPROHngx7qgDjqmIQ+fXmwgGXTW/ITLai0YLSvWepJOP9EVpMnEAcw==",
+      "dev": true,
+      "dependencies": {
+        "async-done": "^1.2.2"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/atob": {
+      "version": "2.1.2",
+      "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
+      "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==",
+      "dev": true,
+      "bin": {
+        "atob": "bin/atob.js"
+      },
+      "engines": {
+        "node": ">= 4.5.0"
+      }
+    },
+    "node_modules/bach": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz",
+      "integrity": "sha512-bZOOfCb3gXBXbTFXq3OZtGR88LwGeJvzu6szttaIzymOTS4ZttBNOWSv7aLZja2EMycKtRYV0Oa8SNKH/zkxvg==",
+      "dev": true,
+      "dependencies": {
+        "arr-filter": "^1.1.1",
+        "arr-flatten": "^1.0.1",
+        "arr-map": "^2.0.0",
+        "array-each": "^1.0.0",
+        "array-initial": "^1.0.0",
+        "array-last": "^1.1.1",
+        "async-done": "^1.2.2",
+        "async-settle": "^1.0.0",
+        "now-and-later": "^2.0.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/balanced-match": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
+      "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+      "dev": true
+    },
+    "node_modules/base": {
+      "version": "0.11.2",
+      "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz",
+      "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==",
+      "dev": true,
+      "dependencies": {
+        "cache-base": "^1.0.1",
+        "class-utils": "^0.3.5",
+        "component-emitter": "^1.2.1",
+        "define-property": "^1.0.0",
+        "isobject": "^3.0.1",
+        "mixin-deep": "^1.2.0",
+        "pascalcase": "^0.1.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/base/node_modules/define-property": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
+      "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==",
+      "dev": true,
+      "dependencies": {
+        "is-descriptor": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/base64-js": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
+      "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==",
+      "dev": true
+    },
+    "node_modules/binary-extensions": {
+      "version": "1.13.1",
+      "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz",
+      "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/bindings": {
+      "version": "1.5.0",
+      "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
+      "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
+      "dev": true,
+      "optional": true,
+      "dependencies": {
+        "file-uri-to-path": "1.0.0"
+      }
+    },
+    "node_modules/bl": {
+      "version": "1.2.3",
+      "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz",
+      "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==",
+      "dev": true,
+      "dependencies": {
+        "readable-stream": "^2.3.5",
+        "safe-buffer": "^5.1.1"
+      }
+    },
+    "node_modules/bn.js": {
+      "version": "4.12.0",
+      "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
+      "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==",
+      "dev": true
+    },
+    "node_modules/brace-expansion": {
+      "version": "1.1.8",
+      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
+      "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
+      "dev": true,
+      "dependencies": {
+        "balanced-match": "^1.0.0",
+        "concat-map": "0.0.1"
+      }
+    },
+    "node_modules/braces": {
+      "version": "2.3.2",
+      "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz",
+      "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==",
+      "dev": true,
+      "dependencies": {
+        "arr-flatten": "^1.1.0",
+        "array-unique": "^0.3.2",
+        "extend-shallow": "^2.0.1",
+        "fill-range": "^4.0.0",
+        "isobject": "^3.0.1",
+        "repeat-element": "^1.1.2",
+        "snapdragon": "^0.8.1",
+        "snapdragon-node": "^2.0.1",
+        "split-string": "^3.0.2",
+        "to-regex": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/brorand": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
+      "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
+      "dev": true
+    },
+    "node_modules/browser-pack": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz",
+      "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==",
+      "dev": true,
+      "dependencies": {
+        "combine-source-map": "~0.8.0",
+        "defined": "^1.0.0",
+        "JSONStream": "^1.0.3",
+        "safe-buffer": "^5.1.1",
+        "through2": "^2.0.0",
+        "umd": "^3.0.0"
+      },
+      "bin": {
+        "browser-pack": "bin/cmd.js"
+      }
+    },
+    "node_modules/browser-resolve": {
+      "version": "1.11.3",
+      "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz",
+      "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==",
+      "dev": true,
+      "dependencies": {
+        "resolve": "1.1.7"
+      }
+    },
+    "node_modules/browser-resolve/node_modules/resolve": {
+      "version": "1.1.7",
+      "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz",
+      "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=",
+      "dev": true
+    },
+    "node_modules/browserify": {
+      "version": "14.5.0",
+      "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.5.0.tgz",
+      "integrity": "sha512-gKfOsNQv/toWz+60nSPfYzuwSEdzvV2WdxrVPUbPD/qui44rAkB3t3muNtmmGYHqrG56FGwX9SUEQmzNLAeS7g==",
+      "dev": true,
+      "dependencies": {
+        "assert": "^1.4.0",
+        "browser-pack": "^6.0.1",
+        "browser-resolve": "^1.11.0",
+        "browserify-zlib": "~0.2.0",
+        "buffer": "^5.0.2",
+        "cached-path-relative": "^1.0.0",
+        "concat-stream": "~1.5.1",
+        "console-browserify": "^1.1.0",
+        "constants-browserify": "~1.0.0",
+        "crypto-browserify": "^3.0.0",
+        "defined": "^1.0.0",
+        "deps-sort": "^2.0.0",
+        "domain-browser": "~1.1.0",
+        "duplexer2": "~0.1.2",
+        "events": "~1.1.0",
+        "glob": "^7.1.0",
+        "has": "^1.0.0",
+        "htmlescape": "^1.1.0",
+        "https-browserify": "^1.0.0",
+        "inherits": "~2.0.1",
+        "insert-module-globals": "^7.0.0",
+        "JSONStream": "^1.0.3",
+        "labeled-stream-splicer": "^2.0.0",
+        "module-deps": "^4.0.8",
+        "os-browserify": "~0.3.0",
+        "parents": "^1.0.1",
+        "path-browserify": "~0.0.0",
+        "process": "~0.11.0",
+        "punycode": "^1.3.2",
+        "querystring-es3": "~0.2.0",
+        "read-only-stream": "^2.0.0",
+        "readable-stream": "^2.0.2",
+        "resolve": "^1.1.4",
+        "shasum": "^1.0.0",
+        "shell-quote": "^1.6.1",
+        "stream-browserify": "^2.0.0",
+        "stream-http": "^2.0.0",
+        "string_decoder": "~1.0.0",
+        "subarg": "^1.0.0",
+        "syntax-error": "^1.1.1",
+        "through2": "^2.0.0",
+        "timers-browserify": "^1.0.1",
+        "tty-browserify": "~0.0.0",
+        "url": "~0.11.0",
+        "util": "~0.10.1",
+        "vm-browserify": "~0.0.1",
+        "xtend": "^4.0.0"
+      },
+      "bin": {
+        "browserify": "bin/cmd.js"
+      }
+    },
+    "node_modules/browserify-aes": {
+      "version": "1.2.0",
+      "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
+      "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
+      "dev": true,
+      "dependencies": {
+        "buffer-xor": "^1.0.3",
+        "cipher-base": "^1.0.0",
+        "create-hash": "^1.1.0",
+        "evp_bytestokey": "^1.0.3",
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.0.1"
+      }
+    },
+    "node_modules/browserify-cipher": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz",
+      "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==",
+      "dev": true,
+      "dependencies": {
+        "browserify-aes": "^1.0.4",
+        "browserify-des": "^1.0.0",
+        "evp_bytestokey": "^1.0.0"
+      }
+    },
+    "node_modules/browserify-des": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz",
+      "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==",
+      "dev": true,
+      "dependencies": {
+        "cipher-base": "^1.0.1",
+        "des.js": "^1.0.0",
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.1.2"
+      }
+    },
+    "node_modules/browserify-des/node_modules/safe-buffer": {
+      "version": "5.1.2",
+      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+      "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+      "dev": true
+    },
+    "node_modules/browserify-rsa": {
+      "version": "4.0.1",
+      "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
+      "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
+      "dev": true,
+      "dependencies": {
+        "bn.js": "^4.1.0",
+        "randombytes": "^2.0.1"
+      }
+    },
+    "node_modules/browserify-sign": {
+      "version": "4.0.4",
+      "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz",
+      "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=",
+      "dev": true,
+      "dependencies": {
+        "bn.js": "^4.1.1",
+        "browserify-rsa": "^4.0.0",
+        "create-hash": "^1.1.0",
+        "create-hmac": "^1.1.2",
+        "elliptic": "^6.0.0",
+        "inherits": "^2.0.1",
+        "parse-asn1": "^5.0.0"
+      }
+    },
+    "node_modules/browserify-zlib": {
+      "version": "0.2.0",
+      "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz",
+      "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==",
+      "dev": true,
+      "dependencies": {
+        "pako": "~1.0.5"
+      }
+    },
+    "node_modules/buffer": {
+      "version": "5.2.1",
+      "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz",
+      "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==",
+      "dev": true,
+      "dependencies": {
+        "base64-js": "^1.0.2",
+        "ieee754": "^1.1.4"
+      }
+    },
+    "node_modules/buffer-equal": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz",
+      "integrity": "sha512-tcBWO2Dl4e7Asr9hTGcpVrCe+F7DubpmqWCTbj4FHLmjqO2hIaC383acQubWtRJhdceqs5uBHs6Es+Sk//RKiQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/buffer-from": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
+      "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
+      "dev": true
+    },
+    "node_modules/buffer-xor": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
+      "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
+      "dev": true
+    },
+    "node_modules/builtin-status-codes": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz",
+      "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=",
+      "dev": true
+    },
+    "node_modules/cache-base": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
+      "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==",
+      "dev": true,
+      "dependencies": {
+        "collection-visit": "^1.0.0",
+        "component-emitter": "^1.2.1",
+        "get-value": "^2.0.6",
+        "has-value": "^1.0.0",
+        "isobject": "^3.0.1",
+        "set-value": "^2.0.0",
+        "to-object-path": "^0.3.0",
+        "union-value": "^1.0.0",
+        "unset-value": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/cached-path-relative": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.1.0.tgz",
+      "integrity": "sha512-WF0LihfemtesFcJgO7xfOoOcnWzY/QHR4qeDqV44jPU3HTI54+LnfXK3SA27AVVGCdZFgjjFFaqUA9Jx7dMJZA==",
+      "dev": true
+    },
+    "node_modules/call-bind": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
+      "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
+      "dev": true,
+      "dependencies": {
+        "function-bind": "^1.1.1",
+        "get-intrinsic": "^1.0.2"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/camelcase": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz",
+      "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/chokidar": {
+      "version": "2.1.8",
+      "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",
+      "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==",
+      "deprecated": "Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies",
+      "dev": true,
+      "dependencies": {
+        "anymatch": "^2.0.0",
+        "async-each": "^1.0.1",
+        "braces": "^2.3.2",
+        "glob-parent": "^3.1.0",
+        "inherits": "^2.0.3",
+        "is-binary-path": "^1.0.0",
+        "is-glob": "^4.0.0",
+        "normalize-path": "^3.0.0",
+        "path-is-absolute": "^1.0.0",
+        "readdirp": "^2.2.1",
+        "upath": "^1.1.1"
+      },
+      "optionalDependencies": {
+        "fsevents": "^1.2.7"
+      }
+    },
+    "node_modules/chokidar/node_modules/normalize-path": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
+      "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/cipher-base": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
+      "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.0.1"
+      }
+    },
+    "node_modules/class-utils": {
+      "version": "0.3.6",
+      "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",
+      "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==",
+      "dev": true,
+      "dependencies": {
+        "arr-union": "^3.1.0",
+        "define-property": "^0.2.5",
+        "isobject": "^3.0.0",
+        "static-extend": "^0.1.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/class-utils/node_modules/define-property": {
+      "version": "0.2.5",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+      "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+      "dev": true,
+      "dependencies": {
+        "is-descriptor": "^0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/class-utils/node_modules/is-accessor-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+      "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/class-utils/node_modules/is-accessor-descriptor/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/class-utils/node_modules/is-data-descriptor": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+      "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/class-utils/node_modules/is-data-descriptor/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/class-utils/node_modules/is-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+      "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+      "dev": true,
+      "dependencies": {
+        "is-accessor-descriptor": "^0.1.6",
+        "is-data-descriptor": "^0.1.4",
+        "kind-of": "^5.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/cliui": {
+      "version": "3.2.0",
+      "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
+      "integrity": "sha512-0yayqDxWQbqk3ojkYqUKqaAQ6AfNKeKWRNA8kR0WXzAsdHpP4BIaOmMAG87JGuO6qcobyW4GjxHd9PmhEd+T9w==",
+      "dev": true,
+      "dependencies": {
+        "string-width": "^1.0.1",
+        "strip-ansi": "^3.0.1",
+        "wrap-ansi": "^2.0.0"
+      }
+    },
+    "node_modules/clone-buffer": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz",
+      "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/cloneable-readable": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.2.tgz",
+      "integrity": "sha512-Bq6+4t+lbM8vhTs/Bef5c5AdEMtapp/iFb6+s4/Hh9MVTt8OLKH7ZOOZSCT+Ys7hsHvqv0GuMPJ1lnQJVHvxpg==",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.1",
+        "process-nextick-args": "^2.0.0",
+        "readable-stream": "^2.3.5"
+      }
+    },
+    "node_modules/cloneable-readable/node_modules/process-nextick-args": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
+      "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
+      "dev": true
+    },
+    "node_modules/code-point-at": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
+      "integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/collection-map": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/collection-map/-/collection-map-1.0.0.tgz",
+      "integrity": "sha512-5D2XXSpkOnleOI21TG7p3T0bGAsZ/XknZpKBmGYyluO8pw4zA3K8ZlrBIbC4FXg3m6z/RNFiUFfT2sQK01+UHA==",
+      "dev": true,
+      "dependencies": {
+        "arr-map": "^2.0.2",
+        "for-own": "^1.0.0",
+        "make-iterator": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/collection-visit": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
+      "integrity": "sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==",
+      "dev": true,
+      "dependencies": {
+        "map-visit": "^1.0.0",
+        "object-visit": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/color-support": {
+      "version": "1.1.3",
+      "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
+      "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==",
+      "dev": true,
+      "bin": {
+        "color-support": "bin.js"
+      }
+    },
+    "node_modules/combine-source-map": {
+      "version": "0.8.0",
+      "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz",
+      "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=",
+      "dev": true,
+      "dependencies": {
+        "convert-source-map": "~1.1.0",
+        "inline-source-map": "~0.6.0",
+        "lodash.memoize": "~3.0.3",
+        "source-map": "~0.5.3"
+      }
+    },
+    "node_modules/commander": {
+      "version": "2.17.1",
+      "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz",
+      "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==",
+      "dev": true
+    },
+    "node_modules/component-emitter": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz",
+      "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==",
+      "dev": true
+    },
+    "node_modules/concat-map": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+      "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+      "dev": true
+    },
+    "node_modules/concat-stream": {
+      "version": "1.5.2",
+      "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz",
+      "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=",
+      "dev": true,
+      "engines": [
+        "node >= 0.8"
+      ],
+      "dependencies": {
+        "inherits": "~2.0.1",
+        "readable-stream": "~2.0.0",
+        "typedarray": "~0.0.5"
+      }
+    },
+    "node_modules/concat-stream/node_modules/readable-stream": {
+      "version": "2.0.6",
+      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz",
+      "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=",
+      "dev": true,
+      "dependencies": {
+        "core-util-is": "~1.0.0",
+        "inherits": "~2.0.1",
+        "isarray": "~1.0.0",
+        "process-nextick-args": "~1.0.6",
+        "string_decoder": "~0.10.x",
+        "util-deprecate": "~1.0.1"
+      }
+    },
+    "node_modules/concat-stream/node_modules/string_decoder": {
+      "version": "0.10.31",
+      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+      "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+      "dev": true
+    },
+    "node_modules/console-browserify": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",
+      "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=",
+      "dev": true,
+      "dependencies": {
+        "date-now": "^0.1.4"
+      }
+    },
+    "node_modules/constants-browserify": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz",
+      "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=",
+      "dev": true
+    },
+    "node_modules/convert-source-map": {
+      "version": "1.1.3",
+      "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz",
+      "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=",
+      "dev": true
+    },
+    "node_modules/copy-descriptor": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
+      "integrity": "sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/copy-props": {
+      "version": "2.0.5",
+      "resolved": "https://registry.npmjs.org/copy-props/-/copy-props-2.0.5.tgz",
+      "integrity": "sha512-XBlx8HSqrT0ObQwmSzM7WE5k8FxTV75h1DX1Z3n6NhQ/UYYAvInWYmG06vFt7hQZArE2fuO62aihiWIVQwh1sw==",
+      "dev": true,
+      "dependencies": {
+        "each-props": "^1.3.2",
+        "is-plain-object": "^5.0.0"
+      }
+    },
+    "node_modules/core-util-is": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+      "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
+      "dev": true
+    },
+    "node_modules/create-ecdh": {
+      "version": "4.0.3",
+      "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz",
+      "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==",
+      "dev": true,
+      "dependencies": {
+        "bn.js": "^4.1.0",
+        "elliptic": "^6.0.0"
+      }
+    },
+    "node_modules/create-hash": {
+      "version": "1.2.0",
+      "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
+      "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
+      "dev": true,
+      "dependencies": {
+        "cipher-base": "^1.0.1",
+        "inherits": "^2.0.1",
+        "md5.js": "^1.3.4",
+        "ripemd160": "^2.0.1",
+        "sha.js": "^2.4.0"
+      }
+    },
+    "node_modules/create-hmac": {
+      "version": "1.1.7",
+      "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
+      "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
+      "dev": true,
+      "dependencies": {
+        "cipher-base": "^1.0.3",
+        "create-hash": "^1.1.0",
+        "inherits": "^2.0.1",
+        "ripemd160": "^2.0.0",
+        "safe-buffer": "^5.0.1",
+        "sha.js": "^2.4.8"
+      }
+    },
+    "node_modules/crypto-browserify": {
+      "version": "3.12.0",
+      "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz",
+      "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==",
+      "dev": true,
+      "dependencies": {
+        "browserify-cipher": "^1.0.0",
+        "browserify-sign": "^4.0.0",
+        "create-ecdh": "^4.0.0",
+        "create-hash": "^1.1.0",
+        "create-hmac": "^1.1.0",
+        "diffie-hellman": "^5.0.0",
+        "inherits": "^2.0.1",
+        "pbkdf2": "^3.0.3",
+        "public-encrypt": "^4.0.0",
+        "randombytes": "^2.0.0",
+        "randomfill": "^1.0.3"
+      },
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/css": {
+      "version": "2.2.4",
+      "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz",
+      "integrity": "sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.3",
+        "source-map": "^0.6.1",
+        "source-map-resolve": "^0.5.2",
+        "urix": "^0.1.0"
+      }
+    },
+    "node_modules/css/node_modules/source-map": {
+      "version": "0.6.1",
+      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+      "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/d": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz",
+      "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=",
+      "dev": true,
+      "dependencies": {
+        "es5-ext": "^0.10.9"
+      }
+    },
+    "node_modules/date-now": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
+      "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=",
+      "dev": true
+    },
+    "node_modules/debug": {
+      "version": "2.6.9",
+      "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+      "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+      "dev": true,
+      "dependencies": {
+        "ms": "2.0.0"
+      }
+    },
+    "node_modules/debug-fabulous": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/debug-fabulous/-/debug-fabulous-1.1.0.tgz",
+      "integrity": "sha512-GZqvGIgKNlUnHUPQhepnUZFIMoi3dgZKQBzKDeL2g7oJF9SNAji/AAu36dusFUas0O+pae74lNeoIPHqXWDkLg==",
+      "dev": true,
+      "dependencies": {
+        "debug": "3.X",
+        "memoizee": "0.4.X",
+        "object-assign": "4.X"
+      }
+    },
+    "node_modules/debug-fabulous/node_modules/debug": {
+      "version": "3.2.6",
+      "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
+      "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
+      "dev": true,
+      "dependencies": {
+        "ms": "^2.1.1"
+      }
+    },
+    "node_modules/debug-fabulous/node_modules/ms": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
+      "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==",
+      "dev": true
+    },
+    "node_modules/decamelize": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
+      "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/decode-uri-component": {
+      "version": "0.2.0",
+      "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
+      "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10"
+      }
+    },
+    "node_modules/default-compare": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz",
+      "integrity": "sha512-QWfXlM0EkAbqOCbD/6HjdwT19j7WCkMyiRhWilc4H9/5h/RzTF9gv5LYh1+CmDV5d1rki6KAWLtQale0xt20eQ==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^5.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/default-resolution": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/default-resolution/-/default-resolution-2.0.0.tgz",
+      "integrity": "sha512-2xaP6GiwVwOEbXCGoJ4ufgC76m8cj805jrghScewJC2ZDsb9U0b4BIrba+xt/Uytyd0HvQ6+WymSRTfnYj59GQ==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/define-properties": {
+      "version": "1.1.4",
+      "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz",
+      "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==",
+      "dev": true,
+      "dependencies": {
+        "has-property-descriptors": "^1.0.0",
+        "object-keys": "^1.1.1"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/define-property": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz",
+      "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==",
+      "dev": true,
+      "dependencies": {
+        "is-descriptor": "^1.0.2",
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/defined": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz",
+      "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
+      "dev": true
+    },
+    "node_modules/deps-sort": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz",
+      "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=",
+      "dev": true,
+      "dependencies": {
+        "JSONStream": "^1.0.3",
+        "shasum": "^1.0.0",
+        "subarg": "^1.0.0",
+        "through2": "^2.0.0"
+      },
+      "bin": {
+        "deps-sort": "bin/cmd.js"
+      }
+    },
+    "node_modules/des.js": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz",
+      "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.1",
+        "minimalistic-assert": "^1.0.0"
+      }
+    },
+    "node_modules/detect-file": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz",
+      "integrity": "sha512-DtCOLG98P007x7wiiOmfI0fi3eIKyWiLTGJ2MDnVi/E04lWGbf+JzrRHMm0rgIIZJGtHpKpbVgLWHrv8xXpc3Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/detect-newline": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz",
+      "integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/detective": {
+      "version": "4.7.1",
+      "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz",
+      "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==",
+      "dev": true,
+      "dependencies": {
+        "acorn": "^5.2.1",
+        "defined": "^1.0.0"
+      }
+    },
+    "node_modules/detective/node_modules/acorn": {
+      "version": "5.7.4",
+      "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
+      "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
+      "dev": true,
+      "bin": {
+        "acorn": "bin/acorn"
+      },
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/diffie-hellman": {
+      "version": "5.0.3",
+      "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
+      "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
+      "dev": true,
+      "dependencies": {
+        "bn.js": "^4.1.0",
+        "miller-rabin": "^4.0.0",
+        "randombytes": "^2.0.0"
+      }
+    },
+    "node_modules/domain-browser": {
+      "version": "1.1.7",
+      "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz",
+      "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.4",
+        "npm": ">=1.2"
+      }
+    },
+    "node_modules/duplexer2": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
+      "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=",
+      "dev": true,
+      "dependencies": {
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "node_modules/duplexify": {
+      "version": "3.7.1",
+      "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz",
+      "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==",
+      "dev": true,
+      "dependencies": {
+        "end-of-stream": "^1.0.0",
+        "inherits": "^2.0.1",
+        "readable-stream": "^2.0.0",
+        "stream-shift": "^1.0.0"
+      }
+    },
+    "node_modules/each-props": {
+      "version": "1.3.2",
+      "resolved": "https://registry.npmjs.org/each-props/-/each-props-1.3.2.tgz",
+      "integrity": "sha512-vV0Hem3zAGkJAyU7JSjixeU66rwdynTAa1vofCrSA5fEln+m67Az9CcnkVD776/fsN/UjIWmBDoNRS6t6G9RfA==",
+      "dev": true,
+      "dependencies": {
+        "is-plain-object": "^2.0.1",
+        "object.defaults": "^1.1.0"
+      }
+    },
+    "node_modules/each-props/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/elliptic": {
+      "version": "6.5.4",
+      "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
+      "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
+      "dev": true,
+      "dependencies": {
+        "bn.js": "^4.11.9",
+        "brorand": "^1.1.0",
+        "hash.js": "^1.0.0",
+        "hmac-drbg": "^1.0.1",
+        "inherits": "^2.0.4",
+        "minimalistic-assert": "^1.0.1",
+        "minimalistic-crypto-utils": "^1.0.1"
+      }
+    },
+    "node_modules/elliptic/node_modules/inherits": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+      "dev": true
+    },
+    "node_modules/end-of-stream": {
+      "version": "1.4.4",
+      "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
+      "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
+      "dev": true,
+      "dependencies": {
+        "once": "^1.4.0"
+      }
+    },
+    "node_modules/error-ex": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz",
+      "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=",
+      "dev": true,
+      "dependencies": {
+        "is-arrayish": "^0.2.1"
+      }
+    },
+    "node_modules/es5-ext": {
+      "version": "0.10.30",
+      "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.30.tgz",
+      "integrity": "sha1-cUGhaDZpfbq/qq7uQUlc4p9SyTk=",
+      "dev": true,
+      "dependencies": {
+        "es6-iterator": "2",
+        "es6-symbol": "~3.1"
+      }
+    },
+    "node_modules/es6-iterator": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz",
+      "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=",
+      "dev": true,
+      "dependencies": {
+        "d": "1",
+        "es5-ext": "^0.10.14",
+        "es6-symbol": "^3.1"
+      }
+    },
+    "node_modules/es6-symbol": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz",
+      "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=",
+      "dev": true,
+      "dependencies": {
+        "d": "1",
+        "es5-ext": "~0.10.14"
+      }
+    },
+    "node_modules/es6-weak-map": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz",
+      "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=",
+      "dev": true,
+      "dependencies": {
+        "d": "1",
+        "es5-ext": "^0.10.14",
+        "es6-iterator": "^2.0.1",
+        "es6-symbol": "^3.1.1"
+      }
+    },
+    "node_modules/event-emitter": {
+      "version": "0.3.5",
+      "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
+      "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=",
+      "dev": true,
+      "dependencies": {
+        "d": "1",
+        "es5-ext": "~0.10.14"
+      }
+    },
+    "node_modules/events": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
+      "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.4.x"
+      }
+    },
+    "node_modules/evp_bytestokey": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz",
+      "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==",
+      "dev": true,
+      "dependencies": {
+        "md5.js": "^1.3.4",
+        "safe-buffer": "^5.1.1"
+      }
+    },
+    "node_modules/expand-brackets": {
+      "version": "2.1.4",
+      "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz",
+      "integrity": "sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==",
+      "dev": true,
+      "dependencies": {
+        "debug": "^2.3.3",
+        "define-property": "^0.2.5",
+        "extend-shallow": "^2.0.1",
+        "posix-character-classes": "^0.1.0",
+        "regex-not": "^1.0.0",
+        "snapdragon": "^0.8.1",
+        "to-regex": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/expand-brackets/node_modules/define-property": {
+      "version": "0.2.5",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+      "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+      "dev": true,
+      "dependencies": {
+        "is-descriptor": "^0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/expand-brackets/node_modules/is-accessor-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+      "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/expand-brackets/node_modules/is-accessor-descriptor/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/expand-brackets/node_modules/is-data-descriptor": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+      "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/expand-brackets/node_modules/is-data-descriptor/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/expand-brackets/node_modules/is-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+      "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+      "dev": true,
+      "dependencies": {
+        "is-accessor-descriptor": "^0.1.6",
+        "is-data-descriptor": "^0.1.4",
+        "kind-of": "^5.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/expand-tilde": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz",
+      "integrity": "sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==",
+      "dev": true,
+      "dependencies": {
+        "homedir-polyfill": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/extend": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
+      "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
+      "dev": true
+    },
+    "node_modules/extend-shallow": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+      "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==",
+      "dev": true,
+      "dependencies": {
+        "is-extendable": "^0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/extglob": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz",
+      "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==",
+      "dev": true,
+      "dependencies": {
+        "array-unique": "^0.3.2",
+        "define-property": "^1.0.0",
+        "expand-brackets": "^2.1.4",
+        "extend-shallow": "^2.0.1",
+        "fragment-cache": "^0.2.1",
+        "regex-not": "^1.0.0",
+        "snapdragon": "^0.8.1",
+        "to-regex": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/extglob/node_modules/define-property": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
+      "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==",
+      "dev": true,
+      "dependencies": {
+        "is-descriptor": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/fancy-log": {
+      "version": "1.3.3",
+      "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz",
+      "integrity": "sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw==",
+      "dev": true,
+      "dependencies": {
+        "ansi-gray": "^0.1.1",
+        "color-support": "^1.1.3",
+        "parse-node-version": "^1.0.0",
+        "time-stamp": "^1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/fast-levenshtein": {
+      "version": "1.1.4",
+      "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz",
+      "integrity": "sha512-Ia0sQNrMPXXkqVFt6w6M1n1oKo3NfKs+mvaV811Jwir7vAk9a6PVV9VPYf6X3BU97QiLEmuW3uXH9u87zDFfdw==",
+      "dev": true
+    },
+    "node_modules/file-uri-to-path": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
+      "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
+      "dev": true,
+      "optional": true
+    },
+    "node_modules/fill-range": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz",
+      "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==",
+      "dev": true,
+      "dependencies": {
+        "extend-shallow": "^2.0.1",
+        "is-number": "^3.0.0",
+        "repeat-string": "^1.6.1",
+        "to-regex-range": "^2.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/find-up": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
+      "integrity": "sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==",
+      "dev": true,
+      "dependencies": {
+        "path-exists": "^2.0.0",
+        "pinkie-promise": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/findup-sync": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz",
+      "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==",
+      "dev": true,
+      "dependencies": {
+        "detect-file": "^1.0.0",
+        "is-glob": "^4.0.0",
+        "micromatch": "^3.0.4",
+        "resolve-dir": "^1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/fined": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz",
+      "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==",
+      "dev": true,
+      "dependencies": {
+        "expand-tilde": "^2.0.2",
+        "is-plain-object": "^2.0.3",
+        "object.defaults": "^1.1.0",
+        "object.pick": "^1.2.0",
+        "parse-filepath": "^1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/fined/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/flagged-respawn": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz",
+      "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/flush-write-stream": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz",
+      "integrity": "sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w==",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.3",
+        "readable-stream": "^2.3.6"
+      }
+    },
+    "node_modules/for-in": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
+      "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/for-own": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz",
+      "integrity": "sha512-0OABksIGrxKK8K4kynWkQ7y1zounQxP+CWnyclVwj81KW3vlLlGUx57DKGcP/LH216GzqnstnPocF16Nxs0Ycg==",
+      "dev": true,
+      "dependencies": {
+        "for-in": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/fragment-cache": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
+      "integrity": "sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==",
+      "dev": true,
+      "dependencies": {
+        "map-cache": "^0.2.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/fs-mkdirp-stream": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz",
+      "integrity": "sha512-+vSd9frUnapVC2RZYfL3FCB2p3g4TBhaUmrsWlSudsGdnxIuUvBB2QM1VZeBtc49QFwrp+wQLrDs3+xxDgI5gQ==",
+      "dev": true,
+      "dependencies": {
+        "graceful-fs": "^4.1.11",
+        "through2": "^2.0.3"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/fs.realpath": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+      "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
+      "dev": true
+    },
+    "node_modules/fsevents": {
+      "version": "1.2.13",
+      "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
+      "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
+      "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.",
+      "dev": true,
+      "hasInstallScript": true,
+      "optional": true,
+      "os": [
+        "darwin"
+      ],
+      "dependencies": {
+        "bindings": "^1.5.0",
+        "nan": "^2.12.1"
+      },
+      "engines": {
+        "node": ">= 4.0"
+      }
+    },
+    "node_modules/function-bind": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
+      "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
+      "dev": true
+    },
+    "node_modules/fuse.js": {
+      "version": "3.3.0",
+      "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-3.3.0.tgz",
+      "integrity": "sha512-ESBRkGLWMuVkapqYCcNO1uqMg5qbCKkgb+VS6wsy17Rix0/cMS9kSOZoYkjH8Ko//pgJ/EEGu0GTjk2mjX2LGQ=="
+    },
+    "node_modules/get-assigned-identifiers": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz",
+      "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==",
+      "dev": true
+    },
+    "node_modules/get-caller-file": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
+      "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==",
+      "dev": true
+    },
+    "node_modules/get-intrinsic": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.2.tgz",
+      "integrity": "sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==",
+      "dev": true,
+      "dependencies": {
+        "function-bind": "^1.1.1",
+        "has": "^1.0.3",
+        "has-symbols": "^1.0.3"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/get-value": {
+      "version": "2.0.6",
+      "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz",
+      "integrity": "sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/glob": {
+      "version": "7.1.3",
+      "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
+      "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
+      "dev": true,
+      "dependencies": {
+        "fs.realpath": "^1.0.0",
+        "inflight": "^1.0.4",
+        "inherits": "2",
+        "minimatch": "^3.0.4",
+        "once": "^1.3.0",
+        "path-is-absolute": "^1.0.0"
+      },
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/glob-parent": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
+      "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==",
+      "dev": true,
+      "dependencies": {
+        "is-glob": "^3.1.0",
+        "path-dirname": "^1.0.0"
+      }
+    },
+    "node_modules/glob-parent/node_modules/is-glob": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz",
+      "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==",
+      "dev": true,
+      "dependencies": {
+        "is-extglob": "^2.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/glob-stream": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz",
+      "integrity": "sha512-uMbLGAP3S2aDOHUDfdoYcdIePUCfysbAd0IAoWVZbeGU/oNQ8asHVSshLDJUPWxfzj8zsCG7/XeHPHTtow0nsw==",
+      "dev": true,
+      "dependencies": {
+        "extend": "^3.0.0",
+        "glob": "^7.1.1",
+        "glob-parent": "^3.1.0",
+        "is-negated-glob": "^1.0.0",
+        "ordered-read-streams": "^1.0.0",
+        "pumpify": "^1.3.5",
+        "readable-stream": "^2.1.5",
+        "remove-trailing-separator": "^1.0.1",
+        "to-absolute-glob": "^2.0.0",
+        "unique-stream": "^2.0.2"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/glob-watcher": {
+      "version": "5.0.5",
+      "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-5.0.5.tgz",
+      "integrity": "sha512-zOZgGGEHPklZNjZQaZ9f41i7F2YwE+tS5ZHrDhbBCk3stwahn5vQxnFmBJZHoYdusR6R1bLSXeGUy/BhctwKzw==",
+      "dev": true,
+      "dependencies": {
+        "anymatch": "^2.0.0",
+        "async-done": "^1.2.0",
+        "chokidar": "^2.0.0",
+        "is-negated-glob": "^1.0.0",
+        "just-debounce": "^1.0.0",
+        "normalize-path": "^3.0.0",
+        "object.defaults": "^1.1.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/glob-watcher/node_modules/normalize-path": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
+      "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/global-modules": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz",
+      "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==",
+      "dev": true,
+      "dependencies": {
+        "global-prefix": "^1.0.1",
+        "is-windows": "^1.0.1",
+        "resolve-dir": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/global-prefix": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz",
+      "integrity": "sha512-5lsx1NUDHtSjfg0eHlmYvZKv8/nVqX4ckFbM+FrGcQ+04KWcWFo9P5MxPZYSzUvyzmdTbI7Eix8Q4IbELDqzKg==",
+      "dev": true,
+      "dependencies": {
+        "expand-tilde": "^2.0.2",
+        "homedir-polyfill": "^1.0.1",
+        "ini": "^1.3.4",
+        "is-windows": "^1.0.1",
+        "which": "^1.2.14"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/glogg": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz",
+      "integrity": "sha1-f+DxmfV6yQbPUS/urY+Q7kooT8U=",
+      "dev": true,
+      "dependencies": {
+        "sparkles": "^1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/graceful-fs": {
+      "version": "4.1.11",
+      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
+      "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/gulp": {
+      "version": "4.0.2",
+      "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz",
+      "integrity": "sha512-dvEs27SCZt2ibF29xYgmnwwCYZxdxhQ/+LFWlbAW8y7jt68L/65402Lz3+CKy0Ov4rOs+NERmDq7YlZaDqUIfA==",
+      "dev": true,
+      "dependencies": {
+        "glob-watcher": "^5.0.3",
+        "gulp-cli": "^2.2.0",
+        "undertaker": "^1.2.1",
+        "vinyl-fs": "^3.0.0"
+      },
+      "bin": {
+        "gulp": "bin/gulp.js"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/gulp-cli": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.3.0.tgz",
+      "integrity": "sha512-zzGBl5fHo0EKSXsHzjspp3y5CONegCm8ErO5Qh0UzFzk2y4tMvzLWhoDokADbarfZRL2pGpRp7yt6gfJX4ph7A==",
+      "dev": true,
+      "dependencies": {
+        "ansi-colors": "^1.0.1",
+        "archy": "^1.0.0",
+        "array-sort": "^1.0.0",
+        "color-support": "^1.1.3",
+        "concat-stream": "^1.6.0",
+        "copy-props": "^2.0.1",
+        "fancy-log": "^1.3.2",
+        "gulplog": "^1.0.0",
+        "interpret": "^1.4.0",
+        "isobject": "^3.0.1",
+        "liftoff": "^3.1.0",
+        "matchdep": "^2.0.0",
+        "mute-stdout": "^1.0.0",
+        "pretty-hrtime": "^1.0.0",
+        "replace-homedir": "^1.0.0",
+        "semver-greatest-satisfied-range": "^1.1.0",
+        "v8flags": "^3.2.0",
+        "yargs": "^7.1.0"
+      },
+      "bin": {
+        "gulp": "bin/gulp.js"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/gulp-cli/node_modules/concat-stream": {
+      "version": "1.6.2",
+      "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
+      "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
+      "dev": true,
+      "engines": [
+        "node >= 0.8"
+      ],
+      "dependencies": {
+        "buffer-from": "^1.0.0",
+        "inherits": "^2.0.3",
+        "readable-stream": "^2.2.2",
+        "typedarray": "^0.0.6"
+      }
+    },
+    "node_modules/gulp-sourcemaps": {
+      "version": "2.6.4",
+      "resolved": "https://registry.npmjs.org/gulp-sourcemaps/-/gulp-sourcemaps-2.6.4.tgz",
+      "integrity": "sha1-y7IAhFCxvM5s0jv5gze+dRv24wo=",
+      "dev": true,
+      "dependencies": {
+        "@gulp-sourcemaps/identity-map": "1.X",
+        "@gulp-sourcemaps/map-sources": "1.X",
+        "acorn": "5.X",
+        "convert-source-map": "1.X",
+        "css": "2.X",
+        "debug-fabulous": "1.X",
+        "detect-newline": "2.X",
+        "graceful-fs": "4.X",
+        "source-map": "~0.6.0",
+        "strip-bom-string": "1.X",
+        "through2": "2.X"
+      },
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/gulp-sourcemaps/node_modules/acorn": {
+      "version": "5.7.4",
+      "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
+      "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
+      "dev": true,
+      "bin": {
+        "acorn": "bin/acorn"
+      },
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/gulp-sourcemaps/node_modules/source-map": {
+      "version": "0.6.1",
+      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+      "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/gulp-uglify": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-3.0.1.tgz",
+      "integrity": "sha512-KVffbGY9d4Wv90bW/B1KZJyunLMyfHTBbilpDvmcrj5Go0/a1G3uVpt+1gRBWSw/11dqR3coJ1oWNTt1AiXuWQ==",
+      "dev": true,
+      "dependencies": {
+        "gulplog": "^1.0.0",
+        "has-gulplog": "^0.1.0",
+        "lodash": "^4.13.1",
+        "make-error-cause": "^1.1.1",
+        "safe-buffer": "^5.1.2",
+        "through2": "^2.0.0",
+        "uglify-js": "^3.0.5",
+        "vinyl-sourcemaps-apply": "^0.2.0"
+      }
+    },
+    "node_modules/gulp-uglify/node_modules/safe-buffer": {
+      "version": "5.1.2",
+      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+      "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+      "dev": true
+    },
+    "node_modules/gulplog": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz",
+      "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=",
+      "dev": true,
+      "dependencies": {
+        "glogg": "^1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/has": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
+      "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+      "dev": true,
+      "dependencies": {
+        "function-bind": "^1.1.1"
+      },
+      "engines": {
+        "node": ">= 0.4.0"
+      }
+    },
+    "node_modules/has-gulplog": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz",
+      "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=",
+      "dev": true,
+      "dependencies": {
+        "sparkles": "^1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/has-property-descriptors": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz",
+      "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==",
+      "dev": true,
+      "dependencies": {
+        "get-intrinsic": "^1.1.1"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/has-symbols": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
+      "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/has-value": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz",
+      "integrity": "sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==",
+      "dev": true,
+      "dependencies": {
+        "get-value": "^2.0.6",
+        "has-values": "^1.0.0",
+        "isobject": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/has-values": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz",
+      "integrity": "sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==",
+      "dev": true,
+      "dependencies": {
+        "is-number": "^3.0.0",
+        "kind-of": "^4.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/has-values/node_modules/kind-of": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz",
+      "integrity": "sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/hash-base": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz",
+      "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.0.1"
+      },
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/hash.js": {
+      "version": "1.1.5",
+      "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz",
+      "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.3",
+        "minimalistic-assert": "^1.0.1"
+      }
+    },
+    "node_modules/hmac-drbg": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
+      "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=",
+      "dev": true,
+      "dependencies": {
+        "hash.js": "^1.0.3",
+        "minimalistic-assert": "^1.0.0",
+        "minimalistic-crypto-utils": "^1.0.1"
+      }
+    },
+    "node_modules/homedir-polyfill": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz",
+      "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==",
+      "dev": true,
+      "dependencies": {
+        "parse-passwd": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/hosted-git-info": {
+      "version": "2.8.9",
+      "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
+      "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
+      "dev": true
+    },
+    "node_modules/htmlescape": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz",
+      "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10"
+      }
+    },
+    "node_modules/https-browserify": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
+      "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=",
+      "dev": true
+    },
+    "node_modules/ieee754": {
+      "version": "1.1.12",
+      "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz",
+      "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==",
+      "dev": true
+    },
+    "node_modules/indexof": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
+      "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
+      "dev": true
+    },
+    "node_modules/inflight": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+      "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+      "dev": true,
+      "dependencies": {
+        "once": "^1.3.0",
+        "wrappy": "1"
+      }
+    },
+    "node_modules/inherits": {
+      "version": "2.0.3",
+      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+      "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
+      "dev": true
+    },
+    "node_modules/ini": {
+      "version": "1.3.8",
+      "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
+      "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
+      "dev": true
+    },
+    "node_modules/inline-source-map": {
+      "version": "0.6.2",
+      "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz",
+      "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=",
+      "dev": true,
+      "dependencies": {
+        "source-map": "~0.5.3"
+      }
+    },
+    "node_modules/insert-module-globals": {
+      "version": "7.2.0",
+      "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz",
+      "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==",
+      "dev": true,
+      "dependencies": {
+        "acorn-node": "^1.5.2",
+        "combine-source-map": "^0.8.0",
+        "concat-stream": "^1.6.1",
+        "is-buffer": "^1.1.0",
+        "JSONStream": "^1.0.3",
+        "path-is-absolute": "^1.0.1",
+        "process": "~0.11.0",
+        "through2": "^2.0.0",
+        "undeclared-identifiers": "^1.1.2",
+        "xtend": "^4.0.0"
+      },
+      "bin": {
+        "insert-module-globals": "bin/cmd.js"
+      }
+    },
+    "node_modules/insert-module-globals/node_modules/concat-stream": {
+      "version": "1.6.2",
+      "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
+      "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
+      "dev": true,
+      "engines": [
+        "node >= 0.8"
+      ],
+      "dependencies": {
+        "buffer-from": "^1.0.0",
+        "inherits": "^2.0.3",
+        "readable-stream": "^2.2.2",
+        "typedarray": "^0.0.6"
+      }
+    },
+    "node_modules/interpret": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz",
+      "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/invert-kv": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
+      "integrity": "sha512-xgs2NH9AE66ucSq4cNG1nhSFghr5l6tdL15Pk+jl46bmmBapgoaY/AacXyaDznAqmGL99TiLSQgO/XazFSKYeQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-absolute": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz",
+      "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==",
+      "dev": true,
+      "dependencies": {
+        "is-relative": "^1.0.0",
+        "is-windows": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-accessor-descriptor": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz",
+      "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^6.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-accessor-descriptor/node_modules/kind-of": {
+      "version": "6.0.3",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+      "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-arrayish": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
+      "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=",
+      "dev": true
+    },
+    "node_modules/is-binary-path": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz",
+      "integrity": "sha512-9fRVlXc0uCxEDj1nQzaWONSpbTfx0FmJfzHF7pwlI8DkWGoHBBea4Pg5Ky0ojwwxQmnSifgbKkI06Qv0Ljgj+Q==",
+      "dev": true,
+      "dependencies": {
+        "binary-extensions": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-buffer": {
+      "version": "1.1.5",
+      "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz",
+      "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=",
+      "dev": true
+    },
+    "node_modules/is-core-module": {
+      "version": "2.9.0",
+      "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",
+      "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",
+      "dev": true,
+      "dependencies": {
+        "has": "^1.0.3"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/is-data-descriptor": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz",
+      "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^6.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-data-descriptor/node_modules/kind-of": {
+      "version": "6.0.3",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+      "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-descriptor": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz",
+      "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==",
+      "dev": true,
+      "dependencies": {
+        "is-accessor-descriptor": "^1.0.0",
+        "is-data-descriptor": "^1.0.0",
+        "kind-of": "^6.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-descriptor/node_modules/kind-of": {
+      "version": "6.0.3",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+      "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-extendable": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
+      "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-extglob": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
+      "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-fullwidth-code-point": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
+      "integrity": "sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==",
+      "dev": true,
+      "dependencies": {
+        "number-is-nan": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-glob": {
+      "version": "4.0.3",
+      "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
+      "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
+      "dev": true,
+      "dependencies": {
+        "is-extglob": "^2.1.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-negated-glob": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz",
+      "integrity": "sha512-czXVVn/QEmgvej1f50BZ648vUI+em0xqMq2Sn+QncCLN4zj1UAxlT+kw/6ggQTOaZPd1HqKQGEqbpQVtJucWug==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-number": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
+      "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-number/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-plain-object": {
+      "version": "5.0.0",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
+      "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-promise": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz",
+      "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
+      "dev": true
+    },
+    "node_modules/is-relative": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz",
+      "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==",
+      "dev": true,
+      "dependencies": {
+        "is-unc-path": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-unc-path": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz",
+      "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==",
+      "dev": true,
+      "dependencies": {
+        "unc-path-regex": "^0.1.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-utf8": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
+      "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
+      "dev": true
+    },
+    "node_modules/is-valid-glob": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-1.0.0.tgz",
+      "integrity": "sha512-AhiROmoEFDSsjx8hW+5sGwgKVIORcXnrlAx/R0ZSeaPw70Vw0CqkGBBhHGL58Uox2eXnU1AnvXJl1XlyedO5bA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-windows": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz",
+      "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/isarray": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+      "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
+      "dev": true
+    },
+    "node_modules/isexe": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+      "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
+      "dev": true
+    },
+    "node_modules/isobject": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
+      "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/json-stable-stringify": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz",
+      "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=",
+      "dev": true,
+      "dependencies": {
+        "jsonify": "~0.0.0"
+      }
+    },
+    "node_modules/json-stable-stringify-without-jsonify": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
+      "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
+      "dev": true
+    },
+    "node_modules/jsonify": {
+      "version": "0.0.0",
+      "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
+      "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
+      "dev": true
+    },
+    "node_modules/jsonparse": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
+      "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=",
+      "dev": true,
+      "engines": [
+        "node >= 0.2.0"
+      ]
+    },
+    "node_modules/JSONStream": {
+      "version": "1.3.5",
+      "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
+      "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==",
+      "dev": true,
+      "dependencies": {
+        "jsonparse": "^1.2.0",
+        "through": ">=2.2.7 <3"
+      },
+      "bin": {
+        "JSONStream": "bin.js"
+      },
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/just-debounce": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.1.0.tgz",
+      "integrity": "sha512-qpcRocdkUmf+UTNBYx5w6dexX5J31AKK1OmPwH630a83DdVVUIngk55RSAiIGpQyoH0dlr872VHfPjnQnK1qDQ==",
+      "dev": true
+    },
+    "node_modules/kind-of": {
+      "version": "5.1.0",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz",
+      "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/labeled-stream-splicer": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz",
+      "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.1",
+        "isarray": "^2.0.4",
+        "stream-splicer": "^2.0.0"
+      }
+    },
+    "node_modules/labeled-stream-splicer/node_modules/isarray": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz",
+      "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==",
+      "dev": true
+    },
+    "node_modules/last-run": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz",
+      "integrity": "sha512-U/VxvpX4N/rFvPzr3qG5EtLKEnNI0emvIQB3/ecEwv+8GHaUKbIB8vxv1Oai5FAF0d0r7LXHhLLe5K/yChm5GQ==",
+      "dev": true,
+      "dependencies": {
+        "default-resolution": "^2.0.0",
+        "es6-weak-map": "^2.0.1"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/lazystream": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.1.tgz",
+      "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==",
+      "dev": true,
+      "dependencies": {
+        "readable-stream": "^2.0.5"
+      },
+      "engines": {
+        "node": ">= 0.6.3"
+      }
+    },
+    "node_modules/lcid": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
+      "integrity": "sha512-YiGkH6EnGrDGqLMITnGjXtGmNtjoXw9SVUzcaos8RBi7Ps0VBylkq+vOcY9QE5poLasPCR849ucFUkl0UzUyOw==",
+      "dev": true,
+      "dependencies": {
+        "invert-kv": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/lead": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/lead/-/lead-1.0.0.tgz",
+      "integrity": "sha512-IpSVCk9AYvLHo5ctcIXxOBpMWUe+4TKN3VPWAKUbJikkmsGp0VrSM8IttVc32D6J4WUsiPE6aEFRNmIoF/gdow==",
+      "dev": true,
+      "dependencies": {
+        "flush-write-stream": "^1.0.2"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/liftoff": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-3.1.0.tgz",
+      "integrity": "sha512-DlIPlJUkCV0Ips2zf2pJP0unEoT1kwYhiiPUGF3s/jtxTCjziNLoiVVh+jqWOWeFi6mmwQ5fNxvAUyPad4Dfog==",
+      "dev": true,
+      "dependencies": {
+        "extend": "^3.0.0",
+        "findup-sync": "^3.0.0",
+        "fined": "^1.0.1",
+        "flagged-respawn": "^1.0.0",
+        "is-plain-object": "^2.0.4",
+        "object.map": "^1.0.0",
+        "rechoir": "^0.6.2",
+        "resolve": "^1.1.7"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/liftoff/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/load-json-file": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
+      "integrity": "sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==",
+      "dev": true,
+      "dependencies": {
+        "graceful-fs": "^4.1.2",
+        "parse-json": "^2.2.0",
+        "pify": "^2.0.0",
+        "pinkie-promise": "^2.0.0",
+        "strip-bom": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/lodash": {
+      "version": "4.17.21",
+      "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
+      "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
+      "dev": true
+    },
+    "node_modules/lodash.memoize": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz",
+      "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=",
+      "dev": true
+    },
+    "node_modules/lru-queue": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
+      "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=",
+      "dev": true,
+      "dependencies": {
+        "es5-ext": "~0.10.2"
+      }
+    },
+    "node_modules/make-error": {
+      "version": "1.3.5",
+      "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
+      "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==",
+      "dev": true
+    },
+    "node_modules/make-error-cause": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmjs.org/make-error-cause/-/make-error-cause-1.2.2.tgz",
+      "integrity": "sha1-3wOI/NCzeBbf8KX7gQiTl3fcvJ0=",
+      "dev": true,
+      "dependencies": {
+        "make-error": "^1.2.0"
+      }
+    },
+    "node_modules/make-iterator": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz",
+      "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^6.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/make-iterator/node_modules/kind-of": {
+      "version": "6.0.3",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+      "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/map-cache": {
+      "version": "0.2.2",
+      "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz",
+      "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/map-visit": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz",
+      "integrity": "sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==",
+      "dev": true,
+      "dependencies": {
+        "object-visit": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/matchdep": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/matchdep/-/matchdep-2.0.0.tgz",
+      "integrity": "sha512-LFgVbaHIHMqCRuCZyfCtUOq9/Lnzhi7Z0KFUE2fhD54+JN2jLh3hC02RLkqauJ3U4soU6H1J3tfj/Byk7GoEjA==",
+      "dev": true,
+      "dependencies": {
+        "findup-sync": "^2.0.0",
+        "micromatch": "^3.0.4",
+        "resolve": "^1.4.0",
+        "stack-trace": "0.0.10"
+      },
+      "engines": {
+        "node": ">= 0.10.0"
+      }
+    },
+    "node_modules/matchdep/node_modules/findup-sync": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz",
+      "integrity": "sha512-vs+3unmJT45eczmcAZ6zMJtxN3l/QXeccaXQx5cu/MeJMhewVfoWZqibRkOxPnmoR59+Zy5hjabfQc6JLSah4g==",
+      "dev": true,
+      "dependencies": {
+        "detect-file": "^1.0.0",
+        "is-glob": "^3.1.0",
+        "micromatch": "^3.0.4",
+        "resolve-dir": "^1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/matchdep/node_modules/is-glob": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz",
+      "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==",
+      "dev": true,
+      "dependencies": {
+        "is-extglob": "^2.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/md5.js": {
+      "version": "1.3.5",
+      "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
+      "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==",
+      "dev": true,
+      "dependencies": {
+        "hash-base": "^3.0.0",
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.1.2"
+      }
+    },
+    "node_modules/md5.js/node_modules/safe-buffer": {
+      "version": "5.1.2",
+      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+      "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+      "dev": true
+    },
+    "node_modules/memoizee": {
+      "version": "0.4.14",
+      "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.14.tgz",
+      "integrity": "sha512-/SWFvWegAIYAO4NQMpcX+gcra0yEZu4OntmUdrBaWrJncxOqAziGFlHxc7yjKVK2uu3lpPW27P27wkR82wA8mg==",
+      "dev": true,
+      "dependencies": {
+        "d": "1",
+        "es5-ext": "^0.10.45",
+        "es6-weak-map": "^2.0.2",
+        "event-emitter": "^0.3.5",
+        "is-promise": "^2.1",
+        "lru-queue": "0.1",
+        "next-tick": "1",
+        "timers-ext": "^0.1.5"
+      }
+    },
+    "node_modules/memoizee/node_modules/es5-ext": {
+      "version": "0.10.46",
+      "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.46.tgz",
+      "integrity": "sha512-24XxRvJXNFwEMpJb3nOkiRJKRoupmjYmOPVlI65Qy2SrtxwOTB+g6ODjBKOtwEHbYrhWRty9xxOWLNdClT2djw==",
+      "dev": true,
+      "dependencies": {
+        "es6-iterator": "~2.0.3",
+        "es6-symbol": "~3.1.1",
+        "next-tick": "1"
+      }
+    },
+    "node_modules/memoizee/node_modules/es6-iterator": {
+      "version": "2.0.3",
+      "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
+      "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
+      "dev": true,
+      "dependencies": {
+        "d": "1",
+        "es5-ext": "^0.10.35",
+        "es6-symbol": "^3.1.1"
+      }
+    },
+    "node_modules/micromatch": {
+      "version": "3.1.10",
+      "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz",
+      "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==",
+      "dev": true,
+      "dependencies": {
+        "arr-diff": "^4.0.0",
+        "array-unique": "^0.3.2",
+        "braces": "^2.3.1",
+        "define-property": "^2.0.2",
+        "extend-shallow": "^3.0.2",
+        "extglob": "^2.0.4",
+        "fragment-cache": "^0.2.1",
+        "kind-of": "^6.0.2",
+        "nanomatch": "^1.2.9",
+        "object.pick": "^1.3.0",
+        "regex-not": "^1.0.0",
+        "snapdragon": "^0.8.1",
+        "to-regex": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/micromatch/node_modules/extend-shallow": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+      "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+      "dev": true,
+      "dependencies": {
+        "assign-symbols": "^1.0.0",
+        "is-extendable": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/micromatch/node_modules/is-extendable": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+      "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+      "dev": true,
+      "dependencies": {
+        "is-plain-object": "^2.0.4"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/micromatch/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/micromatch/node_modules/kind-of": {
+      "version": "6.0.3",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+      "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/miller-rabin": {
+      "version": "4.0.1",
+      "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz",
+      "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==",
+      "dev": true,
+      "dependencies": {
+        "bn.js": "^4.0.0",
+        "brorand": "^1.0.1"
+      },
+      "bin": {
+        "miller-rabin": "bin/miller-rabin"
+      }
+    },
+    "node_modules/minimalistic-assert": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
+      "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==",
+      "dev": true
+    },
+    "node_modules/minimalistic-crypto-utils": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz",
+      "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=",
+      "dev": true
+    },
+    "node_modules/minimatch": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+      "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+      "dev": true,
+      "dependencies": {
+        "brace-expansion": "^1.1.7"
+      },
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/minimist": {
+      "version": "1.2.6",
+      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
+      "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
+      "dev": true
+    },
+    "node_modules/mixin-deep": {
+      "version": "1.3.2",
+      "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
+      "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
+      "dev": true,
+      "dependencies": {
+        "for-in": "^1.0.2",
+        "is-extendable": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/mixin-deep/node_modules/is-extendable": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+      "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+      "dev": true,
+      "dependencies": {
+        "is-plain-object": "^2.0.4"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/mixin-deep/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/module-deps": {
+      "version": "4.1.1",
+      "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz",
+      "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=",
+      "dev": true,
+      "dependencies": {
+        "browser-resolve": "^1.7.0",
+        "cached-path-relative": "^1.0.0",
+        "concat-stream": "~1.5.0",
+        "defined": "^1.0.0",
+        "detective": "^4.0.0",
+        "duplexer2": "^0.1.2",
+        "inherits": "^2.0.1",
+        "JSONStream": "^1.0.3",
+        "parents": "^1.0.0",
+        "readable-stream": "^2.0.2",
+        "resolve": "^1.1.3",
+        "stream-combiner2": "^1.1.1",
+        "subarg": "^1.0.0",
+        "through2": "^2.0.0",
+        "xtend": "^4.0.0"
+      },
+      "bin": {
+        "module-deps": "bin/cmd.js"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/ms": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+      "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+      "dev": true
+    },
+    "node_modules/mute-stdout": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.1.tgz",
+      "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/nan": {
+      "version": "2.16.0",
+      "resolved": "https://registry.npmjs.org/nan/-/nan-2.16.0.tgz",
+      "integrity": "sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA==",
+      "dev": true,
+      "optional": true
+    },
+    "node_modules/nanomatch": {
+      "version": "1.2.13",
+      "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
+      "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==",
+      "dev": true,
+      "dependencies": {
+        "arr-diff": "^4.0.0",
+        "array-unique": "^0.3.2",
+        "define-property": "^2.0.2",
+        "extend-shallow": "^3.0.2",
+        "fragment-cache": "^0.2.1",
+        "is-windows": "^1.0.2",
+        "kind-of": "^6.0.2",
+        "object.pick": "^1.3.0",
+        "regex-not": "^1.0.0",
+        "snapdragon": "^0.8.1",
+        "to-regex": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/nanomatch/node_modules/extend-shallow": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+      "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+      "dev": true,
+      "dependencies": {
+        "assign-symbols": "^1.0.0",
+        "is-extendable": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/nanomatch/node_modules/is-extendable": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+      "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+      "dev": true,
+      "dependencies": {
+        "is-plain-object": "^2.0.4"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/nanomatch/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/nanomatch/node_modules/kind-of": {
+      "version": "6.0.3",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+      "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/next-tick": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
+      "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
+      "dev": true
+    },
+    "node_modules/normalize-package-data": {
+      "version": "2.5.0",
+      "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
+      "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==",
+      "dev": true,
+      "dependencies": {
+        "hosted-git-info": "^2.1.4",
+        "resolve": "^1.10.0",
+        "semver": "2 || 3 || 4 || 5",
+        "validate-npm-package-license": "^3.0.1"
+      }
+    },
+    "node_modules/normalize-path": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
+      "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
+      "dev": true,
+      "dependencies": {
+        "remove-trailing-separator": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/now-and-later": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz",
+      "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==",
+      "dev": true,
+      "dependencies": {
+        "once": "^1.3.2"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/number-is-nan": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
+      "integrity": "sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-assign": {
+      "version": "4.1.1",
+      "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+      "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-copy": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz",
+      "integrity": "sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==",
+      "dev": true,
+      "dependencies": {
+        "copy-descriptor": "^0.1.0",
+        "define-property": "^0.2.5",
+        "kind-of": "^3.0.3"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-copy/node_modules/define-property": {
+      "version": "0.2.5",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+      "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+      "dev": true,
+      "dependencies": {
+        "is-descriptor": "^0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-copy/node_modules/is-accessor-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+      "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-copy/node_modules/is-data-descriptor": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+      "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-copy/node_modules/is-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+      "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+      "dev": true,
+      "dependencies": {
+        "is-accessor-descriptor": "^0.1.6",
+        "is-data-descriptor": "^0.1.4",
+        "kind-of": "^5.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-copy/node_modules/is-descriptor/node_modules/kind-of": {
+      "version": "5.1.0",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz",
+      "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-copy/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-keys": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
+      "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/object-visit": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz",
+      "integrity": "sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object.assign": {
+      "version": "4.1.2",
+      "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz",
+      "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==",
+      "dev": true,
+      "dependencies": {
+        "call-bind": "^1.0.0",
+        "define-properties": "^1.1.3",
+        "has-symbols": "^1.0.1",
+        "object-keys": "^1.1.1"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/object.defaults": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz",
+      "integrity": "sha512-c/K0mw/F11k4dEUBMW8naXUuBuhxRCfG7W+yFy8EcijU/rSmazOUd1XAEEe6bC0OuXY4HUKjTJv7xbxIMqdxrA==",
+      "dev": true,
+      "dependencies": {
+        "array-each": "^1.0.1",
+        "array-slice": "^1.0.0",
+        "for-own": "^1.0.0",
+        "isobject": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object.map": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz",
+      "integrity": "sha512-3+mAJu2PLfnSVGHwIWubpOFLscJANBKuB/6A4CxBstc4aqwQY0FWcsppuy4jU5GSB95yES5JHSI+33AWuS4k6w==",
+      "dev": true,
+      "dependencies": {
+        "for-own": "^1.0.0",
+        "make-iterator": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object.pick": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz",
+      "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object.reduce": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/object.reduce/-/object.reduce-1.0.1.tgz",
+      "integrity": "sha512-naLhxxpUESbNkRqc35oQ2scZSJueHGQNUfMW/0U37IgN6tE2dgDWg3whf+NEliy3F/QysrO48XKUz/nGPe+AQw==",
+      "dev": true,
+      "dependencies": {
+        "for-own": "^1.0.0",
+        "make-iterator": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/once": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+      "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
+      "dev": true,
+      "dependencies": {
+        "wrappy": "1"
+      }
+    },
+    "node_modules/ordered-read-streams": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz",
+      "integrity": "sha512-Z87aSjx3r5c0ZB7bcJqIgIRX5bxR7A4aSzvIbaxd0oTkWBCOoKfuGHiKj60CHVUgg1Phm5yMZzBdt8XqRs73Mw==",
+      "dev": true,
+      "dependencies": {
+        "readable-stream": "^2.0.1"
+      }
+    },
+    "node_modules/os-browserify": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz",
+      "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=",
+      "dev": true
+    },
+    "node_modules/os-locale": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
+      "integrity": "sha512-PRT7ZORmwu2MEFt4/fv3Q+mEfN4zetKxufQrkShY2oGvUms9r8otu5HfdyIFHkYXjO7laNsoVGmM2MANfuTA8g==",
+      "dev": true,
+      "dependencies": {
+        "lcid": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/pako": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
+      "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==",
+      "dev": true
+    },
+    "node_modules/parents": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz",
+      "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=",
+      "dev": true,
+      "dependencies": {
+        "path-platform": "~0.11.15"
+      }
+    },
+    "node_modules/parse-asn1": {
+      "version": "5.1.1",
+      "resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz",
+      "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==",
+      "dev": true,
+      "dependencies": {
+        "asn1.js": "^4.0.0",
+        "browserify-aes": "^1.0.0",
+        "create-hash": "^1.1.0",
+        "evp_bytestokey": "^1.0.0",
+        "pbkdf2": "^3.0.3"
+      }
+    },
+    "node_modules/parse-filepath": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz",
+      "integrity": "sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==",
+      "dev": true,
+      "dependencies": {
+        "is-absolute": "^1.0.0",
+        "map-cache": "^0.2.0",
+        "path-root": "^0.1.1"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
+    "node_modules/parse-json": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
+      "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
+      "dev": true,
+      "dependencies": {
+        "error-ex": "^1.2.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/parse-node-version": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz",
+      "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/parse-passwd": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz",
+      "integrity": "sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/pascalcase": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz",
+      "integrity": "sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/path-browserify": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
+      "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==",
+      "dev": true
+    },
+    "node_modules/path-dirname": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz",
+      "integrity": "sha512-ALzNPpyNq9AqXMBjeymIjFDAkAFH06mHJH/cSBHAgU0s4vfpBn6b2nf8tiRLvagKD8RbTpq2FKTBg7cl9l3c7Q==",
+      "dev": true
+    },
+    "node_modules/path-exists": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
+      "integrity": "sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==",
+      "dev": true,
+      "dependencies": {
+        "pinkie-promise": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/path-is-absolute": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+      "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/path-parse": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
+      "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
+      "dev": true
+    },
+    "node_modules/path-platform": {
+      "version": "0.11.15",
+      "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz",
+      "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8.0"
+      }
+    },
+    "node_modules/path-root": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz",
+      "integrity": "sha512-QLcPegTHF11axjfojBIoDygmS2E3Lf+8+jI6wOVmNVenrKSo3mFdSGiIgdSHenczw3wPtlVMQaFVwGmM7BJdtg==",
+      "dev": true,
+      "dependencies": {
+        "path-root-regex": "^0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/path-root-regex": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz",
+      "integrity": "sha512-4GlJ6rZDhQZFE0DPVKh0e9jmZ5egZfxTkp7bcRDuPlJXbAwhxcl2dINPUAsjLdejqaLsCeg8axcLjIbvBjN4pQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/path-type": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz",
+      "integrity": "sha512-S4eENJz1pkiQn9Znv33Q+deTOKmbl+jj1Fl+qiP/vYezj+S8x+J3Uo0ISrx/QoEvIlOaDWJhPaRd1flJ9HXZqg==",
+      "dev": true,
+      "dependencies": {
+        "graceful-fs": "^4.1.2",
+        "pify": "^2.0.0",
+        "pinkie-promise": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/pbkdf2": {
+      "version": "3.0.17",
+      "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz",
+      "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==",
+      "dev": true,
+      "dependencies": {
+        "create-hash": "^1.1.2",
+        "create-hmac": "^1.1.4",
+        "ripemd160": "^2.0.1",
+        "safe-buffer": "^5.0.1",
+        "sha.js": "^2.4.8"
+      },
+      "engines": {
+        "node": ">=0.12"
+      }
+    },
+    "node_modules/pify": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
+      "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/pinkie": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz",
+      "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/pinkie-promise": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
+      "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==",
+      "dev": true,
+      "dependencies": {
+        "pinkie": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/posix-character-classes": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz",
+      "integrity": "sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/preact": {
+      "version": "8.3.1",
+      "resolved": "https://registry.npmjs.org/preact/-/preact-8.3.1.tgz",
+      "integrity": "sha512-s8H1Y8O9e+mOBo3UP1jvWqArPmjCba2lrrGLlq/0kN1XuIINUbYtf97iiXKxCuG3eYwmppPKnyW2DBrNj/TuTg==",
+      "hasInstallScript": true
+    },
+    "node_modules/pretty-hrtime": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz",
+      "integrity": "sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/process": {
+      "version": "0.11.10",
+      "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
+      "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.6.0"
+      }
+    },
+    "node_modules/process-nextick-args": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
+      "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=",
+      "dev": true
+    },
+    "node_modules/public-encrypt": {
+      "version": "4.0.3",
+      "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz",
+      "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==",
+      "dev": true,
+      "dependencies": {
+        "bn.js": "^4.1.0",
+        "browserify-rsa": "^4.0.0",
+        "create-hash": "^1.1.0",
+        "parse-asn1": "^5.0.0",
+        "randombytes": "^2.0.1",
+        "safe-buffer": "^5.1.2"
+      }
+    },
+    "node_modules/public-encrypt/node_modules/safe-buffer": {
+      "version": "5.1.2",
+      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+      "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+      "dev": true
+    },
+    "node_modules/pump": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz",
+      "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==",
+      "dev": true,
+      "dependencies": {
+        "end-of-stream": "^1.1.0",
+        "once": "^1.3.1"
+      }
+    },
+    "node_modules/pumpify": {
+      "version": "1.5.1",
+      "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz",
+      "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==",
+      "dev": true,
+      "dependencies": {
+        "duplexify": "^3.6.0",
+        "inherits": "^2.0.3",
+        "pump": "^2.0.0"
+      }
+    },
+    "node_modules/punycode": {
+      "version": "1.4.1",
+      "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
+      "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
+      "dev": true
+    },
+    "node_modules/querystring": {
+      "version": "0.2.0",
+      "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
+      "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.4.x"
+      }
+    },
+    "node_modules/querystring-es3": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz",
+      "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.4.x"
+      }
+    },
+    "node_modules/randombytes": {
+      "version": "2.0.6",
+      "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz",
+      "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==",
+      "dev": true,
+      "dependencies": {
+        "safe-buffer": "^5.1.0"
+      }
+    },
+    "node_modules/randomfill": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz",
+      "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==",
+      "dev": true,
+      "dependencies": {
+        "randombytes": "^2.0.5",
+        "safe-buffer": "^5.1.0"
+      }
+    },
+    "node_modules/read-only-stream": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz",
+      "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=",
+      "dev": true,
+      "dependencies": {
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "node_modules/read-pkg": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
+      "integrity": "sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==",
+      "dev": true,
+      "dependencies": {
+        "load-json-file": "^1.0.0",
+        "normalize-package-data": "^2.3.2",
+        "path-type": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/read-pkg-up": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz",
+      "integrity": "sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==",
+      "dev": true,
+      "dependencies": {
+        "find-up": "^1.0.0",
+        "read-pkg": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/readable-stream": {
+      "version": "2.3.6",
+      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
+      "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
+      "dev": true,
+      "dependencies": {
+        "core-util-is": "~1.0.0",
+        "inherits": "~2.0.3",
+        "isarray": "~1.0.0",
+        "process-nextick-args": "~2.0.0",
+        "safe-buffer": "~5.1.1",
+        "string_decoder": "~1.1.1",
+        "util-deprecate": "~1.0.1"
+      }
+    },
+    "node_modules/readable-stream/node_modules/process-nextick-args": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
+      "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
+      "dev": true
+    },
+    "node_modules/readable-stream/node_modules/string_decoder": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
+      "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
+      "dev": true,
+      "dependencies": {
+        "safe-buffer": "~5.1.0"
+      }
+    },
+    "node_modules/readdirp": {
+      "version": "2.2.1",
+      "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz",
+      "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==",
+      "dev": true,
+      "dependencies": {
+        "graceful-fs": "^4.1.11",
+        "micromatch": "^3.1.10",
+        "readable-stream": "^2.0.2"
+      },
+      "engines": {
+        "node": ">=0.10"
+      }
+    },
+    "node_modules/rechoir": {
+      "version": "0.6.2",
+      "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
+      "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==",
+      "dev": true,
+      "dependencies": {
+        "resolve": "^1.1.6"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/regex-not": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz",
+      "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==",
+      "dev": true,
+      "dependencies": {
+        "extend-shallow": "^3.0.2",
+        "safe-regex": "^1.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/regex-not/node_modules/extend-shallow": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+      "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+      "dev": true,
+      "dependencies": {
+        "assign-symbols": "^1.0.0",
+        "is-extendable": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/regex-not/node_modules/is-extendable": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+      "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+      "dev": true,
+      "dependencies": {
+        "is-plain-object": "^2.0.4"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/regex-not/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/remove-bom-buffer": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz",
+      "integrity": "sha512-8v2rWhaakv18qcvNeli2mZ/TMTL2nEyAKRvzo1WtnZBl15SHyEhrCu2/xKlJyUFKHiHgfXIyuY6g2dObJJycXQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5",
+        "is-utf8": "^0.2.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/remove-bom-stream": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz",
+      "integrity": "sha512-wigO8/O08XHb8YPzpDDT+QmRANfW6vLqxfaXm1YXhnFf3AkSLyjfG3GEFg4McZkmgL7KvCj5u2KczkvSP6NfHA==",
+      "dev": true,
+      "dependencies": {
+        "remove-bom-buffer": "^3.0.0",
+        "safe-buffer": "^5.1.0",
+        "through2": "^2.0.3"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/remove-trailing-separator": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
+      "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=",
+      "dev": true
+    },
+    "node_modules/repeat-element": {
+      "version": "1.1.4",
+      "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.4.tgz",
+      "integrity": "sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/repeat-string": {
+      "version": "1.6.1",
+      "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
+      "integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10"
+      }
+    },
+    "node_modules/replace-homedir": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/replace-homedir/-/replace-homedir-1.0.0.tgz",
+      "integrity": "sha512-CHPV/GAglbIB1tnQgaiysb8H2yCy8WQ7lcEwQ/eT+kLj0QHV8LnJW0zpqpE7RSkrMSRoa+EBoag86clf7WAgSg==",
+      "dev": true,
+      "dependencies": {
+        "homedir-polyfill": "^1.0.1",
+        "is-absolute": "^1.0.0",
+        "remove-trailing-separator": "^1.1.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/require-directory": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
+      "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/require-main-filename": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz",
+      "integrity": "sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==",
+      "dev": true
+    },
+    "node_modules/resolve": {
+      "version": "1.22.0",
+      "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz",
+      "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==",
+      "dev": true,
+      "dependencies": {
+        "is-core-module": "^2.8.1",
+        "path-parse": "^1.0.7",
+        "supports-preserve-symlinks-flag": "^1.0.0"
+      },
+      "bin": {
+        "resolve": "bin/resolve"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/resolve-dir": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz",
+      "integrity": "sha512-R7uiTjECzvOsWSfdM0QKFNBVFcK27aHOUwdvK53BcW8zqnGdYp0Fbj82cy54+2A4P2tFM22J5kRfe1R+lM/1yg==",
+      "dev": true,
+      "dependencies": {
+        "expand-tilde": "^2.0.0",
+        "global-modules": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/resolve-options": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz",
+      "integrity": "sha512-NYDgziiroVeDC29xq7bp/CacZERYsA9bXYd1ZmcJlF3BcrZv5pTb4NG7SjdyKDnXZ84aC4vo2u6sNKIA1LCu/A==",
+      "dev": true,
+      "dependencies": {
+        "value-or-function": "^3.0.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/resolve-url": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz",
+      "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=",
+      "dev": true
+    },
+    "node_modules/ret": {
+      "version": "0.1.15",
+      "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz",
+      "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.12"
+      }
+    },
+    "node_modules/ripemd160": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz",
+      "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==",
+      "dev": true,
+      "dependencies": {
+        "hash-base": "^3.0.0",
+        "inherits": "^2.0.1"
+      }
+    },
+    "node_modules/safe-buffer": {
+      "version": "5.1.1",
+      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
+      "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
+      "dev": true
+    },
+    "node_modules/safe-regex": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
+      "integrity": "sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==",
+      "dev": true,
+      "dependencies": {
+        "ret": "~0.1.10"
+      }
+    },
+    "node_modules/semver": {
+      "version": "5.6.0",
+      "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
+      "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==",
+      "dev": true,
+      "bin": {
+        "semver": "bin/semver"
+      }
+    },
+    "node_modules/semver-greatest-satisfied-range": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/semver-greatest-satisfied-range/-/semver-greatest-satisfied-range-1.1.0.tgz",
+      "integrity": "sha512-Ny/iyOzSSa8M5ML46IAx3iXc6tfOsYU2R4AXi2UpHk60Zrgyq6eqPj/xiOfS0rRl/iiQ/rdJkVjw/5cdUyCntQ==",
+      "dev": true,
+      "dependencies": {
+        "sver-compat": "^1.5.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/set-blocking": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
+      "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
+      "dev": true
+    },
+    "node_modules/set-value": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
+      "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==",
+      "dev": true,
+      "dependencies": {
+        "extend-shallow": "^2.0.1",
+        "is-extendable": "^0.1.1",
+        "is-plain-object": "^2.0.3",
+        "split-string": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/set-value/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/sha.js": {
+      "version": "2.4.11",
+      "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
+      "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.0.1"
+      },
+      "bin": {
+        "sha.js": "bin.js"
+      }
+    },
+    "node_modules/shasum": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz",
+      "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=",
+      "dev": true,
+      "dependencies": {
+        "json-stable-stringify": "~0.0.0",
+        "sha.js": "~2.4.4"
+      }
+    },
+    "node_modules/shell-quote": {
+      "version": "1.7.3",
+      "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz",
+      "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==",
+      "dev": true
+    },
+    "node_modules/simple-concat": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz",
+      "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=",
+      "dev": true
+    },
+    "node_modules/snapdragon": {
+      "version": "0.8.2",
+      "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
+      "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==",
+      "dev": true,
+      "dependencies": {
+        "base": "^0.11.1",
+        "debug": "^2.2.0",
+        "define-property": "^0.2.5",
+        "extend-shallow": "^2.0.1",
+        "map-cache": "^0.2.2",
+        "source-map": "^0.5.6",
+        "source-map-resolve": "^0.5.0",
+        "use": "^3.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon-node": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz",
+      "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==",
+      "dev": true,
+      "dependencies": {
+        "define-property": "^1.0.0",
+        "isobject": "^3.0.0",
+        "snapdragon-util": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon-node/node_modules/define-property": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
+      "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==",
+      "dev": true,
+      "dependencies": {
+        "is-descriptor": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon-util": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz",
+      "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.2.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon-util/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon/node_modules/define-property": {
+      "version": "0.2.5",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+      "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+      "dev": true,
+      "dependencies": {
+        "is-descriptor": "^0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon/node_modules/is-accessor-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+      "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon/node_modules/is-data-descriptor": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+      "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/snapdragon/node_modules/is-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+      "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+      "dev": true,
+      "dependencies": {
+        "is-accessor-descriptor": "^0.1.6",
+        "is-data-descriptor": "^0.1.4",
+        "kind-of": "^5.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/source-map": {
+      "version": "0.5.7",
+      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
+      "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/source-map-resolve": {
+      "version": "0.5.2",
+      "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz",
+      "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==",
+      "dev": true,
+      "dependencies": {
+        "atob": "^2.1.1",
+        "decode-uri-component": "^0.2.0",
+        "resolve-url": "^0.2.1",
+        "source-map-url": "^0.4.0",
+        "urix": "^0.1.0"
+      }
+    },
+    "node_modules/source-map-url": {
+      "version": "0.4.0",
+      "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz",
+      "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=",
+      "dev": true
+    },
+    "node_modules/sparkles": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz",
+      "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/spdx-correct": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz",
+      "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==",
+      "dev": true,
+      "dependencies": {
+        "spdx-expression-parse": "^3.0.0",
+        "spdx-license-ids": "^3.0.0"
+      }
+    },
+    "node_modules/spdx-exceptions": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz",
+      "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==",
+      "dev": true
+    },
+    "node_modules/spdx-expression-parse": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz",
+      "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==",
+      "dev": true,
+      "dependencies": {
+        "spdx-exceptions": "^2.1.0",
+        "spdx-license-ids": "^3.0.0"
+      }
+    },
+    "node_modules/spdx-license-ids": {
+      "version": "3.0.11",
+      "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz",
+      "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==",
+      "dev": true
+    },
+    "node_modules/split-string": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
+      "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==",
+      "dev": true,
+      "dependencies": {
+        "extend-shallow": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/split-string/node_modules/extend-shallow": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+      "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+      "dev": true,
+      "dependencies": {
+        "assign-symbols": "^1.0.0",
+        "is-extendable": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/split-string/node_modules/is-extendable": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+      "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+      "dev": true,
+      "dependencies": {
+        "is-plain-object": "^2.0.4"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/split-string/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/stack-trace": {
+      "version": "0.0.10",
+      "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
+      "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==",
+      "dev": true,
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/static-extend": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz",
+      "integrity": "sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==",
+      "dev": true,
+      "dependencies": {
+        "define-property": "^0.2.5",
+        "object-copy": "^0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/static-extend/node_modules/define-property": {
+      "version": "0.2.5",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+      "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+      "dev": true,
+      "dependencies": {
+        "is-descriptor": "^0.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/static-extend/node_modules/is-accessor-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+      "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/static-extend/node_modules/is-accessor-descriptor/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/static-extend/node_modules/is-data-descriptor": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+      "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/static-extend/node_modules/is-data-descriptor/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/static-extend/node_modules/is-descriptor": {
+      "version": "0.1.6",
+      "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+      "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+      "dev": true,
+      "dependencies": {
+        "is-accessor-descriptor": "^0.1.6",
+        "is-data-descriptor": "^0.1.4",
+        "kind-of": "^5.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/stream-browserify": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz",
+      "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=",
+      "dev": true,
+      "dependencies": {
+        "inherits": "~2.0.1",
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "node_modules/stream-combiner2": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz",
+      "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=",
+      "dev": true,
+      "dependencies": {
+        "duplexer2": "~0.1.0",
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "node_modules/stream-exhaust": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz",
+      "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==",
+      "dev": true
+    },
+    "node_modules/stream-http": {
+      "version": "2.8.3",
+      "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz",
+      "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==",
+      "dev": true,
+      "dependencies": {
+        "builtin-status-codes": "^3.0.0",
+        "inherits": "^2.0.1",
+        "readable-stream": "^2.3.6",
+        "to-arraybuffer": "^1.0.0",
+        "xtend": "^4.0.0"
+      }
+    },
+    "node_modules/stream-shift": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz",
+      "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==",
+      "dev": true
+    },
+    "node_modules/stream-splicer": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz",
+      "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=",
+      "dev": true,
+      "dependencies": {
+        "inherits": "^2.0.1",
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "node_modules/string_decoder": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
+      "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
+      "dev": true,
+      "dependencies": {
+        "safe-buffer": "~5.1.0"
+      }
+    },
+    "node_modules/string-width": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
+      "integrity": "sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==",
+      "dev": true,
+      "dependencies": {
+        "code-point-at": "^1.0.0",
+        "is-fullwidth-code-point": "^1.0.0",
+        "strip-ansi": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/strip-ansi": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+      "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==",
+      "dev": true,
+      "dependencies": {
+        "ansi-regex": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/strip-bom": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
+      "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
+      "dev": true,
+      "dependencies": {
+        "is-utf8": "^0.2.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/strip-bom-string": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
+      "integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/strip-json-comments": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
+      "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/subarg": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz",
+      "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=",
+      "dev": true,
+      "dependencies": {
+        "minimist": "^1.1.0"
+      }
+    },
+    "node_modules/supports-preserve-symlinks-flag": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
+      "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/sver-compat": {
+      "version": "1.5.0",
+      "resolved": "https://registry.npmjs.org/sver-compat/-/sver-compat-1.5.0.tgz",
+      "integrity": "sha512-aFTHfmjwizMNlNE6dsGmoAM4lHjL0CyiobWaFiXWSlD7cIxshW422Nb8KbXCmR6z+0ZEPY+daXJrDyh/vuwTyg==",
+      "dev": true,
+      "dependencies": {
+        "es6-iterator": "^2.0.1",
+        "es6-symbol": "^3.1.1"
+      }
+    },
+    "node_modules/syntax-error": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz",
+      "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==",
+      "dev": true,
+      "dependencies": {
+        "acorn-node": "^1.2.0"
+      }
+    },
+    "node_modules/through": {
+      "version": "2.3.8",
+      "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
+      "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
+      "dev": true
+    },
+    "node_modules/through2": {
+      "version": "2.0.3",
+      "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
+      "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=",
+      "dev": true,
+      "dependencies": {
+        "readable-stream": "^2.1.5",
+        "xtend": "~4.0.1"
+      }
+    },
+    "node_modules/through2-filter": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-3.0.0.tgz",
+      "integrity": "sha512-jaRjI2WxN3W1V8/FMZ9HKIBXixtiqs3SQSX4/YGIiP3gL6djW48VoZq9tDqeCWs3MT8YY5wb/zli8VW8snY1CA==",
+      "dev": true,
+      "dependencies": {
+        "through2": "~2.0.0",
+        "xtend": "~4.0.0"
+      }
+    },
+    "node_modules/time-stamp": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz",
+      "integrity": "sha512-gLCeArryy2yNTRzTGKbZbloctj64jkZ57hj5zdraXue6aFgd6PmvVtEyiUU+hvU0v7q08oVv8r8ev0tRo6bvgw==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/timers-browserify": {
+      "version": "1.4.2",
+      "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz",
+      "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=",
+      "dev": true,
+      "dependencies": {
+        "process": "~0.11.0"
+      },
+      "engines": {
+        "node": ">=0.6.0"
+      }
+    },
+    "node_modules/timers-ext": {
+      "version": "0.1.7",
+      "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
+      "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
+      "dev": true,
+      "dependencies": {
+        "es5-ext": "~0.10.46",
+        "next-tick": "1"
+      }
+    },
+    "node_modules/timers-ext/node_modules/es5-ext": {
+      "version": "0.10.46",
+      "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.46.tgz",
+      "integrity": "sha512-24XxRvJXNFwEMpJb3nOkiRJKRoupmjYmOPVlI65Qy2SrtxwOTB+g6ODjBKOtwEHbYrhWRty9xxOWLNdClT2djw==",
+      "dev": true,
+      "dependencies": {
+        "es6-iterator": "~2.0.3",
+        "es6-symbol": "~3.1.1",
+        "next-tick": "1"
+      }
+    },
+    "node_modules/timers-ext/node_modules/es6-iterator": {
+      "version": "2.0.3",
+      "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
+      "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
+      "dev": true,
+      "dependencies": {
+        "d": "1",
+        "es5-ext": "^0.10.35",
+        "es6-symbol": "^3.1.1"
+      }
+    },
+    "node_modules/to-absolute-glob": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz",
+      "integrity": "sha512-rtwLUQEwT8ZeKQbyFJyomBRYXyE16U5VKuy0ftxLMK/PZb2fkOsg5r9kHdauuVDbsNdIBoC/HCthpidamQFXYA==",
+      "dev": true,
+      "dependencies": {
+        "is-absolute": "^1.0.0",
+        "is-negated-glob": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/to-arraybuffer": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
+      "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=",
+      "dev": true
+    },
+    "node_modules/to-object-path": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz",
+      "integrity": "sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==",
+      "dev": true,
+      "dependencies": {
+        "kind-of": "^3.0.2"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/to-object-path/node_modules/kind-of": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+      "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+      "dev": true,
+      "dependencies": {
+        "is-buffer": "^1.1.5"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/to-regex": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz",
+      "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==",
+      "dev": true,
+      "dependencies": {
+        "define-property": "^2.0.2",
+        "extend-shallow": "^3.0.2",
+        "regex-not": "^1.0.2",
+        "safe-regex": "^1.1.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/to-regex-range": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz",
+      "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==",
+      "dev": true,
+      "dependencies": {
+        "is-number": "^3.0.0",
+        "repeat-string": "^1.6.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/to-regex/node_modules/extend-shallow": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+      "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+      "dev": true,
+      "dependencies": {
+        "assign-symbols": "^1.0.0",
+        "is-extendable": "^1.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/to-regex/node_modules/is-extendable": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+      "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+      "dev": true,
+      "dependencies": {
+        "is-plain-object": "^2.0.4"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/to-regex/node_modules/is-plain-object": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+      "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+      "dev": true,
+      "dependencies": {
+        "isobject": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/to-through": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/to-through/-/to-through-2.0.0.tgz",
+      "integrity": "sha512-+QIz37Ly7acM4EMdw2PRN389OneM5+d844tirkGp4dPKzI5OE72V9OsbFp+CIYJDahZ41ZV05hNtcPAQUAm9/Q==",
+      "dev": true,
+      "dependencies": {
+        "through2": "^2.0.3"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/tsconfig": {
+      "version": "5.0.3",
+      "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-5.0.3.tgz",
+      "integrity": "sha1-X0J45wGACWeo/Dg/0ZZIh48qbjo=",
+      "dev": true,
+      "dependencies": {
+        "any-promise": "^1.3.0",
+        "parse-json": "^2.2.0",
+        "strip-bom": "^2.0.0",
+        "strip-json-comments": "^2.0.0"
+      }
+    },
+    "node_modules/tsify": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/tsify/-/tsify-3.0.4.tgz",
+      "integrity": "sha512-y75+qgB41YS8HJck+jmSIn395I4qRGtm5ZELzvNh80Llzh8ojPWp47jm0ZoIJesNYVzbqEyLzgYXV9d/calvVg==",
+      "dev": true,
+      "dependencies": {
+        "convert-source-map": "^1.1.0",
+        "fs.realpath": "^1.0.0",
+        "object-assign": "^4.1.0",
+        "semver": "^5.1.0",
+        "through2": "^2.0.0",
+        "tsconfig": "^5.0.3"
+      },
+      "engines": {
+        "node": ">=0.12"
+      }
+    },
+    "node_modules/tty-browserify": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz",
+      "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==",
+      "dev": true
+    },
+    "node_modules/typedarray": {
+      "version": "0.0.6",
+      "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
+      "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
+      "dev": true
+    },
+    "node_modules/typescript": {
+      "version": "2.9.2",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz",
+      "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==",
+      "dev": true,
+      "bin": {
+        "tsc": "bin/tsc",
+        "tsserver": "bin/tsserver"
+      },
+      "engines": {
+        "node": ">=4.2.0"
+      }
+    },
+    "node_modules/uglify-js": {
+      "version": "3.4.9",
+      "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz",
+      "integrity": "sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==",
+      "dev": true,
+      "dependencies": {
+        "commander": "~2.17.1",
+        "source-map": "~0.6.1"
+      },
+      "bin": {
+        "uglifyjs": "bin/uglifyjs"
+      },
+      "engines": {
+        "node": ">=0.8.0"
+      }
+    },
+    "node_modules/uglify-js/node_modules/source-map": {
+      "version": "0.6.1",
+      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+      "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/umd": {
+      "version": "3.0.3",
+      "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz",
+      "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==",
+      "dev": true,
+      "bin": {
+        "umd": "bin/cli.js"
+      }
+    },
+    "node_modules/unc-path-regex": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz",
+      "integrity": "sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/undeclared-identifiers": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz",
+      "integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==",
+      "dev": true,
+      "dependencies": {
+        "acorn-node": "^1.3.0",
+        "get-assigned-identifiers": "^1.2.0",
+        "simple-concat": "^1.0.0",
+        "xtend": "^4.0.1"
+      },
+      "bin": {
+        "undeclared-identifiers": "bin.js"
+      }
+    },
+    "node_modules/undertaker": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.3.0.tgz",
+      "integrity": "sha512-/RXwi5m/Mu3H6IHQGww3GNt1PNXlbeCuclF2QYR14L/2CHPz3DFZkvB5hZ0N/QUkiXWCACML2jXViIQEQc2MLg==",
+      "dev": true,
+      "dependencies": {
+        "arr-flatten": "^1.0.1",
+        "arr-map": "^2.0.0",
+        "bach": "^1.0.0",
+        "collection-map": "^1.0.0",
+        "es6-weak-map": "^2.0.1",
+        "fast-levenshtein": "^1.0.0",
+        "last-run": "^1.1.0",
+        "object.defaults": "^1.0.0",
+        "object.reduce": "^1.0.0",
+        "undertaker-registry": "^1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/undertaker-registry": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/undertaker-registry/-/undertaker-registry-1.0.1.tgz",
+      "integrity": "sha512-UR1khWeAjugW3548EfQmL9Z7pGMlBgXteQpr1IZeZBtnkCJQJIJ1Scj0mb9wQaPvUZ9Q17XqW6TIaPchJkyfqw==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/union-value": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
+      "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==",
+      "dev": true,
+      "dependencies": {
+        "arr-union": "^3.1.0",
+        "get-value": "^2.0.6",
+        "is-extendable": "^0.1.1",
+        "set-value": "^2.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/unique-stream": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz",
+      "integrity": "sha512-2nY4TnBE70yoxHkDli7DMazpWiP7xMdCYqU2nBRO0UB+ZpEkGsSija7MvmvnZFUeC+mrgiUfcHSr3LmRFIg4+A==",
+      "dev": true,
+      "dependencies": {
+        "json-stable-stringify-without-jsonify": "^1.0.1",
+        "through2-filter": "^3.0.0"
+      }
+    },
+    "node_modules/unset-value": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz",
+      "integrity": "sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==",
+      "dev": true,
+      "dependencies": {
+        "has-value": "^0.3.1",
+        "isobject": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/unset-value/node_modules/has-value": {
+      "version": "0.3.1",
+      "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz",
+      "integrity": "sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==",
+      "dev": true,
+      "dependencies": {
+        "get-value": "^2.0.3",
+        "has-values": "^0.1.4",
+        "isobject": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/unset-value/node_modules/has-value/node_modules/isobject": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
+      "integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==",
+      "dev": true,
+      "dependencies": {
+        "isarray": "1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/unset-value/node_modules/has-values": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz",
+      "integrity": "sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/upath": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz",
+      "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==",
+      "dev": true,
+      "engines": {
+        "node": ">=4",
+        "yarn": "*"
+      }
+    },
+    "node_modules/urix": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz",
+      "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=",
+      "dev": true
+    },
+    "node_modules/url": {
+      "version": "0.11.0",
+      "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz",
+      "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=",
+      "dev": true,
+      "dependencies": {
+        "punycode": "1.3.2",
+        "querystring": "0.2.0"
+      }
+    },
+    "node_modules/url/node_modules/punycode": {
+      "version": "1.3.2",
+      "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
+      "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=",
+      "dev": true
+    },
+    "node_modules/use": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz",
+      "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==",
+      "dev": true,
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/util": {
+      "version": "0.10.4",
+      "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
+      "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
+      "dev": true,
+      "dependencies": {
+        "inherits": "2.0.3"
+      }
+    },
+    "node_modules/util-deprecate": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+      "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
+      "dev": true
+    },
+    "node_modules/v8flags": {
+      "version": "3.2.0",
+      "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz",
+      "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==",
+      "dev": true,
+      "dependencies": {
+        "homedir-polyfill": "^1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/validate-npm-package-license": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
+      "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==",
+      "dev": true,
+      "dependencies": {
+        "spdx-correct": "^3.0.0",
+        "spdx-expression-parse": "^3.0.0"
+      }
+    },
+    "node_modules/value-or-function": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz",
+      "integrity": "sha512-jdBB2FrWvQC/pnPtIqcLsMaQgjhdb6B7tk1MMyTKapox+tQZbdRP4uLxu/JY0t7fbfDCUMnuelzEYv5GsxHhdg==",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/vinyl": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
+      "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
+      "dev": true,
+      "dependencies": {
+        "clone": "^2.1.1",
+        "clone-buffer": "^1.0.0",
+        "clone-stats": "^1.0.0",
+        "cloneable-readable": "^1.0.0",
+        "remove-trailing-separator": "^1.0.1",
+        "replace-ext": "^1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/vinyl-buffer": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/vinyl-buffer/-/vinyl-buffer-1.0.1.tgz",
+      "integrity": "sha1-lsGjR5uMU5JULGEgKQE7Wyf4i78=",
+      "dev": true,
+      "dependencies": {
+        "bl": "^1.2.1",
+        "through2": "^2.0.3"
+      }
+    },
+    "node_modules/vinyl-fs": {
+      "version": "3.0.3",
+      "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz",
+      "integrity": "sha512-vIu34EkyNyJxmP0jscNzWBSygh7VWhqun6RmqVfXePrOwi9lhvRs//dOaGOTRUQr4tx7/zd26Tk5WeSVZitgng==",
+      "dev": true,
+      "dependencies": {
+        "fs-mkdirp-stream": "^1.0.0",
+        "glob-stream": "^6.1.0",
+        "graceful-fs": "^4.0.0",
+        "is-valid-glob": "^1.0.0",
+        "lazystream": "^1.0.0",
+        "lead": "^1.0.0",
+        "object.assign": "^4.0.4",
+        "pumpify": "^1.3.5",
+        "readable-stream": "^2.3.3",
+        "remove-bom-buffer": "^3.0.0",
+        "remove-bom-stream": "^1.2.0",
+        "resolve-options": "^1.1.0",
+        "through2": "^2.0.0",
+        "to-through": "^2.0.0",
+        "value-or-function": "^3.0.0",
+        "vinyl": "^2.0.0",
+        "vinyl-sourcemap": "^1.1.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/vinyl-source-stream": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/vinyl-source-stream/-/vinyl-source-stream-2.0.0.tgz",
+      "integrity": "sha1-84pa+53R6Ttl1VBGmsYYKsT1S44=",
+      "dev": true,
+      "dependencies": {
+        "through2": "^2.0.3",
+        "vinyl": "^2.1.0"
+      }
+    },
+    "node_modules/vinyl-sourcemap": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz",
+      "integrity": "sha512-NiibMgt6VJGJmyw7vtzhctDcfKch4e4n9TBeoWlirb7FMg9/1Ov9k+A5ZRAtywBpRPiyECvQRQllYM8dECegVA==",
+      "dev": true,
+      "dependencies": {
+        "append-buffer": "^1.0.2",
+        "convert-source-map": "^1.5.0",
+        "graceful-fs": "^4.1.6",
+        "normalize-path": "^2.1.1",
+        "now-and-later": "^2.0.0",
+        "remove-bom-buffer": "^3.0.0",
+        "vinyl": "^2.0.0"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/vinyl-sourcemap/node_modules/convert-source-map": {
+      "version": "1.8.0",
+      "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz",
+      "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==",
+      "dev": true,
+      "dependencies": {
+        "safe-buffer": "~5.1.1"
+      }
+    },
+    "node_modules/vinyl-sourcemaps-apply": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz",
+      "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=",
+      "dev": true,
+      "dependencies": {
+        "source-map": "^0.5.1"
+      }
+    },
+    "node_modules/vinyl/node_modules/clone": {
+      "version": "2.1.2",
+      "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
+      "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
+    "node_modules/vinyl/node_modules/clone-stats": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
+      "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=",
+      "dev": true
+    },
+    "node_modules/vinyl/node_modules/replace-ext": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
+      "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=",
+      "dev": true,
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/vm-browserify": {
+      "version": "0.0.4",
+      "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
+      "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=",
+      "dev": true,
+      "dependencies": {
+        "indexof": "0.0.1"
+      }
+    },
+    "node_modules/which": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
+      "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
+      "dev": true,
+      "dependencies": {
+        "isexe": "^2.0.0"
+      },
+      "bin": {
+        "which": "bin/which"
+      }
+    },
+    "node_modules/which-module": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz",
+      "integrity": "sha512-F6+WgncZi/mJDrammbTuHe1q0R5hOXv/mBaiNA2TCNT/LTHusX0V+CJnj9XT8ki5ln2UZyyddDgHfCzyrOH7MQ==",
+      "dev": true
+    },
+    "node_modules/wrap-ansi": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
+      "integrity": "sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==",
+      "dev": true,
+      "dependencies": {
+        "string-width": "^1.0.1",
+        "strip-ansi": "^3.0.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/wrappy": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+      "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
+      "dev": true
+    },
+    "node_modules/xtend": {
+      "version": "4.0.1",
+      "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
+      "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=",
+      "dev": true,
+      "engines": {
+        "node": ">=0.4"
+      }
+    },
+    "node_modules/y18n": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz",
+      "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==",
+      "dev": true
+    },
+    "node_modules/yargs": {
+      "version": "7.1.2",
+      "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.2.tgz",
+      "integrity": "sha512-ZEjj/dQYQy0Zx0lgLMLR8QuaqTihnxirir7EwUHp1Axq4e3+k8jXU5K0VLbNvedv1f4EWtBonDIZm0NUr+jCcA==",
+      "dev": true,
+      "dependencies": {
+        "camelcase": "^3.0.0",
+        "cliui": "^3.2.0",
+        "decamelize": "^1.1.1",
+        "get-caller-file": "^1.0.1",
+        "os-locale": "^1.4.0",
+        "read-pkg-up": "^1.0.1",
+        "require-directory": "^2.1.1",
+        "require-main-filename": "^1.0.1",
+        "set-blocking": "^2.0.0",
+        "string-width": "^1.0.2",
+        "which-module": "^1.0.0",
+        "y18n": "^3.2.1",
+        "yargs-parser": "^5.0.1"
+      }
+    },
+    "node_modules/yargs-parser": {
+      "version": "5.0.1",
+      "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-5.0.1.tgz",
+      "integrity": "sha512-wpav5XYiddjXxirPoCTUPbqM0PXvJ9hiBMvuJgInvo4/lAOTZzUprArw17q2O1P2+GHhbBr18/iQwjL5Z9BqfA==",
+      "dev": true,
+      "dependencies": {
+        "camelcase": "^3.0.0",
+        "object.assign": "^4.1.0"
+      }
+    }
+  },
+  "dependencies": {
+    "@gulp-sourcemaps/identity-map": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/identity-map/-/identity-map-1.0.2.tgz",
+      "integrity": "sha512-ciiioYMLdo16ShmfHBXJBOFm3xPC4AuwO4xeRpFeHz7WK9PYsWCmigagG2XyzZpubK4a3qNKoUBDhbzHfa50LQ==",
+      "dev": true,
+      "requires": {
+        "acorn": "^5.0.3",
+        "css": "^2.2.1",
+        "normalize-path": "^2.1.1",
+        "source-map": "^0.6.0",
+        "through2": "^2.0.3"
+      },
+      "dependencies": {
+        "acorn": {
+          "version": "5.7.4",
+          "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
+          "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
+          "dev": true
+        },
+        "source-map": {
+          "version": "0.6.1",
+          "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+          "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+          "dev": true
+        }
+      }
+    },
+    "@gulp-sourcemaps/map-sources": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz",
+      "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=",
+      "dev": true,
+      "requires": {
+        "normalize-path": "^2.0.1",
+        "through2": "^2.0.3"
+      }
+    },
+    "acorn": {
+      "version": "6.4.2",
+      "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
+      "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==",
+      "dev": true
+    },
+    "acorn-dynamic-import": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
+      "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
+      "dev": true
+    },
+    "acorn-node": {
+      "version": "1.6.1",
+      "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.6.1.tgz",
+      "integrity": "sha512-B+fHENiJB8X0lNQQ/auxOqBC1xWig8RpxUAomCrlLJmNx1Z141WyRjwcEK4Ux7YRq3133H5Q6GYXch0rOa47NQ==",
+      "dev": true,
+      "requires": {
+        "acorn": "^6.0.1",
+        "acorn-dynamic-import": "^4.0.0",
+        "acorn-walk": "^6.0.1",
+        "xtend": "^4.0.1"
+      }
+    },
+    "acorn-walk": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.0.tgz",
+      "integrity": "sha512-ugTb7Lq7u4GfWSqqpwE0bGyoBZNMTok/zDBXxfEG0QM50jNlGhIWjRC1pPN7bvV1anhF+bs+/gNcRw+o55Evbg==",
+      "dev": true
+    },
+    "ansi-colors": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz",
+      "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==",
+      "dev": true,
+      "requires": {
+        "ansi-wrap": "^0.1.0"
+      }
+    },
+    "ansi-gray": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz",
+      "integrity": "sha512-HrgGIZUl8h2EHuZaU9hTR/cU5nhKxpVE1V6kdGsQ8e4zirElJ5fvtfc8N7Q1oq1aatO275i8pUFUCpNWCAnVWw==",
+      "dev": true,
+      "requires": {
+        "ansi-wrap": "0.1.0"
+      }
+    },
+    "ansi-regex": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
+      "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==",
+      "dev": true
+    },
+    "ansi-wrap": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz",
+      "integrity": "sha512-ZyznvL8k/FZeQHr2T6LzcJ/+vBApDnMNZvfVFy3At0knswWd6rJ3/0Hhmpu8oqa6C92npmozs890sX9Dl6q+Qw==",
+      "dev": true
+    },
+    "any-promise": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
+      "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=",
+      "dev": true
+    },
+    "anymatch": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz",
+      "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==",
+      "dev": true,
+      "requires": {
+        "micromatch": "^3.1.4",
+        "normalize-path": "^2.1.1"
+      }
+    },
+    "append-buffer": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/append-buffer/-/append-buffer-1.0.2.tgz",
+      "integrity": "sha512-WLbYiXzD3y/ATLZFufV/rZvWdZOs+Z/+5v1rBZ463Jn398pa6kcde27cvozYnBoxXblGZTFfoPpsaEw0orU5BA==",
+      "dev": true,
+      "requires": {
+        "buffer-equal": "^1.0.0"
+      }
+    },
+    "archy": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz",
+      "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==",
+      "dev": true
+    },
+    "arr-diff": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz",
+      "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==",
+      "dev": true
+    },
+    "arr-filter": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/arr-filter/-/arr-filter-1.1.2.tgz",
+      "integrity": "sha512-A2BETWCqhsecSvCkWAeVBFLH6sXEUGASuzkpjL3GR1SlL/PWL6M3J8EAAld2Uubmh39tvkJTqC9LeLHCUKmFXA==",
+      "dev": true,
+      "requires": {
+        "make-iterator": "^1.0.0"
+      }
+    },
+    "arr-flatten": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
+      "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
+      "dev": true
+    },
+    "arr-map": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/arr-map/-/arr-map-2.0.2.tgz",
+      "integrity": "sha512-tVqVTHt+Q5Xb09qRkbu+DidW1yYzz5izWS2Xm2yFm7qJnmUfz4HPzNxbHkdRJbz2lrqI7S+z17xNYdFcBBO8Hw==",
+      "dev": true,
+      "requires": {
+        "make-iterator": "^1.0.0"
+      }
+    },
+    "arr-union": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz",
+      "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==",
+      "dev": true
+    },
+    "array-each": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz",
+      "integrity": "sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==",
+      "dev": true
+    },
+    "array-initial": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/array-initial/-/array-initial-1.1.0.tgz",
+      "integrity": "sha512-BC4Yl89vneCYfpLrs5JU2aAu9/a+xWbeKhvISg9PT7eWFB9UlRvI+rKEtk6mgxWr3dSkk9gQ8hCrdqt06NXPdw==",
+      "dev": true,
+      "requires": {
+        "array-slice": "^1.0.0",
+        "is-number": "^4.0.0"
+      },
+      "dependencies": {
+        "is-number": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz",
+          "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==",
+          "dev": true
+        }
+      }
+    },
+    "array-last": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/array-last/-/array-last-1.3.0.tgz",
+      "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==",
+      "dev": true,
+      "requires": {
+        "is-number": "^4.0.0"
+      },
+      "dependencies": {
+        "is-number": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz",
+          "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==",
+          "dev": true
+        }
+      }
+    },
+    "array-slice": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz",
+      "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==",
+      "dev": true
+    },
+    "array-sort": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/array-sort/-/array-sort-1.0.0.tgz",
+      "integrity": "sha512-ihLeJkonmdiAsD7vpgN3CRcx2J2S0TiYW+IS/5zHBI7mKUq3ySvBdzzBfD236ubDBQFiiyG3SWCPc+msQ9KoYg==",
+      "dev": true,
+      "requires": {
+        "default-compare": "^1.0.0",
+        "get-value": "^2.0.6",
+        "kind-of": "^5.0.2"
+      }
+    },
+    "array-unique": {
+      "version": "0.3.2",
+      "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
+      "integrity": "sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==",
+      "dev": true
+    },
+    "asn1.js": {
+      "version": "4.10.1",
+      "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz",
+      "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==",
+      "dev": true,
+      "requires": {
+        "bn.js": "^4.0.0",
+        "inherits": "^2.0.1",
+        "minimalistic-assert": "^1.0.0"
+      }
+    },
+    "assert": {
+      "version": "1.4.1",
+      "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz",
+      "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=",
+      "dev": true,
+      "requires": {
+        "util": "0.10.3"
+      },
+      "dependencies": {
+        "inherits": {
+          "version": "2.0.1",
+          "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
+          "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=",
+          "dev": true
+        },
+        "util": {
+          "version": "0.10.3",
+          "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
+          "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
+          "dev": true,
+          "requires": {
+            "inherits": "2.0.1"
+          }
+        }
+      }
+    },
+    "assign-symbols": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
+      "integrity": "sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==",
+      "dev": true
+    },
+    "async-done": {
+      "version": "1.3.2",
+      "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.2.tgz",
+      "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==",
+      "dev": true,
+      "requires": {
+        "end-of-stream": "^1.1.0",
+        "once": "^1.3.2",
+        "process-nextick-args": "^2.0.0",
+        "stream-exhaust": "^1.0.1"
+      },
+      "dependencies": {
+        "process-nextick-args": {
+          "version": "2.0.1",
+          "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
+          "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
+          "dev": true
+        }
+      }
+    },
+    "async-each": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz",
+      "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==",
+      "dev": true
+    },
+    "async-settle": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/async-settle/-/async-settle-1.0.0.tgz",
+      "integrity": "sha512-VPXfB4Vk49z1LHHodrEQ6Xf7W4gg1w0dAPROHngx7qgDjqmIQ+fXmwgGXTW/ITLai0YLSvWepJOP9EVpMnEAcw==",
+      "dev": true,
+      "requires": {
+        "async-done": "^1.2.2"
+      }
+    },
+    "atob": {
+      "version": "2.1.2",
+      "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
+      "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==",
+      "dev": true
+    },
+    "bach": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz",
+      "integrity": "sha512-bZOOfCb3gXBXbTFXq3OZtGR88LwGeJvzu6szttaIzymOTS4ZttBNOWSv7aLZja2EMycKtRYV0Oa8SNKH/zkxvg==",
+      "dev": true,
+      "requires": {
+        "arr-filter": "^1.1.1",
+        "arr-flatten": "^1.0.1",
+        "arr-map": "^2.0.0",
+        "array-each": "^1.0.0",
+        "array-initial": "^1.0.0",
+        "array-last": "^1.1.1",
+        "async-done": "^1.2.2",
+        "async-settle": "^1.0.0",
+        "now-and-later": "^2.0.0"
+      }
+    },
+    "balanced-match": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
+      "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+      "dev": true
+    },
+    "base": {
+      "version": "0.11.2",
+      "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz",
+      "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==",
+      "dev": true,
+      "requires": {
+        "cache-base": "^1.0.1",
+        "class-utils": "^0.3.5",
+        "component-emitter": "^1.2.1",
+        "define-property": "^1.0.0",
+        "isobject": "^3.0.1",
+        "mixin-deep": "^1.2.0",
+        "pascalcase": "^0.1.1"
+      },
+      "dependencies": {
+        "define-property": {
+          "version": "1.0.0",
+          "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
+          "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==",
+          "dev": true,
+          "requires": {
+            "is-descriptor": "^1.0.0"
+          }
+        }
+      }
+    },
+    "base64-js": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
+      "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==",
+      "dev": true
+    },
+    "binary-extensions": {
+      "version": "1.13.1",
+      "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz",
+      "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==",
+      "dev": true
+    },
+    "bindings": {
+      "version": "1.5.0",
+      "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
+      "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
+      "dev": true,
+      "optional": true,
+      "requires": {
+        "file-uri-to-path": "1.0.0"
+      }
+    },
+    "bl": {
+      "version": "1.2.3",
+      "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz",
+      "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==",
+      "dev": true,
+      "requires": {
+        "readable-stream": "^2.3.5",
+        "safe-buffer": "^5.1.1"
+      }
+    },
+    "bn.js": {
+      "version": "4.12.0",
+      "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
+      "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==",
+      "dev": true
+    },
+    "brace-expansion": {
+      "version": "1.1.8",
+      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
+      "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
+      "dev": true,
+      "requires": {
+        "balanced-match": "^1.0.0",
+        "concat-map": "0.0.1"
+      }
+    },
+    "braces": {
+      "version": "2.3.2",
+      "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz",
+      "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==",
+      "dev": true,
+      "requires": {
+        "arr-flatten": "^1.1.0",
+        "array-unique": "^0.3.2",
+        "extend-shallow": "^2.0.1",
+        "fill-range": "^4.0.0",
+        "isobject": "^3.0.1",
+        "repeat-element": "^1.1.2",
+        "snapdragon": "^0.8.1",
+        "snapdragon-node": "^2.0.1",
+        "split-string": "^3.0.2",
+        "to-regex": "^3.0.1"
+      }
+    },
+    "brorand": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
+      "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
+      "dev": true
+    },
+    "browser-pack": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz",
+      "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==",
+      "dev": true,
+      "requires": {
+        "combine-source-map": "~0.8.0",
+        "defined": "^1.0.0",
+        "JSONStream": "^1.0.3",
+        "safe-buffer": "^5.1.1",
+        "through2": "^2.0.0",
+        "umd": "^3.0.0"
+      }
+    },
+    "browser-resolve": {
+      "version": "1.11.3",
+      "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz",
+      "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==",
+      "dev": true,
+      "requires": {
+        "resolve": "1.1.7"
+      },
+      "dependencies": {
+        "resolve": {
+          "version": "1.1.7",
+          "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz",
+          "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=",
+          "dev": true
+        }
+      }
+    },
+    "browserify": {
+      "version": "14.5.0",
+      "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.5.0.tgz",
+      "integrity": "sha512-gKfOsNQv/toWz+60nSPfYzuwSEdzvV2WdxrVPUbPD/qui44rAkB3t3muNtmmGYHqrG56FGwX9SUEQmzNLAeS7g==",
+      "dev": true,
+      "requires": {
+        "assert": "^1.4.0",
+        "browser-pack": "^6.0.1",
+        "browser-resolve": "^1.11.0",
+        "browserify-zlib": "~0.2.0",
+        "buffer": "^5.0.2",
+        "cached-path-relative": "^1.0.0",
+        "concat-stream": "~1.5.1",
+        "console-browserify": "^1.1.0",
+        "constants-browserify": "~1.0.0",
+        "crypto-browserify": "^3.0.0",
+        "defined": "^1.0.0",
+        "deps-sort": "^2.0.0",
+        "domain-browser": "~1.1.0",
+        "duplexer2": "~0.1.2",
+        "events": "~1.1.0",
+        "glob": "^7.1.0",
+        "has": "^1.0.0",
+        "htmlescape": "^1.1.0",
+        "https-browserify": "^1.0.0",
+        "inherits": "~2.0.1",
+        "insert-module-globals": "^7.0.0",
+        "JSONStream": "^1.0.3",
+        "labeled-stream-splicer": "^2.0.0",
+        "module-deps": "^4.0.8",
+        "os-browserify": "~0.3.0",
+        "parents": "^1.0.1",
+        "path-browserify": "~0.0.0",
+        "process": "~0.11.0",
+        "punycode": "^1.3.2",
+        "querystring-es3": "~0.2.0",
+        "read-only-stream": "^2.0.0",
+        "readable-stream": "^2.0.2",
+        "resolve": "^1.1.4",
+        "shasum": "^1.0.0",
+        "shell-quote": "^1.6.1",
+        "stream-browserify": "^2.0.0",
+        "stream-http": "^2.0.0",
+        "string_decoder": "~1.0.0",
+        "subarg": "^1.0.0",
+        "syntax-error": "^1.1.1",
+        "through2": "^2.0.0",
+        "timers-browserify": "^1.0.1",
+        "tty-browserify": "~0.0.0",
+        "url": "~0.11.0",
+        "util": "~0.10.1",
+        "vm-browserify": "~0.0.1",
+        "xtend": "^4.0.0"
+      }
+    },
+    "browserify-aes": {
+      "version": "1.2.0",
+      "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
+      "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
+      "dev": true,
+      "requires": {
+        "buffer-xor": "^1.0.3",
+        "cipher-base": "^1.0.0",
+        "create-hash": "^1.1.0",
+        "evp_bytestokey": "^1.0.3",
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.0.1"
+      }
+    },
+    "browserify-cipher": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz",
+      "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==",
+      "dev": true,
+      "requires": {
+        "browserify-aes": "^1.0.4",
+        "browserify-des": "^1.0.0",
+        "evp_bytestokey": "^1.0.0"
+      }
+    },
+    "browserify-des": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz",
+      "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==",
+      "dev": true,
+      "requires": {
+        "cipher-base": "^1.0.1",
+        "des.js": "^1.0.0",
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.1.2"
+      },
+      "dependencies": {
+        "safe-buffer": {
+          "version": "5.1.2",
+          "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+          "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+          "dev": true
+        }
+      }
+    },
+    "browserify-rsa": {
+      "version": "4.0.1",
+      "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
+      "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
+      "dev": true,
+      "requires": {
+        "bn.js": "^4.1.0",
+        "randombytes": "^2.0.1"
+      }
+    },
+    "browserify-sign": {
+      "version": "4.0.4",
+      "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz",
+      "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=",
+      "dev": true,
+      "requires": {
+        "bn.js": "^4.1.1",
+        "browserify-rsa": "^4.0.0",
+        "create-hash": "^1.1.0",
+        "create-hmac": "^1.1.2",
+        "elliptic": "^6.0.0",
+        "inherits": "^2.0.1",
+        "parse-asn1": "^5.0.0"
+      }
+    },
+    "browserify-zlib": {
+      "version": "0.2.0",
+      "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz",
+      "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==",
+      "dev": true,
+      "requires": {
+        "pako": "~1.0.5"
+      }
+    },
+    "buffer": {
+      "version": "5.2.1",
+      "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz",
+      "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==",
+      "dev": true,
+      "requires": {
+        "base64-js": "^1.0.2",
+        "ieee754": "^1.1.4"
+      }
+    },
+    "buffer-equal": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz",
+      "integrity": "sha512-tcBWO2Dl4e7Asr9hTGcpVrCe+F7DubpmqWCTbj4FHLmjqO2hIaC383acQubWtRJhdceqs5uBHs6Es+Sk//RKiQ==",
+      "dev": true
+    },
+    "buffer-from": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
+      "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
+      "dev": true
+    },
+    "buffer-xor": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
+      "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
+      "dev": true
+    },
+    "builtin-status-codes": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz",
+      "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=",
+      "dev": true
+    },
+    "cache-base": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
+      "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==",
+      "dev": true,
+      "requires": {
+        "collection-visit": "^1.0.0",
+        "component-emitter": "^1.2.1",
+        "get-value": "^2.0.6",
+        "has-value": "^1.0.0",
+        "isobject": "^3.0.1",
+        "set-value": "^2.0.0",
+        "to-object-path": "^0.3.0",
+        "union-value": "^1.0.0",
+        "unset-value": "^1.0.0"
+      }
+    },
+    "cached-path-relative": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.1.0.tgz",
+      "integrity": "sha512-WF0LihfemtesFcJgO7xfOoOcnWzY/QHR4qeDqV44jPU3HTI54+LnfXK3SA27AVVGCdZFgjjFFaqUA9Jx7dMJZA==",
+      "dev": true
+    },
+    "call-bind": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
+      "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
+      "dev": true,
+      "requires": {
+        "function-bind": "^1.1.1",
+        "get-intrinsic": "^1.0.2"
+      }
+    },
+    "camelcase": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz",
+      "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==",
+      "dev": true
+    },
+    "chokidar": {
+      "version": "2.1.8",
+      "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",
+      "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==",
+      "dev": true,
+      "requires": {
+        "anymatch": "^2.0.0",
+        "async-each": "^1.0.1",
+        "braces": "^2.3.2",
+        "fsevents": "^1.2.7",
+        "glob-parent": "^3.1.0",
+        "inherits": "^2.0.3",
+        "is-binary-path": "^1.0.0",
+        "is-glob": "^4.0.0",
+        "normalize-path": "^3.0.0",
+        "path-is-absolute": "^1.0.0",
+        "readdirp": "^2.2.1",
+        "upath": "^1.1.1"
+      },
+      "dependencies": {
+        "normalize-path": {
+          "version": "3.0.0",
+          "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
+          "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
+          "dev": true
+        }
+      }
+    },
+    "cipher-base": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
+      "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.0.1"
+      }
+    },
+    "class-utils": {
+      "version": "0.3.6",
+      "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",
+      "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==",
+      "dev": true,
+      "requires": {
+        "arr-union": "^3.1.0",
+        "define-property": "^0.2.5",
+        "isobject": "^3.0.0",
+        "static-extend": "^0.1.1"
+      },
+      "dependencies": {
+        "define-property": {
+          "version": "0.2.5",
+          "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+          "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+          "dev": true,
+          "requires": {
+            "is-descriptor": "^0.1.0"
+          }
+        },
+        "is-accessor-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+          "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          },
+          "dependencies": {
+            "kind-of": {
+              "version": "3.2.2",
+              "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+              "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+              "dev": true,
+              "requires": {
+                "is-buffer": "^1.1.5"
+              }
+            }
+          }
+        },
+        "is-data-descriptor": {
+          "version": "0.1.4",
+          "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+          "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          },
+          "dependencies": {
+            "kind-of": {
+              "version": "3.2.2",
+              "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+              "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+              "dev": true,
+              "requires": {
+                "is-buffer": "^1.1.5"
+              }
+            }
+          }
+        },
+        "is-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+          "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+          "dev": true,
+          "requires": {
+            "is-accessor-descriptor": "^0.1.6",
+            "is-data-descriptor": "^0.1.4",
+            "kind-of": "^5.0.0"
+          }
+        }
+      }
+    },
+    "cliui": {
+      "version": "3.2.0",
+      "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
+      "integrity": "sha512-0yayqDxWQbqk3ojkYqUKqaAQ6AfNKeKWRNA8kR0WXzAsdHpP4BIaOmMAG87JGuO6qcobyW4GjxHd9PmhEd+T9w==",
+      "dev": true,
+      "requires": {
+        "string-width": "^1.0.1",
+        "strip-ansi": "^3.0.1",
+        "wrap-ansi": "^2.0.0"
+      }
+    },
+    "clone-buffer": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz",
+      "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=",
+      "dev": true
+    },
+    "cloneable-readable": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.2.tgz",
+      "integrity": "sha512-Bq6+4t+lbM8vhTs/Bef5c5AdEMtapp/iFb6+s4/Hh9MVTt8OLKH7ZOOZSCT+Ys7hsHvqv0GuMPJ1lnQJVHvxpg==",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.1",
+        "process-nextick-args": "^2.0.0",
+        "readable-stream": "^2.3.5"
+      },
+      "dependencies": {
+        "process-nextick-args": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
+          "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
+          "dev": true
+        }
+      }
+    },
+    "code-point-at": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
+      "integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==",
+      "dev": true
+    },
+    "collection-map": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/collection-map/-/collection-map-1.0.0.tgz",
+      "integrity": "sha512-5D2XXSpkOnleOI21TG7p3T0bGAsZ/XknZpKBmGYyluO8pw4zA3K8ZlrBIbC4FXg3m6z/RNFiUFfT2sQK01+UHA==",
+      "dev": true,
+      "requires": {
+        "arr-map": "^2.0.2",
+        "for-own": "^1.0.0",
+        "make-iterator": "^1.0.0"
+      }
+    },
+    "collection-visit": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
+      "integrity": "sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==",
+      "dev": true,
+      "requires": {
+        "map-visit": "^1.0.0",
+        "object-visit": "^1.0.0"
+      }
+    },
+    "color-support": {
+      "version": "1.1.3",
+      "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
+      "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==",
+      "dev": true
+    },
+    "combine-source-map": {
+      "version": "0.8.0",
+      "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz",
+      "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=",
+      "dev": true,
+      "requires": {
+        "convert-source-map": "~1.1.0",
+        "inline-source-map": "~0.6.0",
+        "lodash.memoize": "~3.0.3",
+        "source-map": "~0.5.3"
+      }
+    },
+    "commander": {
+      "version": "2.17.1",
+      "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz",
+      "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==",
+      "dev": true
+    },
+    "component-emitter": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz",
+      "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==",
+      "dev": true
+    },
+    "concat-map": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+      "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+      "dev": true
+    },
+    "concat-stream": {
+      "version": "1.5.2",
+      "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz",
+      "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=",
+      "dev": true,
+      "requires": {
+        "inherits": "~2.0.1",
+        "readable-stream": "~2.0.0",
+        "typedarray": "~0.0.5"
+      },
+      "dependencies": {
+        "readable-stream": {
+          "version": "2.0.6",
+          "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz",
+          "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=",
+          "dev": true,
+          "requires": {
+            "core-util-is": "~1.0.0",
+            "inherits": "~2.0.1",
+            "isarray": "~1.0.0",
+            "process-nextick-args": "~1.0.6",
+            "string_decoder": "~0.10.x",
+            "util-deprecate": "~1.0.1"
+          }
+        },
+        "string_decoder": {
+          "version": "0.10.31",
+          "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+          "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+          "dev": true
+        }
+      }
+    },
+    "console-browserify": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",
+      "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=",
+      "dev": true,
+      "requires": {
+        "date-now": "^0.1.4"
+      }
+    },
+    "constants-browserify": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz",
+      "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=",
+      "dev": true
+    },
+    "convert-source-map": {
+      "version": "1.1.3",
+      "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz",
+      "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=",
+      "dev": true
+    },
+    "copy-descriptor": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
+      "integrity": "sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==",
+      "dev": true
+    },
+    "copy-props": {
+      "version": "2.0.5",
+      "resolved": "https://registry.npmjs.org/copy-props/-/copy-props-2.0.5.tgz",
+      "integrity": "sha512-XBlx8HSqrT0ObQwmSzM7WE5k8FxTV75h1DX1Z3n6NhQ/UYYAvInWYmG06vFt7hQZArE2fuO62aihiWIVQwh1sw==",
+      "dev": true,
+      "requires": {
+        "each-props": "^1.3.2",
+        "is-plain-object": "^5.0.0"
+      }
+    },
+    "core-util-is": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+      "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
+      "dev": true
+    },
+    "create-ecdh": {
+      "version": "4.0.3",
+      "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz",
+      "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==",
+      "dev": true,
+      "requires": {
+        "bn.js": "^4.1.0",
+        "elliptic": "^6.0.0"
+      }
+    },
+    "create-hash": {
+      "version": "1.2.0",
+      "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
+      "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
+      "dev": true,
+      "requires": {
+        "cipher-base": "^1.0.1",
+        "inherits": "^2.0.1",
+        "md5.js": "^1.3.4",
+        "ripemd160": "^2.0.1",
+        "sha.js": "^2.4.0"
+      }
+    },
+    "create-hmac": {
+      "version": "1.1.7",
+      "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
+      "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
+      "dev": true,
+      "requires": {
+        "cipher-base": "^1.0.3",
+        "create-hash": "^1.1.0",
+        "inherits": "^2.0.1",
+        "ripemd160": "^2.0.0",
+        "safe-buffer": "^5.0.1",
+        "sha.js": "^2.4.8"
+      }
+    },
+    "crypto-browserify": {
+      "version": "3.12.0",
+      "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz",
+      "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==",
+      "dev": true,
+      "requires": {
+        "browserify-cipher": "^1.0.0",
+        "browserify-sign": "^4.0.0",
+        "create-ecdh": "^4.0.0",
+        "create-hash": "^1.1.0",
+        "create-hmac": "^1.1.0",
+        "diffie-hellman": "^5.0.0",
+        "inherits": "^2.0.1",
+        "pbkdf2": "^3.0.3",
+        "public-encrypt": "^4.0.0",
+        "randombytes": "^2.0.0",
+        "randomfill": "^1.0.3"
+      }
+    },
+    "css": {
+      "version": "2.2.4",
+      "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz",
+      "integrity": "sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.3",
+        "source-map": "^0.6.1",
+        "source-map-resolve": "^0.5.2",
+        "urix": "^0.1.0"
+      },
+      "dependencies": {
+        "source-map": {
+          "version": "0.6.1",
+          "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+          "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+          "dev": true
+        }
+      }
+    },
+    "d": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz",
+      "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=",
+      "dev": true,
+      "requires": {
+        "es5-ext": "^0.10.9"
+      }
+    },
+    "date-now": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
+      "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=",
+      "dev": true
+    },
+    "debug": {
+      "version": "2.6.9",
+      "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+      "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+      "dev": true,
+      "requires": {
+        "ms": "2.0.0"
+      }
+    },
+    "debug-fabulous": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/debug-fabulous/-/debug-fabulous-1.1.0.tgz",
+      "integrity": "sha512-GZqvGIgKNlUnHUPQhepnUZFIMoi3dgZKQBzKDeL2g7oJF9SNAji/AAu36dusFUas0O+pae74lNeoIPHqXWDkLg==",
+      "dev": true,
+      "requires": {
+        "debug": "3.X",
+        "memoizee": "0.4.X",
+        "object-assign": "4.X"
+      },
+      "dependencies": {
+        "debug": {
+          "version": "3.2.6",
+          "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
+          "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
+          "dev": true,
+          "requires": {
+            "ms": "^2.1.1"
+          }
+        },
+        "ms": {
+          "version": "2.1.1",
+          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
+          "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==",
+          "dev": true
+        }
+      }
+    },
+    "decamelize": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
+      "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
+      "dev": true
+    },
+    "decode-uri-component": {
+      "version": "0.2.0",
+      "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
+      "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=",
+      "dev": true
+    },
+    "default-compare": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz",
+      "integrity": "sha512-QWfXlM0EkAbqOCbD/6HjdwT19j7WCkMyiRhWilc4H9/5h/RzTF9gv5LYh1+CmDV5d1rki6KAWLtQale0xt20eQ==",
+      "dev": true,
+      "requires": {
+        "kind-of": "^5.0.2"
+      }
+    },
+    "default-resolution": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/default-resolution/-/default-resolution-2.0.0.tgz",
+      "integrity": "sha512-2xaP6GiwVwOEbXCGoJ4ufgC76m8cj805jrghScewJC2ZDsb9U0b4BIrba+xt/Uytyd0HvQ6+WymSRTfnYj59GQ==",
+      "dev": true
+    },
+    "define-properties": {
+      "version": "1.1.4",
+      "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz",
+      "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==",
+      "dev": true,
+      "requires": {
+        "has-property-descriptors": "^1.0.0",
+        "object-keys": "^1.1.1"
+      }
+    },
+    "define-property": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz",
+      "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==",
+      "dev": true,
+      "requires": {
+        "is-descriptor": "^1.0.2",
+        "isobject": "^3.0.1"
+      }
+    },
+    "defined": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz",
+      "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
+      "dev": true
+    },
+    "deps-sort": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz",
+      "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=",
+      "dev": true,
+      "requires": {
+        "JSONStream": "^1.0.3",
+        "shasum": "^1.0.0",
+        "subarg": "^1.0.0",
+        "through2": "^2.0.0"
+      }
+    },
+    "des.js": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz",
+      "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.1",
+        "minimalistic-assert": "^1.0.0"
+      }
+    },
+    "detect-file": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz",
+      "integrity": "sha512-DtCOLG98P007x7wiiOmfI0fi3eIKyWiLTGJ2MDnVi/E04lWGbf+JzrRHMm0rgIIZJGtHpKpbVgLWHrv8xXpc3Q==",
+      "dev": true
+    },
+    "detect-newline": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz",
+      "integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=",
+      "dev": true
+    },
+    "detective": {
+      "version": "4.7.1",
+      "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz",
+      "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==",
+      "dev": true,
+      "requires": {
+        "acorn": "^5.2.1",
+        "defined": "^1.0.0"
+      },
+      "dependencies": {
+        "acorn": {
+          "version": "5.7.4",
+          "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
+          "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
+          "dev": true
+        }
+      }
+    },
+    "diffie-hellman": {
+      "version": "5.0.3",
+      "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
+      "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
+      "dev": true,
+      "requires": {
+        "bn.js": "^4.1.0",
+        "miller-rabin": "^4.0.0",
+        "randombytes": "^2.0.0"
+      }
+    },
+    "domain-browser": {
+      "version": "1.1.7",
+      "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz",
+      "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=",
+      "dev": true
+    },
+    "duplexer2": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
+      "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=",
+      "dev": true,
+      "requires": {
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "duplexify": {
+      "version": "3.7.1",
+      "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz",
+      "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==",
+      "dev": true,
+      "requires": {
+        "end-of-stream": "^1.0.0",
+        "inherits": "^2.0.1",
+        "readable-stream": "^2.0.0",
+        "stream-shift": "^1.0.0"
+      }
+    },
+    "each-props": {
+      "version": "1.3.2",
+      "resolved": "https://registry.npmjs.org/each-props/-/each-props-1.3.2.tgz",
+      "integrity": "sha512-vV0Hem3zAGkJAyU7JSjixeU66rwdynTAa1vofCrSA5fEln+m67Az9CcnkVD776/fsN/UjIWmBDoNRS6t6G9RfA==",
+      "dev": true,
+      "requires": {
+        "is-plain-object": "^2.0.1",
+        "object.defaults": "^1.1.0"
+      },
+      "dependencies": {
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        }
+      }
+    },
+    "elliptic": {
+      "version": "6.5.4",
+      "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
+      "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
+      "dev": true,
+      "requires": {
+        "bn.js": "^4.11.9",
+        "brorand": "^1.1.0",
+        "hash.js": "^1.0.0",
+        "hmac-drbg": "^1.0.1",
+        "inherits": "^2.0.4",
+        "minimalistic-assert": "^1.0.1",
+        "minimalistic-crypto-utils": "^1.0.1"
+      },
+      "dependencies": {
+        "inherits": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+          "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+          "dev": true
+        }
+      }
+    },
+    "end-of-stream": {
+      "version": "1.4.4",
+      "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
+      "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
+      "dev": true,
+      "requires": {
+        "once": "^1.4.0"
+      }
+    },
+    "error-ex": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz",
+      "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=",
+      "dev": true,
+      "requires": {
+        "is-arrayish": "^0.2.1"
+      }
+    },
+    "es5-ext": {
+      "version": "0.10.30",
+      "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.30.tgz",
+      "integrity": "sha1-cUGhaDZpfbq/qq7uQUlc4p9SyTk=",
+      "dev": true,
+      "requires": {
+        "es6-iterator": "2",
+        "es6-symbol": "~3.1"
+      }
+    },
+    "es6-iterator": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz",
+      "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=",
+      "dev": true,
+      "requires": {
+        "d": "1",
+        "es5-ext": "^0.10.14",
+        "es6-symbol": "^3.1"
+      }
+    },
+    "es6-symbol": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz",
+      "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=",
+      "dev": true,
+      "requires": {
+        "d": "1",
+        "es5-ext": "~0.10.14"
+      }
+    },
+    "es6-weak-map": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz",
+      "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=",
+      "dev": true,
+      "requires": {
+        "d": "1",
+        "es5-ext": "^0.10.14",
+        "es6-iterator": "^2.0.1",
+        "es6-symbol": "^3.1.1"
+      }
+    },
+    "event-emitter": {
+      "version": "0.3.5",
+      "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
+      "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=",
+      "dev": true,
+      "requires": {
+        "d": "1",
+        "es5-ext": "~0.10.14"
+      }
+    },
+    "events": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
+      "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=",
+      "dev": true
+    },
+    "evp_bytestokey": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz",
+      "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==",
+      "dev": true,
+      "requires": {
+        "md5.js": "^1.3.4",
+        "safe-buffer": "^5.1.1"
+      }
+    },
+    "expand-brackets": {
+      "version": "2.1.4",
+      "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz",
+      "integrity": "sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==",
+      "dev": true,
+      "requires": {
+        "debug": "^2.3.3",
+        "define-property": "^0.2.5",
+        "extend-shallow": "^2.0.1",
+        "posix-character-classes": "^0.1.0",
+        "regex-not": "^1.0.0",
+        "snapdragon": "^0.8.1",
+        "to-regex": "^3.0.1"
+      },
+      "dependencies": {
+        "define-property": {
+          "version": "0.2.5",
+          "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+          "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+          "dev": true,
+          "requires": {
+            "is-descriptor": "^0.1.0"
+          }
+        },
+        "is-accessor-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+          "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          },
+          "dependencies": {
+            "kind-of": {
+              "version": "3.2.2",
+              "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+              "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+              "dev": true,
+              "requires": {
+                "is-buffer": "^1.1.5"
+              }
+            }
+          }
+        },
+        "is-data-descriptor": {
+          "version": "0.1.4",
+          "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+          "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          },
+          "dependencies": {
+            "kind-of": {
+              "version": "3.2.2",
+              "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+              "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+              "dev": true,
+              "requires": {
+                "is-buffer": "^1.1.5"
+              }
+            }
+          }
+        },
+        "is-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+          "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+          "dev": true,
+          "requires": {
+            "is-accessor-descriptor": "^0.1.6",
+            "is-data-descriptor": "^0.1.4",
+            "kind-of": "^5.0.0"
+          }
+        }
+      }
+    },
+    "expand-tilde": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz",
+      "integrity": "sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==",
+      "dev": true,
+      "requires": {
+        "homedir-polyfill": "^1.0.1"
+      }
+    },
+    "extend": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
+      "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
+      "dev": true
+    },
+    "extend-shallow": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+      "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==",
+      "dev": true,
+      "requires": {
+        "is-extendable": "^0.1.0"
+      }
+    },
+    "extglob": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz",
+      "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==",
+      "dev": true,
+      "requires": {
+        "array-unique": "^0.3.2",
+        "define-property": "^1.0.0",
+        "expand-brackets": "^2.1.4",
+        "extend-shallow": "^2.0.1",
+        "fragment-cache": "^0.2.1",
+        "regex-not": "^1.0.0",
+        "snapdragon": "^0.8.1",
+        "to-regex": "^3.0.1"
+      },
+      "dependencies": {
+        "define-property": {
+          "version": "1.0.0",
+          "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
+          "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==",
+          "dev": true,
+          "requires": {
+            "is-descriptor": "^1.0.0"
+          }
+        }
+      }
+    },
+    "fancy-log": {
+      "version": "1.3.3",
+      "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz",
+      "integrity": "sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw==",
+      "dev": true,
+      "requires": {
+        "ansi-gray": "^0.1.1",
+        "color-support": "^1.1.3",
+        "parse-node-version": "^1.0.0",
+        "time-stamp": "^1.0.0"
+      }
+    },
+    "fast-levenshtein": {
+      "version": "1.1.4",
+      "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz",
+      "integrity": "sha512-Ia0sQNrMPXXkqVFt6w6M1n1oKo3NfKs+mvaV811Jwir7vAk9a6PVV9VPYf6X3BU97QiLEmuW3uXH9u87zDFfdw==",
+      "dev": true
+    },
+    "file-uri-to-path": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
+      "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
+      "dev": true,
+      "optional": true
+    },
+    "fill-range": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz",
+      "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==",
+      "dev": true,
+      "requires": {
+        "extend-shallow": "^2.0.1",
+        "is-number": "^3.0.0",
+        "repeat-string": "^1.6.1",
+        "to-regex-range": "^2.1.0"
+      }
+    },
+    "find-up": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
+      "integrity": "sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==",
+      "dev": true,
+      "requires": {
+        "path-exists": "^2.0.0",
+        "pinkie-promise": "^2.0.0"
+      }
+    },
+    "findup-sync": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz",
+      "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==",
+      "dev": true,
+      "requires": {
+        "detect-file": "^1.0.0",
+        "is-glob": "^4.0.0",
+        "micromatch": "^3.0.4",
+        "resolve-dir": "^1.0.1"
+      }
+    },
+    "fined": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz",
+      "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==",
+      "dev": true,
+      "requires": {
+        "expand-tilde": "^2.0.2",
+        "is-plain-object": "^2.0.3",
+        "object.defaults": "^1.1.0",
+        "object.pick": "^1.2.0",
+        "parse-filepath": "^1.0.1"
+      },
+      "dependencies": {
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        }
+      }
+    },
+    "flagged-respawn": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz",
+      "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==",
+      "dev": true
+    },
+    "flush-write-stream": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz",
+      "integrity": "sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w==",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.3",
+        "readable-stream": "^2.3.6"
+      }
+    },
+    "for-in": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
+      "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==",
+      "dev": true
+    },
+    "for-own": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz",
+      "integrity": "sha512-0OABksIGrxKK8K4kynWkQ7y1zounQxP+CWnyclVwj81KW3vlLlGUx57DKGcP/LH216GzqnstnPocF16Nxs0Ycg==",
+      "dev": true,
+      "requires": {
+        "for-in": "^1.0.1"
+      }
+    },
+    "fragment-cache": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
+      "integrity": "sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==",
+      "dev": true,
+      "requires": {
+        "map-cache": "^0.2.2"
+      }
+    },
+    "fs-mkdirp-stream": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz",
+      "integrity": "sha512-+vSd9frUnapVC2RZYfL3FCB2p3g4TBhaUmrsWlSudsGdnxIuUvBB2QM1VZeBtc49QFwrp+wQLrDs3+xxDgI5gQ==",
+      "dev": true,
+      "requires": {
+        "graceful-fs": "^4.1.11",
+        "through2": "^2.0.3"
+      }
+    },
+    "fs.realpath": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+      "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
+      "dev": true
+    },
+    "fsevents": {
+      "version": "1.2.13",
+      "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
+      "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
+      "dev": true,
+      "optional": true,
+      "requires": {
+        "bindings": "^1.5.0",
+        "nan": "^2.12.1"
+      }
+    },
+    "function-bind": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
+      "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
+      "dev": true
+    },
+    "fuse.js": {
+      "version": "3.3.0",
+      "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-3.3.0.tgz",
+      "integrity": "sha512-ESBRkGLWMuVkapqYCcNO1uqMg5qbCKkgb+VS6wsy17Rix0/cMS9kSOZoYkjH8Ko//pgJ/EEGu0GTjk2mjX2LGQ=="
+    },
+    "get-assigned-identifiers": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz",
+      "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==",
+      "dev": true
+    },
+    "get-caller-file": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
+      "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==",
+      "dev": true
+    },
+    "get-intrinsic": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.2.tgz",
+      "integrity": "sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==",
+      "dev": true,
+      "requires": {
+        "function-bind": "^1.1.1",
+        "has": "^1.0.3",
+        "has-symbols": "^1.0.3"
+      }
+    },
+    "get-value": {
+      "version": "2.0.6",
+      "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz",
+      "integrity": "sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==",
+      "dev": true
+    },
+    "glob": {
+      "version": "7.1.3",
+      "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
+      "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
+      "dev": true,
+      "requires": {
+        "fs.realpath": "^1.0.0",
+        "inflight": "^1.0.4",
+        "inherits": "2",
+        "minimatch": "^3.0.4",
+        "once": "^1.3.0",
+        "path-is-absolute": "^1.0.0"
+      }
+    },
+    "glob-parent": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
+      "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==",
+      "dev": true,
+      "requires": {
+        "is-glob": "^3.1.0",
+        "path-dirname": "^1.0.0"
+      },
+      "dependencies": {
+        "is-glob": {
+          "version": "3.1.0",
+          "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz",
+          "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==",
+          "dev": true,
+          "requires": {
+            "is-extglob": "^2.1.0"
+          }
+        }
+      }
+    },
+    "glob-stream": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz",
+      "integrity": "sha512-uMbLGAP3S2aDOHUDfdoYcdIePUCfysbAd0IAoWVZbeGU/oNQ8asHVSshLDJUPWxfzj8zsCG7/XeHPHTtow0nsw==",
+      "dev": true,
+      "requires": {
+        "extend": "^3.0.0",
+        "glob": "^7.1.1",
+        "glob-parent": "^3.1.0",
+        "is-negated-glob": "^1.0.0",
+        "ordered-read-streams": "^1.0.0",
+        "pumpify": "^1.3.5",
+        "readable-stream": "^2.1.5",
+        "remove-trailing-separator": "^1.0.1",
+        "to-absolute-glob": "^2.0.0",
+        "unique-stream": "^2.0.2"
+      }
+    },
+    "glob-watcher": {
+      "version": "5.0.5",
+      "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-5.0.5.tgz",
+      "integrity": "sha512-zOZgGGEHPklZNjZQaZ9f41i7F2YwE+tS5ZHrDhbBCk3stwahn5vQxnFmBJZHoYdusR6R1bLSXeGUy/BhctwKzw==",
+      "dev": true,
+      "requires": {
+        "anymatch": "^2.0.0",
+        "async-done": "^1.2.0",
+        "chokidar": "^2.0.0",
+        "is-negated-glob": "^1.0.0",
+        "just-debounce": "^1.0.0",
+        "normalize-path": "^3.0.0",
+        "object.defaults": "^1.1.0"
+      },
+      "dependencies": {
+        "normalize-path": {
+          "version": "3.0.0",
+          "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
+          "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
+          "dev": true
+        }
+      }
+    },
+    "global-modules": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz",
+      "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==",
+      "dev": true,
+      "requires": {
+        "global-prefix": "^1.0.1",
+        "is-windows": "^1.0.1",
+        "resolve-dir": "^1.0.0"
+      }
+    },
+    "global-prefix": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz",
+      "integrity": "sha512-5lsx1NUDHtSjfg0eHlmYvZKv8/nVqX4ckFbM+FrGcQ+04KWcWFo9P5MxPZYSzUvyzmdTbI7Eix8Q4IbELDqzKg==",
+      "dev": true,
+      "requires": {
+        "expand-tilde": "^2.0.2",
+        "homedir-polyfill": "^1.0.1",
+        "ini": "^1.3.4",
+        "is-windows": "^1.0.1",
+        "which": "^1.2.14"
+      }
+    },
+    "glogg": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz",
+      "integrity": "sha1-f+DxmfV6yQbPUS/urY+Q7kooT8U=",
+      "dev": true,
+      "requires": {
+        "sparkles": "^1.0.0"
+      }
+    },
+    "graceful-fs": {
+      "version": "4.1.11",
+      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
+      "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
+      "dev": true
+    },
+    "gulp": {
+      "version": "4.0.2",
+      "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz",
+      "integrity": "sha512-dvEs27SCZt2ibF29xYgmnwwCYZxdxhQ/+LFWlbAW8y7jt68L/65402Lz3+CKy0Ov4rOs+NERmDq7YlZaDqUIfA==",
+      "dev": true,
+      "requires": {
+        "glob-watcher": "^5.0.3",
+        "gulp-cli": "^2.2.0",
+        "undertaker": "^1.2.1",
+        "vinyl-fs": "^3.0.0"
+      }
+    },
+    "gulp-cli": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.3.0.tgz",
+      "integrity": "sha512-zzGBl5fHo0EKSXsHzjspp3y5CONegCm8ErO5Qh0UzFzk2y4tMvzLWhoDokADbarfZRL2pGpRp7yt6gfJX4ph7A==",
+      "dev": true,
+      "requires": {
+        "ansi-colors": "^1.0.1",
+        "archy": "^1.0.0",
+        "array-sort": "^1.0.0",
+        "color-support": "^1.1.3",
+        "concat-stream": "^1.6.0",
+        "copy-props": "^2.0.1",
+        "fancy-log": "^1.3.2",
+        "gulplog": "^1.0.0",
+        "interpret": "^1.4.0",
+        "isobject": "^3.0.1",
+        "liftoff": "^3.1.0",
+        "matchdep": "^2.0.0",
+        "mute-stdout": "^1.0.0",
+        "pretty-hrtime": "^1.0.0",
+        "replace-homedir": "^1.0.0",
+        "semver-greatest-satisfied-range": "^1.1.0",
+        "v8flags": "^3.2.0",
+        "yargs": "^7.1.0"
+      },
+      "dependencies": {
+        "concat-stream": {
+          "version": "1.6.2",
+          "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
+          "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
+          "dev": true,
+          "requires": {
+            "buffer-from": "^1.0.0",
+            "inherits": "^2.0.3",
+            "readable-stream": "^2.2.2",
+            "typedarray": "^0.0.6"
+          }
+        }
+      }
+    },
+    "gulp-sourcemaps": {
+      "version": "2.6.4",
+      "resolved": "https://registry.npmjs.org/gulp-sourcemaps/-/gulp-sourcemaps-2.6.4.tgz",
+      "integrity": "sha1-y7IAhFCxvM5s0jv5gze+dRv24wo=",
+      "dev": true,
+      "requires": {
+        "@gulp-sourcemaps/identity-map": "1.X",
+        "@gulp-sourcemaps/map-sources": "1.X",
+        "acorn": "5.X",
+        "convert-source-map": "1.X",
+        "css": "2.X",
+        "debug-fabulous": "1.X",
+        "detect-newline": "2.X",
+        "graceful-fs": "4.X",
+        "source-map": "~0.6.0",
+        "strip-bom-string": "1.X",
+        "through2": "2.X"
+      },
+      "dependencies": {
+        "acorn": {
+          "version": "5.7.4",
+          "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
+          "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
+          "dev": true
+        },
+        "source-map": {
+          "version": "0.6.1",
+          "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+          "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+          "dev": true
+        }
+      }
+    },
+    "gulp-uglify": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-3.0.1.tgz",
+      "integrity": "sha512-KVffbGY9d4Wv90bW/B1KZJyunLMyfHTBbilpDvmcrj5Go0/a1G3uVpt+1gRBWSw/11dqR3coJ1oWNTt1AiXuWQ==",
+      "dev": true,
+      "requires": {
+        "gulplog": "^1.0.0",
+        "has-gulplog": "^0.1.0",
+        "lodash": "^4.13.1",
+        "make-error-cause": "^1.1.1",
+        "safe-buffer": "^5.1.2",
+        "through2": "^2.0.0",
+        "uglify-js": "^3.0.5",
+        "vinyl-sourcemaps-apply": "^0.2.0"
+      },
+      "dependencies": {
+        "safe-buffer": {
+          "version": "5.1.2",
+          "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+          "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+          "dev": true
+        }
+      }
+    },
+    "gulplog": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz",
+      "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=",
+      "dev": true,
+      "requires": {
+        "glogg": "^1.0.0"
+      }
+    },
+    "has": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
+      "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+      "dev": true,
+      "requires": {
+        "function-bind": "^1.1.1"
+      }
+    },
+    "has-gulplog": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz",
+      "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=",
+      "dev": true,
+      "requires": {
+        "sparkles": "^1.0.0"
+      }
+    },
+    "has-property-descriptors": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz",
+      "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==",
+      "dev": true,
+      "requires": {
+        "get-intrinsic": "^1.1.1"
+      }
+    },
+    "has-symbols": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
+      "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
+      "dev": true
+    },
+    "has-value": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz",
+      "integrity": "sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==",
+      "dev": true,
+      "requires": {
+        "get-value": "^2.0.6",
+        "has-values": "^1.0.0",
+        "isobject": "^3.0.0"
+      }
+    },
+    "has-values": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz",
+      "integrity": "sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==",
+      "dev": true,
+      "requires": {
+        "is-number": "^3.0.0",
+        "kind-of": "^4.0.0"
+      },
+      "dependencies": {
+        "kind-of": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz",
+          "integrity": "sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==",
+          "dev": true,
+          "requires": {
+            "is-buffer": "^1.1.5"
+          }
+        }
+      }
+    },
+    "hash-base": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz",
+      "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.0.1"
+      }
+    },
+    "hash.js": {
+      "version": "1.1.5",
+      "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz",
+      "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.3",
+        "minimalistic-assert": "^1.0.1"
+      }
+    },
+    "hmac-drbg": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
+      "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=",
+      "dev": true,
+      "requires": {
+        "hash.js": "^1.0.3",
+        "minimalistic-assert": "^1.0.0",
+        "minimalistic-crypto-utils": "^1.0.1"
+      }
+    },
+    "homedir-polyfill": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz",
+      "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==",
+      "dev": true,
+      "requires": {
+        "parse-passwd": "^1.0.0"
+      }
+    },
+    "hosted-git-info": {
+      "version": "2.8.9",
+      "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
+      "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
+      "dev": true
+    },
+    "htmlescape": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz",
+      "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=",
+      "dev": true
+    },
+    "https-browserify": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
+      "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=",
+      "dev": true
+    },
+    "ieee754": {
+      "version": "1.1.12",
+      "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz",
+      "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==",
+      "dev": true
+    },
+    "indexof": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
+      "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
+      "dev": true
+    },
+    "inflight": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+      "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+      "dev": true,
+      "requires": {
+        "once": "^1.3.0",
+        "wrappy": "1"
+      }
+    },
+    "inherits": {
+      "version": "2.0.3",
+      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+      "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
+      "dev": true
+    },
+    "ini": {
+      "version": "1.3.8",
+      "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
+      "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
+      "dev": true
+    },
+    "inline-source-map": {
+      "version": "0.6.2",
+      "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz",
+      "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=",
+      "dev": true,
+      "requires": {
+        "source-map": "~0.5.3"
+      }
+    },
+    "insert-module-globals": {
+      "version": "7.2.0",
+      "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz",
+      "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==",
+      "dev": true,
+      "requires": {
+        "acorn-node": "^1.5.2",
+        "combine-source-map": "^0.8.0",
+        "concat-stream": "^1.6.1",
+        "is-buffer": "^1.1.0",
+        "JSONStream": "^1.0.3",
+        "path-is-absolute": "^1.0.1",
+        "process": "~0.11.0",
+        "through2": "^2.0.0",
+        "undeclared-identifiers": "^1.1.2",
+        "xtend": "^4.0.0"
+      },
+      "dependencies": {
+        "concat-stream": {
+          "version": "1.6.2",
+          "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
+          "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
+          "dev": true,
+          "requires": {
+            "buffer-from": "^1.0.0",
+            "inherits": "^2.0.3",
+            "readable-stream": "^2.2.2",
+            "typedarray": "^0.0.6"
+          }
+        }
+      }
+    },
+    "interpret": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz",
+      "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==",
+      "dev": true
+    },
+    "invert-kv": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
+      "integrity": "sha512-xgs2NH9AE66ucSq4cNG1nhSFghr5l6tdL15Pk+jl46bmmBapgoaY/AacXyaDznAqmGL99TiLSQgO/XazFSKYeQ==",
+      "dev": true
+    },
+    "is-absolute": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz",
+      "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==",
+      "dev": true,
+      "requires": {
+        "is-relative": "^1.0.0",
+        "is-windows": "^1.0.1"
+      }
+    },
+    "is-accessor-descriptor": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz",
+      "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==",
+      "dev": true,
+      "requires": {
+        "kind-of": "^6.0.0"
+      },
+      "dependencies": {
+        "kind-of": {
+          "version": "6.0.3",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+          "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+          "dev": true
+        }
+      }
+    },
+    "is-arrayish": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
+      "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=",
+      "dev": true
+    },
+    "is-binary-path": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz",
+      "integrity": "sha512-9fRVlXc0uCxEDj1nQzaWONSpbTfx0FmJfzHF7pwlI8DkWGoHBBea4Pg5Ky0ojwwxQmnSifgbKkI06Qv0Ljgj+Q==",
+      "dev": true,
+      "requires": {
+        "binary-extensions": "^1.0.0"
+      }
+    },
+    "is-buffer": {
+      "version": "1.1.5",
+      "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz",
+      "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=",
+      "dev": true
+    },
+    "is-core-module": {
+      "version": "2.9.0",
+      "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",
+      "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",
+      "dev": true,
+      "requires": {
+        "has": "^1.0.3"
+      }
+    },
+    "is-data-descriptor": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz",
+      "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==",
+      "dev": true,
+      "requires": {
+        "kind-of": "^6.0.0"
+      },
+      "dependencies": {
+        "kind-of": {
+          "version": "6.0.3",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+          "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+          "dev": true
+        }
+      }
+    },
+    "is-descriptor": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz",
+      "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==",
+      "dev": true,
+      "requires": {
+        "is-accessor-descriptor": "^1.0.0",
+        "is-data-descriptor": "^1.0.0",
+        "kind-of": "^6.0.2"
+      },
+      "dependencies": {
+        "kind-of": {
+          "version": "6.0.3",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+          "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+          "dev": true
+        }
+      }
+    },
+    "is-extendable": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
+      "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==",
+      "dev": true
+    },
+    "is-extglob": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
+      "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
+      "dev": true
+    },
+    "is-fullwidth-code-point": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
+      "integrity": "sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==",
+      "dev": true,
+      "requires": {
+        "number-is-nan": "^1.0.0"
+      }
+    },
+    "is-glob": {
+      "version": "4.0.3",
+      "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
+      "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
+      "dev": true,
+      "requires": {
+        "is-extglob": "^2.1.1"
+      }
+    },
+    "is-negated-glob": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz",
+      "integrity": "sha512-czXVVn/QEmgvej1f50BZ648vUI+em0xqMq2Sn+QncCLN4zj1UAxlT+kw/6ggQTOaZPd1HqKQGEqbpQVtJucWug==",
+      "dev": true
+    },
+    "is-number": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
+      "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==",
+      "dev": true,
+      "requires": {
+        "kind-of": "^3.0.2"
+      },
+      "dependencies": {
+        "kind-of": {
+          "version": "3.2.2",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+          "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+          "dev": true,
+          "requires": {
+            "is-buffer": "^1.1.5"
+          }
+        }
+      }
+    },
+    "is-plain-object": {
+      "version": "5.0.0",
+      "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
+      "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
+      "dev": true
+    },
+    "is-promise": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz",
+      "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
+      "dev": true
+    },
+    "is-relative": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz",
+      "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==",
+      "dev": true,
+      "requires": {
+        "is-unc-path": "^1.0.0"
+      }
+    },
+    "is-unc-path": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz",
+      "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==",
+      "dev": true,
+      "requires": {
+        "unc-path-regex": "^0.1.2"
+      }
+    },
+    "is-utf8": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
+      "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
+      "dev": true
+    },
+    "is-valid-glob": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-1.0.0.tgz",
+      "integrity": "sha512-AhiROmoEFDSsjx8hW+5sGwgKVIORcXnrlAx/R0ZSeaPw70Vw0CqkGBBhHGL58Uox2eXnU1AnvXJl1XlyedO5bA==",
+      "dev": true
+    },
+    "is-windows": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz",
+      "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==",
+      "dev": true
+    },
+    "isarray": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+      "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
+      "dev": true
+    },
+    "isexe": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+      "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
+      "dev": true
+    },
+    "isobject": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
+      "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==",
+      "dev": true
+    },
+    "json-stable-stringify": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz",
+      "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=",
+      "dev": true,
+      "requires": {
+        "jsonify": "~0.0.0"
+      }
+    },
+    "json-stable-stringify-without-jsonify": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
+      "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
+      "dev": true
+    },
+    "jsonify": {
+      "version": "0.0.0",
+      "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
+      "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
+      "dev": true
+    },
+    "jsonparse": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
+      "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=",
+      "dev": true
+    },
+    "JSONStream": {
+      "version": "1.3.5",
+      "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
+      "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==",
+      "dev": true,
+      "requires": {
+        "jsonparse": "^1.2.0",
+        "through": ">=2.2.7 <3"
+      }
+    },
+    "just-debounce": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.1.0.tgz",
+      "integrity": "sha512-qpcRocdkUmf+UTNBYx5w6dexX5J31AKK1OmPwH630a83DdVVUIngk55RSAiIGpQyoH0dlr872VHfPjnQnK1qDQ==",
+      "dev": true
+    },
+    "kind-of": {
+      "version": "5.1.0",
+      "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz",
+      "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==",
+      "dev": true
+    },
+    "labeled-stream-splicer": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz",
+      "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.1",
+        "isarray": "^2.0.4",
+        "stream-splicer": "^2.0.0"
+      },
+      "dependencies": {
+        "isarray": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz",
+          "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==",
+          "dev": true
+        }
+      }
+    },
+    "last-run": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz",
+      "integrity": "sha512-U/VxvpX4N/rFvPzr3qG5EtLKEnNI0emvIQB3/ecEwv+8GHaUKbIB8vxv1Oai5FAF0d0r7LXHhLLe5K/yChm5GQ==",
+      "dev": true,
+      "requires": {
+        "default-resolution": "^2.0.0",
+        "es6-weak-map": "^2.0.1"
+      }
+    },
+    "lazystream": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.1.tgz",
+      "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==",
+      "dev": true,
+      "requires": {
+        "readable-stream": "^2.0.5"
+      }
+    },
+    "lcid": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
+      "integrity": "sha512-YiGkH6EnGrDGqLMITnGjXtGmNtjoXw9SVUzcaos8RBi7Ps0VBylkq+vOcY9QE5poLasPCR849ucFUkl0UzUyOw==",
+      "dev": true,
+      "requires": {
+        "invert-kv": "^1.0.0"
+      }
+    },
+    "lead": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/lead/-/lead-1.0.0.tgz",
+      "integrity": "sha512-IpSVCk9AYvLHo5ctcIXxOBpMWUe+4TKN3VPWAKUbJikkmsGp0VrSM8IttVc32D6J4WUsiPE6aEFRNmIoF/gdow==",
+      "dev": true,
+      "requires": {
+        "flush-write-stream": "^1.0.2"
+      }
+    },
+    "liftoff": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-3.1.0.tgz",
+      "integrity": "sha512-DlIPlJUkCV0Ips2zf2pJP0unEoT1kwYhiiPUGF3s/jtxTCjziNLoiVVh+jqWOWeFi6mmwQ5fNxvAUyPad4Dfog==",
+      "dev": true,
+      "requires": {
+        "extend": "^3.0.0",
+        "findup-sync": "^3.0.0",
+        "fined": "^1.0.1",
+        "flagged-respawn": "^1.0.0",
+        "is-plain-object": "^2.0.4",
+        "object.map": "^1.0.0",
+        "rechoir": "^0.6.2",
+        "resolve": "^1.1.7"
+      },
+      "dependencies": {
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        }
+      }
+    },
+    "load-json-file": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
+      "integrity": "sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==",
+      "dev": true,
+      "requires": {
+        "graceful-fs": "^4.1.2",
+        "parse-json": "^2.2.0",
+        "pify": "^2.0.0",
+        "pinkie-promise": "^2.0.0",
+        "strip-bom": "^2.0.0"
+      }
+    },
+    "lodash": {
+      "version": "4.17.21",
+      "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
+      "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
+      "dev": true
+    },
+    "lodash.memoize": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz",
+      "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=",
+      "dev": true
+    },
+    "lru-queue": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
+      "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=",
+      "dev": true,
+      "requires": {
+        "es5-ext": "~0.10.2"
+      }
+    },
+    "make-error": {
+      "version": "1.3.5",
+      "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
+      "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==",
+      "dev": true
+    },
+    "make-error-cause": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmjs.org/make-error-cause/-/make-error-cause-1.2.2.tgz",
+      "integrity": "sha1-3wOI/NCzeBbf8KX7gQiTl3fcvJ0=",
+      "dev": true,
+      "requires": {
+        "make-error": "^1.2.0"
+      }
+    },
+    "make-iterator": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz",
+      "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==",
+      "dev": true,
+      "requires": {
+        "kind-of": "^6.0.2"
+      },
+      "dependencies": {
+        "kind-of": {
+          "version": "6.0.3",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+          "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+          "dev": true
+        }
+      }
+    },
+    "map-cache": {
+      "version": "0.2.2",
+      "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz",
+      "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==",
+      "dev": true
+    },
+    "map-visit": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz",
+      "integrity": "sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==",
+      "dev": true,
+      "requires": {
+        "object-visit": "^1.0.0"
+      }
+    },
+    "matchdep": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/matchdep/-/matchdep-2.0.0.tgz",
+      "integrity": "sha512-LFgVbaHIHMqCRuCZyfCtUOq9/Lnzhi7Z0KFUE2fhD54+JN2jLh3hC02RLkqauJ3U4soU6H1J3tfj/Byk7GoEjA==",
+      "dev": true,
+      "requires": {
+        "findup-sync": "^2.0.0",
+        "micromatch": "^3.0.4",
+        "resolve": "^1.4.0",
+        "stack-trace": "0.0.10"
+      },
+      "dependencies": {
+        "findup-sync": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz",
+          "integrity": "sha512-vs+3unmJT45eczmcAZ6zMJtxN3l/QXeccaXQx5cu/MeJMhewVfoWZqibRkOxPnmoR59+Zy5hjabfQc6JLSah4g==",
+          "dev": true,
+          "requires": {
+            "detect-file": "^1.0.0",
+            "is-glob": "^3.1.0",
+            "micromatch": "^3.0.4",
+            "resolve-dir": "^1.0.1"
+          }
+        },
+        "is-glob": {
+          "version": "3.1.0",
+          "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz",
+          "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==",
+          "dev": true,
+          "requires": {
+            "is-extglob": "^2.1.0"
+          }
+        }
+      }
+    },
+    "md5.js": {
+      "version": "1.3.5",
+      "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
+      "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==",
+      "dev": true,
+      "requires": {
+        "hash-base": "^3.0.0",
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.1.2"
+      },
+      "dependencies": {
+        "safe-buffer": {
+          "version": "5.1.2",
+          "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+          "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+          "dev": true
+        }
+      }
+    },
+    "memoizee": {
+      "version": "0.4.14",
+      "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.14.tgz",
+      "integrity": "sha512-/SWFvWegAIYAO4NQMpcX+gcra0yEZu4OntmUdrBaWrJncxOqAziGFlHxc7yjKVK2uu3lpPW27P27wkR82wA8mg==",
+      "dev": true,
+      "requires": {
+        "d": "1",
+        "es5-ext": "^0.10.45",
+        "es6-weak-map": "^2.0.2",
+        "event-emitter": "^0.3.5",
+        "is-promise": "^2.1",
+        "lru-queue": "0.1",
+        "next-tick": "1",
+        "timers-ext": "^0.1.5"
+      },
+      "dependencies": {
+        "es5-ext": {
+          "version": "0.10.46",
+          "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.46.tgz",
+          "integrity": "sha512-24XxRvJXNFwEMpJb3nOkiRJKRoupmjYmOPVlI65Qy2SrtxwOTB+g6ODjBKOtwEHbYrhWRty9xxOWLNdClT2djw==",
+          "dev": true,
+          "requires": {
+            "es6-iterator": "~2.0.3",
+            "es6-symbol": "~3.1.1",
+            "next-tick": "1"
+          }
+        },
+        "es6-iterator": {
+          "version": "2.0.3",
+          "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
+          "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
+          "dev": true,
+          "requires": {
+            "d": "1",
+            "es5-ext": "^0.10.35",
+            "es6-symbol": "^3.1.1"
+          }
+        }
+      }
+    },
+    "micromatch": {
+      "version": "3.1.10",
+      "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz",
+      "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==",
+      "dev": true,
+      "requires": {
+        "arr-diff": "^4.0.0",
+        "array-unique": "^0.3.2",
+        "braces": "^2.3.1",
+        "define-property": "^2.0.2",
+        "extend-shallow": "^3.0.2",
+        "extglob": "^2.0.4",
+        "fragment-cache": "^0.2.1",
+        "kind-of": "^6.0.2",
+        "nanomatch": "^1.2.9",
+        "object.pick": "^1.3.0",
+        "regex-not": "^1.0.0",
+        "snapdragon": "^0.8.1",
+        "to-regex": "^3.0.2"
+      },
+      "dependencies": {
+        "extend-shallow": {
+          "version": "3.0.2",
+          "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+          "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+          "dev": true,
+          "requires": {
+            "assign-symbols": "^1.0.0",
+            "is-extendable": "^1.0.1"
+          }
+        },
+        "is-extendable": {
+          "version": "1.0.1",
+          "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+          "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+          "dev": true,
+          "requires": {
+            "is-plain-object": "^2.0.4"
+          }
+        },
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        },
+        "kind-of": {
+          "version": "6.0.3",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+          "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+          "dev": true
+        }
+      }
+    },
+    "miller-rabin": {
+      "version": "4.0.1",
+      "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz",
+      "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==",
+      "dev": true,
+      "requires": {
+        "bn.js": "^4.0.0",
+        "brorand": "^1.0.1"
+      }
+    },
+    "minimalistic-assert": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
+      "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==",
+      "dev": true
+    },
+    "minimalistic-crypto-utils": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz",
+      "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=",
+      "dev": true
+    },
+    "minimatch": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+      "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+      "dev": true,
+      "requires": {
+        "brace-expansion": "^1.1.7"
+      }
+    },
+    "minimist": {
+      "version": "1.2.6",
+      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
+      "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
+      "dev": true
+    },
+    "mixin-deep": {
+      "version": "1.3.2",
+      "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
+      "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
+      "dev": true,
+      "requires": {
+        "for-in": "^1.0.2",
+        "is-extendable": "^1.0.1"
+      },
+      "dependencies": {
+        "is-extendable": {
+          "version": "1.0.1",
+          "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+          "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+          "dev": true,
+          "requires": {
+            "is-plain-object": "^2.0.4"
+          }
+        },
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        }
+      }
+    },
+    "module-deps": {
+      "version": "4.1.1",
+      "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz",
+      "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=",
+      "dev": true,
+      "requires": {
+        "browser-resolve": "^1.7.0",
+        "cached-path-relative": "^1.0.0",
+        "concat-stream": "~1.5.0",
+        "defined": "^1.0.0",
+        "detective": "^4.0.0",
+        "duplexer2": "^0.1.2",
+        "inherits": "^2.0.1",
+        "JSONStream": "^1.0.3",
+        "parents": "^1.0.0",
+        "readable-stream": "^2.0.2",
+        "resolve": "^1.1.3",
+        "stream-combiner2": "^1.1.1",
+        "subarg": "^1.0.0",
+        "through2": "^2.0.0",
+        "xtend": "^4.0.0"
+      }
+    },
+    "ms": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+      "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+      "dev": true
+    },
+    "mute-stdout": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.1.tgz",
+      "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==",
+      "dev": true
+    },
+    "nan": {
+      "version": "2.16.0",
+      "resolved": "https://registry.npmjs.org/nan/-/nan-2.16.0.tgz",
+      "integrity": "sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA==",
+      "dev": true,
+      "optional": true
+    },
+    "nanomatch": {
+      "version": "1.2.13",
+      "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
+      "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==",
+      "dev": true,
+      "requires": {
+        "arr-diff": "^4.0.0",
+        "array-unique": "^0.3.2",
+        "define-property": "^2.0.2",
+        "extend-shallow": "^3.0.2",
+        "fragment-cache": "^0.2.1",
+        "is-windows": "^1.0.2",
+        "kind-of": "^6.0.2",
+        "object.pick": "^1.3.0",
+        "regex-not": "^1.0.0",
+        "snapdragon": "^0.8.1",
+        "to-regex": "^3.0.1"
+      },
+      "dependencies": {
+        "extend-shallow": {
+          "version": "3.0.2",
+          "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+          "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+          "dev": true,
+          "requires": {
+            "assign-symbols": "^1.0.0",
+            "is-extendable": "^1.0.1"
+          }
+        },
+        "is-extendable": {
+          "version": "1.0.1",
+          "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+          "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+          "dev": true,
+          "requires": {
+            "is-plain-object": "^2.0.4"
+          }
+        },
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        },
+        "kind-of": {
+          "version": "6.0.3",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+          "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+          "dev": true
+        }
+      }
+    },
+    "next-tick": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
+      "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
+      "dev": true
+    },
+    "normalize-package-data": {
+      "version": "2.5.0",
+      "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
+      "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==",
+      "dev": true,
+      "requires": {
+        "hosted-git-info": "^2.1.4",
+        "resolve": "^1.10.0",
+        "semver": "2 || 3 || 4 || 5",
+        "validate-npm-package-license": "^3.0.1"
+      }
+    },
+    "normalize-path": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
+      "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
+      "dev": true,
+      "requires": {
+        "remove-trailing-separator": "^1.0.1"
+      }
+    },
+    "now-and-later": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz",
+      "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==",
+      "dev": true,
+      "requires": {
+        "once": "^1.3.2"
+      }
+    },
+    "number-is-nan": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
+      "integrity": "sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==",
+      "dev": true
+    },
+    "object-assign": {
+      "version": "4.1.1",
+      "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+      "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
+      "dev": true
+    },
+    "object-copy": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz",
+      "integrity": "sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==",
+      "dev": true,
+      "requires": {
+        "copy-descriptor": "^0.1.0",
+        "define-property": "^0.2.5",
+        "kind-of": "^3.0.3"
+      },
+      "dependencies": {
+        "define-property": {
+          "version": "0.2.5",
+          "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+          "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+          "dev": true,
+          "requires": {
+            "is-descriptor": "^0.1.0"
+          }
+        },
+        "is-accessor-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+          "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          }
+        },
+        "is-data-descriptor": {
+          "version": "0.1.4",
+          "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+          "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          }
+        },
+        "is-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+          "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+          "dev": true,
+          "requires": {
+            "is-accessor-descriptor": "^0.1.6",
+            "is-data-descriptor": "^0.1.4",
+            "kind-of": "^5.0.0"
+          },
+          "dependencies": {
+            "kind-of": {
+              "version": "5.1.0",
+              "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz",
+              "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==",
+              "dev": true
+            }
+          }
+        },
+        "kind-of": {
+          "version": "3.2.2",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+          "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+          "dev": true,
+          "requires": {
+            "is-buffer": "^1.1.5"
+          }
+        }
+      }
+    },
+    "object-keys": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
+      "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
+      "dev": true
+    },
+    "object-visit": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz",
+      "integrity": "sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==",
+      "dev": true,
+      "requires": {
+        "isobject": "^3.0.0"
+      }
+    },
+    "object.assign": {
+      "version": "4.1.2",
+      "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz",
+      "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==",
+      "dev": true,
+      "requires": {
+        "call-bind": "^1.0.0",
+        "define-properties": "^1.1.3",
+        "has-symbols": "^1.0.1",
+        "object-keys": "^1.1.1"
+      }
+    },
+    "object.defaults": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz",
+      "integrity": "sha512-c/K0mw/F11k4dEUBMW8naXUuBuhxRCfG7W+yFy8EcijU/rSmazOUd1XAEEe6bC0OuXY4HUKjTJv7xbxIMqdxrA==",
+      "dev": true,
+      "requires": {
+        "array-each": "^1.0.1",
+        "array-slice": "^1.0.0",
+        "for-own": "^1.0.0",
+        "isobject": "^3.0.0"
+      }
+    },
+    "object.map": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz",
+      "integrity": "sha512-3+mAJu2PLfnSVGHwIWubpOFLscJANBKuB/6A4CxBstc4aqwQY0FWcsppuy4jU5GSB95yES5JHSI+33AWuS4k6w==",
+      "dev": true,
+      "requires": {
+        "for-own": "^1.0.0",
+        "make-iterator": "^1.0.0"
+      }
+    },
+    "object.pick": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz",
+      "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==",
+      "dev": true,
+      "requires": {
+        "isobject": "^3.0.1"
+      }
+    },
+    "object.reduce": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/object.reduce/-/object.reduce-1.0.1.tgz",
+      "integrity": "sha512-naLhxxpUESbNkRqc35oQ2scZSJueHGQNUfMW/0U37IgN6tE2dgDWg3whf+NEliy3F/QysrO48XKUz/nGPe+AQw==",
+      "dev": true,
+      "requires": {
+        "for-own": "^1.0.0",
+        "make-iterator": "^1.0.0"
+      }
+    },
+    "once": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+      "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
+      "dev": true,
+      "requires": {
+        "wrappy": "1"
+      }
+    },
+    "ordered-read-streams": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz",
+      "integrity": "sha512-Z87aSjx3r5c0ZB7bcJqIgIRX5bxR7A4aSzvIbaxd0oTkWBCOoKfuGHiKj60CHVUgg1Phm5yMZzBdt8XqRs73Mw==",
+      "dev": true,
+      "requires": {
+        "readable-stream": "^2.0.1"
+      }
+    },
+    "os-browserify": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz",
+      "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=",
+      "dev": true
+    },
+    "os-locale": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
+      "integrity": "sha512-PRT7ZORmwu2MEFt4/fv3Q+mEfN4zetKxufQrkShY2oGvUms9r8otu5HfdyIFHkYXjO7laNsoVGmM2MANfuTA8g==",
+      "dev": true,
+      "requires": {
+        "lcid": "^1.0.0"
+      }
+    },
+    "pako": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
+      "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==",
+      "dev": true
+    },
+    "parents": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz",
+      "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=",
+      "dev": true,
+      "requires": {
+        "path-platform": "~0.11.15"
+      }
+    },
+    "parse-asn1": {
+      "version": "5.1.1",
+      "resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz",
+      "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==",
+      "dev": true,
+      "requires": {
+        "asn1.js": "^4.0.0",
+        "browserify-aes": "^1.0.0",
+        "create-hash": "^1.1.0",
+        "evp_bytestokey": "^1.0.0",
+        "pbkdf2": "^3.0.3"
+      }
+    },
+    "parse-filepath": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz",
+      "integrity": "sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==",
+      "dev": true,
+      "requires": {
+        "is-absolute": "^1.0.0",
+        "map-cache": "^0.2.0",
+        "path-root": "^0.1.1"
+      }
+    },
+    "parse-json": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
+      "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
+      "dev": true,
+      "requires": {
+        "error-ex": "^1.2.0"
+      }
+    },
+    "parse-node-version": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz",
+      "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==",
+      "dev": true
+    },
+    "parse-passwd": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz",
+      "integrity": "sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==",
+      "dev": true
+    },
+    "pascalcase": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz",
+      "integrity": "sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==",
+      "dev": true
+    },
+    "path-browserify": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
+      "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==",
+      "dev": true
+    },
+    "path-dirname": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz",
+      "integrity": "sha512-ALzNPpyNq9AqXMBjeymIjFDAkAFH06mHJH/cSBHAgU0s4vfpBn6b2nf8tiRLvagKD8RbTpq2FKTBg7cl9l3c7Q==",
+      "dev": true
+    },
+    "path-exists": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
+      "integrity": "sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==",
+      "dev": true,
+      "requires": {
+        "pinkie-promise": "^2.0.0"
+      }
+    },
+    "path-is-absolute": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+      "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
+      "dev": true
+    },
+    "path-parse": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
+      "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
+      "dev": true
+    },
+    "path-platform": {
+      "version": "0.11.15",
+      "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz",
+      "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=",
+      "dev": true
+    },
+    "path-root": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz",
+      "integrity": "sha512-QLcPegTHF11axjfojBIoDygmS2E3Lf+8+jI6wOVmNVenrKSo3mFdSGiIgdSHenczw3wPtlVMQaFVwGmM7BJdtg==",
+      "dev": true,
+      "requires": {
+        "path-root-regex": "^0.1.0"
+      }
+    },
+    "path-root-regex": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz",
+      "integrity": "sha512-4GlJ6rZDhQZFE0DPVKh0e9jmZ5egZfxTkp7bcRDuPlJXbAwhxcl2dINPUAsjLdejqaLsCeg8axcLjIbvBjN4pQ==",
+      "dev": true
+    },
+    "path-type": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz",
+      "integrity": "sha512-S4eENJz1pkiQn9Znv33Q+deTOKmbl+jj1Fl+qiP/vYezj+S8x+J3Uo0ISrx/QoEvIlOaDWJhPaRd1flJ9HXZqg==",
+      "dev": true,
+      "requires": {
+        "graceful-fs": "^4.1.2",
+        "pify": "^2.0.0",
+        "pinkie-promise": "^2.0.0"
+      }
+    },
+    "pbkdf2": {
+      "version": "3.0.17",
+      "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz",
+      "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==",
+      "dev": true,
+      "requires": {
+        "create-hash": "^1.1.2",
+        "create-hmac": "^1.1.4",
+        "ripemd160": "^2.0.1",
+        "safe-buffer": "^5.0.1",
+        "sha.js": "^2.4.8"
+      }
+    },
+    "pify": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
+      "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==",
+      "dev": true
+    },
+    "pinkie": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz",
+      "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==",
+      "dev": true
+    },
+    "pinkie-promise": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
+      "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==",
+      "dev": true,
+      "requires": {
+        "pinkie": "^2.0.0"
+      }
+    },
+    "posix-character-classes": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz",
+      "integrity": "sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==",
+      "dev": true
+    },
+    "preact": {
+      "version": "8.3.1",
+      "resolved": "https://registry.npmjs.org/preact/-/preact-8.3.1.tgz",
+      "integrity": "sha512-s8H1Y8O9e+mOBo3UP1jvWqArPmjCba2lrrGLlq/0kN1XuIINUbYtf97iiXKxCuG3eYwmppPKnyW2DBrNj/TuTg=="
+    },
+    "pretty-hrtime": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz",
+      "integrity": "sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==",
+      "dev": true
+    },
+    "process": {
+      "version": "0.11.10",
+      "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
+      "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=",
+      "dev": true
+    },
+    "process-nextick-args": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
+      "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=",
+      "dev": true
+    },
+    "public-encrypt": {
+      "version": "4.0.3",
+      "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz",
+      "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==",
+      "dev": true,
+      "requires": {
+        "bn.js": "^4.1.0",
+        "browserify-rsa": "^4.0.0",
+        "create-hash": "^1.1.0",
+        "parse-asn1": "^5.0.0",
+        "randombytes": "^2.0.1",
+        "safe-buffer": "^5.1.2"
+      },
+      "dependencies": {
+        "safe-buffer": {
+          "version": "5.1.2",
+          "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+          "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
+          "dev": true
+        }
+      }
+    },
+    "pump": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz",
+      "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==",
+      "dev": true,
+      "requires": {
+        "end-of-stream": "^1.1.0",
+        "once": "^1.3.1"
+      }
+    },
+    "pumpify": {
+      "version": "1.5.1",
+      "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz",
+      "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==",
+      "dev": true,
+      "requires": {
+        "duplexify": "^3.6.0",
+        "inherits": "^2.0.3",
+        "pump": "^2.0.0"
+      }
+    },
+    "punycode": {
+      "version": "1.4.1",
+      "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
+      "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
+      "dev": true
+    },
+    "querystring": {
+      "version": "0.2.0",
+      "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
+      "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=",
+      "dev": true
+    },
+    "querystring-es3": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz",
+      "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=",
+      "dev": true
+    },
+    "randombytes": {
+      "version": "2.0.6",
+      "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz",
+      "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==",
+      "dev": true,
+      "requires": {
+        "safe-buffer": "^5.1.0"
+      }
+    },
+    "randomfill": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz",
+      "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==",
+      "dev": true,
+      "requires": {
+        "randombytes": "^2.0.5",
+        "safe-buffer": "^5.1.0"
+      }
+    },
+    "read-only-stream": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz",
+      "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=",
+      "dev": true,
+      "requires": {
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "read-pkg": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
+      "integrity": "sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==",
+      "dev": true,
+      "requires": {
+        "load-json-file": "^1.0.0",
+        "normalize-package-data": "^2.3.2",
+        "path-type": "^1.0.0"
+      }
+    },
+    "read-pkg-up": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz",
+      "integrity": "sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==",
+      "dev": true,
+      "requires": {
+        "find-up": "^1.0.0",
+        "read-pkg": "^1.0.0"
+      }
+    },
+    "readable-stream": {
+      "version": "2.3.6",
+      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
+      "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
+      "dev": true,
+      "requires": {
+        "core-util-is": "~1.0.0",
+        "inherits": "~2.0.3",
+        "isarray": "~1.0.0",
+        "process-nextick-args": "~2.0.0",
+        "safe-buffer": "~5.1.1",
+        "string_decoder": "~1.1.1",
+        "util-deprecate": "~1.0.1"
+      },
+      "dependencies": {
+        "process-nextick-args": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
+          "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
+          "dev": true
+        },
+        "string_decoder": {
+          "version": "1.1.1",
+          "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
+          "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
+          "dev": true,
+          "requires": {
+            "safe-buffer": "~5.1.0"
+          }
+        }
+      }
+    },
+    "readdirp": {
+      "version": "2.2.1",
+      "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz",
+      "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==",
+      "dev": true,
+      "requires": {
+        "graceful-fs": "^4.1.11",
+        "micromatch": "^3.1.10",
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "rechoir": {
+      "version": "0.6.2",
+      "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
+      "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==",
+      "dev": true,
+      "requires": {
+        "resolve": "^1.1.6"
+      }
+    },
+    "regex-not": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz",
+      "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==",
+      "dev": true,
+      "requires": {
+        "extend-shallow": "^3.0.2",
+        "safe-regex": "^1.1.0"
+      },
+      "dependencies": {
+        "extend-shallow": {
+          "version": "3.0.2",
+          "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+          "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+          "dev": true,
+          "requires": {
+            "assign-symbols": "^1.0.0",
+            "is-extendable": "^1.0.1"
+          }
+        },
+        "is-extendable": {
+          "version": "1.0.1",
+          "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+          "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+          "dev": true,
+          "requires": {
+            "is-plain-object": "^2.0.4"
+          }
+        },
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        }
+      }
+    },
+    "remove-bom-buffer": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz",
+      "integrity": "sha512-8v2rWhaakv18qcvNeli2mZ/TMTL2nEyAKRvzo1WtnZBl15SHyEhrCu2/xKlJyUFKHiHgfXIyuY6g2dObJJycXQ==",
+      "dev": true,
+      "requires": {
+        "is-buffer": "^1.1.5",
+        "is-utf8": "^0.2.1"
+      }
+    },
+    "remove-bom-stream": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz",
+      "integrity": "sha512-wigO8/O08XHb8YPzpDDT+QmRANfW6vLqxfaXm1YXhnFf3AkSLyjfG3GEFg4McZkmgL7KvCj5u2KczkvSP6NfHA==",
+      "dev": true,
+      "requires": {
+        "remove-bom-buffer": "^3.0.0",
+        "safe-buffer": "^5.1.0",
+        "through2": "^2.0.3"
+      }
+    },
+    "remove-trailing-separator": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
+      "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=",
+      "dev": true
+    },
+    "repeat-element": {
+      "version": "1.1.4",
+      "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.4.tgz",
+      "integrity": "sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ==",
+      "dev": true
+    },
+    "repeat-string": {
+      "version": "1.6.1",
+      "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
+      "integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==",
+      "dev": true
+    },
+    "replace-homedir": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/replace-homedir/-/replace-homedir-1.0.0.tgz",
+      "integrity": "sha512-CHPV/GAglbIB1tnQgaiysb8H2yCy8WQ7lcEwQ/eT+kLj0QHV8LnJW0zpqpE7RSkrMSRoa+EBoag86clf7WAgSg==",
+      "dev": true,
+      "requires": {
+        "homedir-polyfill": "^1.0.1",
+        "is-absolute": "^1.0.0",
+        "remove-trailing-separator": "^1.1.0"
+      }
+    },
+    "require-directory": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
+      "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
+      "dev": true
+    },
+    "require-main-filename": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz",
+      "integrity": "sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==",
+      "dev": true
+    },
+    "resolve": {
+      "version": "1.22.0",
+      "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz",
+      "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==",
+      "dev": true,
+      "requires": {
+        "is-core-module": "^2.8.1",
+        "path-parse": "^1.0.7",
+        "supports-preserve-symlinks-flag": "^1.0.0"
+      }
+    },
+    "resolve-dir": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz",
+      "integrity": "sha512-R7uiTjECzvOsWSfdM0QKFNBVFcK27aHOUwdvK53BcW8zqnGdYp0Fbj82cy54+2A4P2tFM22J5kRfe1R+lM/1yg==",
+      "dev": true,
+      "requires": {
+        "expand-tilde": "^2.0.0",
+        "global-modules": "^1.0.0"
+      }
+    },
+    "resolve-options": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz",
+      "integrity": "sha512-NYDgziiroVeDC29xq7bp/CacZERYsA9bXYd1ZmcJlF3BcrZv5pTb4NG7SjdyKDnXZ84aC4vo2u6sNKIA1LCu/A==",
+      "dev": true,
+      "requires": {
+        "value-or-function": "^3.0.0"
+      }
+    },
+    "resolve-url": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz",
+      "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=",
+      "dev": true
+    },
+    "ret": {
+      "version": "0.1.15",
+      "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz",
+      "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==",
+      "dev": true
+    },
+    "ripemd160": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz",
+      "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==",
+      "dev": true,
+      "requires": {
+        "hash-base": "^3.0.0",
+        "inherits": "^2.0.1"
+      }
+    },
+    "safe-buffer": {
+      "version": "5.1.1",
+      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
+      "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
+      "dev": true
+    },
+    "safe-regex": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
+      "integrity": "sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==",
+      "dev": true,
+      "requires": {
+        "ret": "~0.1.10"
+      }
+    },
+    "semver": {
+      "version": "5.6.0",
+      "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
+      "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==",
+      "dev": true
+    },
+    "semver-greatest-satisfied-range": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/semver-greatest-satisfied-range/-/semver-greatest-satisfied-range-1.1.0.tgz",
+      "integrity": "sha512-Ny/iyOzSSa8M5ML46IAx3iXc6tfOsYU2R4AXi2UpHk60Zrgyq6eqPj/xiOfS0rRl/iiQ/rdJkVjw/5cdUyCntQ==",
+      "dev": true,
+      "requires": {
+        "sver-compat": "^1.5.0"
+      }
+    },
+    "set-blocking": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
+      "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
+      "dev": true
+    },
+    "set-value": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
+      "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==",
+      "dev": true,
+      "requires": {
+        "extend-shallow": "^2.0.1",
+        "is-extendable": "^0.1.1",
+        "is-plain-object": "^2.0.3",
+        "split-string": "^3.0.1"
+      },
+      "dependencies": {
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        }
+      }
+    },
+    "sha.js": {
+      "version": "2.4.11",
+      "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
+      "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.1",
+        "safe-buffer": "^5.0.1"
+      }
+    },
+    "shasum": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz",
+      "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=",
+      "dev": true,
+      "requires": {
+        "json-stable-stringify": "~0.0.0",
+        "sha.js": "~2.4.4"
+      }
+    },
+    "shell-quote": {
+      "version": "1.7.3",
+      "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz",
+      "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==",
+      "dev": true
+    },
+    "simple-concat": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz",
+      "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=",
+      "dev": true
+    },
+    "snapdragon": {
+      "version": "0.8.2",
+      "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
+      "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==",
+      "dev": true,
+      "requires": {
+        "base": "^0.11.1",
+        "debug": "^2.2.0",
+        "define-property": "^0.2.5",
+        "extend-shallow": "^2.0.1",
+        "map-cache": "^0.2.2",
+        "source-map": "^0.5.6",
+        "source-map-resolve": "^0.5.0",
+        "use": "^3.1.0"
+      },
+      "dependencies": {
+        "define-property": {
+          "version": "0.2.5",
+          "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+          "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+          "dev": true,
+          "requires": {
+            "is-descriptor": "^0.1.0"
+          }
+        },
+        "is-accessor-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+          "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          },
+          "dependencies": {
+            "kind-of": {
+              "version": "3.2.2",
+              "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+              "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+              "dev": true,
+              "requires": {
+                "is-buffer": "^1.1.5"
+              }
+            }
+          }
+        },
+        "is-data-descriptor": {
+          "version": "0.1.4",
+          "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+          "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          },
+          "dependencies": {
+            "kind-of": {
+              "version": "3.2.2",
+              "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+              "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+              "dev": true,
+              "requires": {
+                "is-buffer": "^1.1.5"
+              }
+            }
+          }
+        },
+        "is-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+          "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+          "dev": true,
+          "requires": {
+            "is-accessor-descriptor": "^0.1.6",
+            "is-data-descriptor": "^0.1.4",
+            "kind-of": "^5.0.0"
+          }
+        }
+      }
+    },
+    "snapdragon-node": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz",
+      "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==",
+      "dev": true,
+      "requires": {
+        "define-property": "^1.0.0",
+        "isobject": "^3.0.0",
+        "snapdragon-util": "^3.0.1"
+      },
+      "dependencies": {
+        "define-property": {
+          "version": "1.0.0",
+          "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
+          "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==",
+          "dev": true,
+          "requires": {
+            "is-descriptor": "^1.0.0"
+          }
+        }
+      }
+    },
+    "snapdragon-util": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz",
+      "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==",
+      "dev": true,
+      "requires": {
+        "kind-of": "^3.2.0"
+      },
+      "dependencies": {
+        "kind-of": {
+          "version": "3.2.2",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+          "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+          "dev": true,
+          "requires": {
+            "is-buffer": "^1.1.5"
+          }
+        }
+      }
+    },
+    "source-map": {
+      "version": "0.5.7",
+      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
+      "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
+      "dev": true
+    },
+    "source-map-resolve": {
+      "version": "0.5.2",
+      "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz",
+      "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==",
+      "dev": true,
+      "requires": {
+        "atob": "^2.1.1",
+        "decode-uri-component": "^0.2.0",
+        "resolve-url": "^0.2.1",
+        "source-map-url": "^0.4.0",
+        "urix": "^0.1.0"
+      }
+    },
+    "source-map-url": {
+      "version": "0.4.0",
+      "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz",
+      "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=",
+      "dev": true
+    },
+    "sparkles": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz",
+      "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=",
+      "dev": true
+    },
+    "spdx-correct": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz",
+      "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==",
+      "dev": true,
+      "requires": {
+        "spdx-expression-parse": "^3.0.0",
+        "spdx-license-ids": "^3.0.0"
+      }
+    },
+    "spdx-exceptions": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz",
+      "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==",
+      "dev": true
+    },
+    "spdx-expression-parse": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz",
+      "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==",
+      "dev": true,
+      "requires": {
+        "spdx-exceptions": "^2.1.0",
+        "spdx-license-ids": "^3.0.0"
+      }
+    },
+    "spdx-license-ids": {
+      "version": "3.0.11",
+      "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz",
+      "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==",
+      "dev": true
+    },
+    "split-string": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
+      "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==",
+      "dev": true,
+      "requires": {
+        "extend-shallow": "^3.0.0"
+      },
+      "dependencies": {
+        "extend-shallow": {
+          "version": "3.0.2",
+          "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+          "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+          "dev": true,
+          "requires": {
+            "assign-symbols": "^1.0.0",
+            "is-extendable": "^1.0.1"
+          }
+        },
+        "is-extendable": {
+          "version": "1.0.1",
+          "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+          "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+          "dev": true,
+          "requires": {
+            "is-plain-object": "^2.0.4"
+          }
+        },
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        }
+      }
+    },
+    "stack-trace": {
+      "version": "0.0.10",
+      "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
+      "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==",
+      "dev": true
+    },
+    "static-extend": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz",
+      "integrity": "sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==",
+      "dev": true,
+      "requires": {
+        "define-property": "^0.2.5",
+        "object-copy": "^0.1.0"
+      },
+      "dependencies": {
+        "define-property": {
+          "version": "0.2.5",
+          "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+          "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==",
+          "dev": true,
+          "requires": {
+            "is-descriptor": "^0.1.0"
+          }
+        },
+        "is-accessor-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+          "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          },
+          "dependencies": {
+            "kind-of": {
+              "version": "3.2.2",
+              "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+              "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+              "dev": true,
+              "requires": {
+                "is-buffer": "^1.1.5"
+              }
+            }
+          }
+        },
+        "is-data-descriptor": {
+          "version": "0.1.4",
+          "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+          "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==",
+          "dev": true,
+          "requires": {
+            "kind-of": "^3.0.2"
+          },
+          "dependencies": {
+            "kind-of": {
+              "version": "3.2.2",
+              "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+              "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+              "dev": true,
+              "requires": {
+                "is-buffer": "^1.1.5"
+              }
+            }
+          }
+        },
+        "is-descriptor": {
+          "version": "0.1.6",
+          "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+          "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+          "dev": true,
+          "requires": {
+            "is-accessor-descriptor": "^0.1.6",
+            "is-data-descriptor": "^0.1.4",
+            "kind-of": "^5.0.0"
+          }
+        }
+      }
+    },
+    "stream-browserify": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz",
+      "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=",
+      "dev": true,
+      "requires": {
+        "inherits": "~2.0.1",
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "stream-combiner2": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz",
+      "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=",
+      "dev": true,
+      "requires": {
+        "duplexer2": "~0.1.0",
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "stream-exhaust": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz",
+      "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==",
+      "dev": true
+    },
+    "stream-http": {
+      "version": "2.8.3",
+      "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz",
+      "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==",
+      "dev": true,
+      "requires": {
+        "builtin-status-codes": "^3.0.0",
+        "inherits": "^2.0.1",
+        "readable-stream": "^2.3.6",
+        "to-arraybuffer": "^1.0.0",
+        "xtend": "^4.0.0"
+      }
+    },
+    "stream-shift": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz",
+      "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==",
+      "dev": true
+    },
+    "stream-splicer": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz",
+      "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=",
+      "dev": true,
+      "requires": {
+        "inherits": "^2.0.1",
+        "readable-stream": "^2.0.2"
+      }
+    },
+    "string_decoder": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
+      "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
+      "dev": true,
+      "requires": {
+        "safe-buffer": "~5.1.0"
+      }
+    },
+    "string-width": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
+      "integrity": "sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==",
+      "dev": true,
+      "requires": {
+        "code-point-at": "^1.0.0",
+        "is-fullwidth-code-point": "^1.0.0",
+        "strip-ansi": "^3.0.0"
+      }
+    },
+    "strip-ansi": {
+      "version": "3.0.1",
+      "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+      "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==",
+      "dev": true,
+      "requires": {
+        "ansi-regex": "^2.0.0"
+      }
+    },
+    "strip-bom": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
+      "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
+      "dev": true,
+      "requires": {
+        "is-utf8": "^0.2.0"
+      }
+    },
+    "strip-bom-string": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
+      "integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI=",
+      "dev": true
+    },
+    "strip-json-comments": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
+      "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
+      "dev": true
+    },
+    "subarg": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz",
+      "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=",
+      "dev": true,
+      "requires": {
+        "minimist": "^1.1.0"
+      }
+    },
+    "supports-preserve-symlinks-flag": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
+      "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
+      "dev": true
+    },
+    "sver-compat": {
+      "version": "1.5.0",
+      "resolved": "https://registry.npmjs.org/sver-compat/-/sver-compat-1.5.0.tgz",
+      "integrity": "sha512-aFTHfmjwizMNlNE6dsGmoAM4lHjL0CyiobWaFiXWSlD7cIxshW422Nb8KbXCmR6z+0ZEPY+daXJrDyh/vuwTyg==",
+      "dev": true,
+      "requires": {
+        "es6-iterator": "^2.0.1",
+        "es6-symbol": "^3.1.1"
+      }
+    },
+    "syntax-error": {
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz",
+      "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==",
+      "dev": true,
+      "requires": {
+        "acorn-node": "^1.2.0"
+      }
+    },
+    "through": {
+      "version": "2.3.8",
+      "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
+      "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
+      "dev": true
+    },
+    "through2": {
+      "version": "2.0.3",
+      "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
+      "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=",
+      "dev": true,
+      "requires": {
+        "readable-stream": "^2.1.5",
+        "xtend": "~4.0.1"
+      }
+    },
+    "through2-filter": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-3.0.0.tgz",
+      "integrity": "sha512-jaRjI2WxN3W1V8/FMZ9HKIBXixtiqs3SQSX4/YGIiP3gL6djW48VoZq9tDqeCWs3MT8YY5wb/zli8VW8snY1CA==",
+      "dev": true,
+      "requires": {
+        "through2": "~2.0.0",
+        "xtend": "~4.0.0"
+      }
+    },
+    "time-stamp": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz",
+      "integrity": "sha512-gLCeArryy2yNTRzTGKbZbloctj64jkZ57hj5zdraXue6aFgd6PmvVtEyiUU+hvU0v7q08oVv8r8ev0tRo6bvgw==",
+      "dev": true
+    },
+    "timers-browserify": {
+      "version": "1.4.2",
+      "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz",
+      "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=",
+      "dev": true,
+      "requires": {
+        "process": "~0.11.0"
+      }
+    },
+    "timers-ext": {
+      "version": "0.1.7",
+      "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
+      "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
+      "dev": true,
+      "requires": {
+        "es5-ext": "~0.10.46",
+        "next-tick": "1"
+      },
+      "dependencies": {
+        "es5-ext": {
+          "version": "0.10.46",
+          "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.46.tgz",
+          "integrity": "sha512-24XxRvJXNFwEMpJb3nOkiRJKRoupmjYmOPVlI65Qy2SrtxwOTB+g6ODjBKOtwEHbYrhWRty9xxOWLNdClT2djw==",
+          "dev": true,
+          "requires": {
+            "es6-iterator": "~2.0.3",
+            "es6-symbol": "~3.1.1",
+            "next-tick": "1"
+          }
+        },
+        "es6-iterator": {
+          "version": "2.0.3",
+          "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
+          "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
+          "dev": true,
+          "requires": {
+            "d": "1",
+            "es5-ext": "^0.10.35",
+            "es6-symbol": "^3.1.1"
+          }
+        }
+      }
+    },
+    "to-absolute-glob": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz",
+      "integrity": "sha512-rtwLUQEwT8ZeKQbyFJyomBRYXyE16U5VKuy0ftxLMK/PZb2fkOsg5r9kHdauuVDbsNdIBoC/HCthpidamQFXYA==",
+      "dev": true,
+      "requires": {
+        "is-absolute": "^1.0.0",
+        "is-negated-glob": "^1.0.0"
+      }
+    },
+    "to-arraybuffer": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
+      "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=",
+      "dev": true
+    },
+    "to-object-path": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz",
+      "integrity": "sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==",
+      "dev": true,
+      "requires": {
+        "kind-of": "^3.0.2"
+      },
+      "dependencies": {
+        "kind-of": {
+          "version": "3.2.2",
+          "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+          "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
+          "dev": true,
+          "requires": {
+            "is-buffer": "^1.1.5"
+          }
+        }
+      }
+    },
+    "to-regex": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz",
+      "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==",
+      "dev": true,
+      "requires": {
+        "define-property": "^2.0.2",
+        "extend-shallow": "^3.0.2",
+        "regex-not": "^1.0.2",
+        "safe-regex": "^1.1.0"
+      },
+      "dependencies": {
+        "extend-shallow": {
+          "version": "3.0.2",
+          "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+          "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==",
+          "dev": true,
+          "requires": {
+            "assign-symbols": "^1.0.0",
+            "is-extendable": "^1.0.1"
+          }
+        },
+        "is-extendable": {
+          "version": "1.0.1",
+          "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+          "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+          "dev": true,
+          "requires": {
+            "is-plain-object": "^2.0.4"
+          }
+        },
+        "is-plain-object": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+          "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+          "dev": true,
+          "requires": {
+            "isobject": "^3.0.1"
+          }
+        }
+      }
+    },
+    "to-regex-range": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz",
+      "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==",
+      "dev": true,
+      "requires": {
+        "is-number": "^3.0.0",
+        "repeat-string": "^1.6.1"
+      }
+    },
+    "to-through": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/to-through/-/to-through-2.0.0.tgz",
+      "integrity": "sha512-+QIz37Ly7acM4EMdw2PRN389OneM5+d844tirkGp4dPKzI5OE72V9OsbFp+CIYJDahZ41ZV05hNtcPAQUAm9/Q==",
+      "dev": true,
+      "requires": {
+        "through2": "^2.0.3"
+      }
+    },
+    "tsconfig": {
+      "version": "5.0.3",
+      "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-5.0.3.tgz",
+      "integrity": "sha1-X0J45wGACWeo/Dg/0ZZIh48qbjo=",
+      "dev": true,
+      "requires": {
+        "any-promise": "^1.3.0",
+        "parse-json": "^2.2.0",
+        "strip-bom": "^2.0.0",
+        "strip-json-comments": "^2.0.0"
+      }
+    },
+    "tsify": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/tsify/-/tsify-3.0.4.tgz",
+      "integrity": "sha512-y75+qgB41YS8HJck+jmSIn395I4qRGtm5ZELzvNh80Llzh8ojPWp47jm0ZoIJesNYVzbqEyLzgYXV9d/calvVg==",
+      "dev": true,
+      "requires": {
+        "convert-source-map": "^1.1.0",
+        "fs.realpath": "^1.0.0",
+        "object-assign": "^4.1.0",
+        "semver": "^5.1.0",
+        "through2": "^2.0.0",
+        "tsconfig": "^5.0.3"
+      }
+    },
+    "tty-browserify": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz",
+      "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==",
+      "dev": true
+    },
+    "typedarray": {
+      "version": "0.0.6",
+      "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
+      "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
+      "dev": true
+    },
+    "typescript": {
+      "version": "2.9.2",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz",
+      "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==",
+      "dev": true
+    },
+    "uglify-js": {
+      "version": "3.4.9",
+      "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz",
+      "integrity": "sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==",
+      "dev": true,
+      "requires": {
+        "commander": "~2.17.1",
+        "source-map": "~0.6.1"
+      },
+      "dependencies": {
+        "source-map": {
+          "version": "0.6.1",
+          "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+          "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+          "dev": true
+        }
+      }
+    },
+    "umd": {
+      "version": "3.0.3",
+      "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz",
+      "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==",
+      "dev": true
+    },
+    "unc-path-regex": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz",
+      "integrity": "sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg==",
+      "dev": true
+    },
+    "undeclared-identifiers": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz",
+      "integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==",
+      "dev": true,
+      "requires": {
+        "acorn-node": "^1.3.0",
+        "get-assigned-identifiers": "^1.2.0",
+        "simple-concat": "^1.0.0",
+        "xtend": "^4.0.1"
+      }
+    },
+    "undertaker": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.3.0.tgz",
+      "integrity": "sha512-/RXwi5m/Mu3H6IHQGww3GNt1PNXlbeCuclF2QYR14L/2CHPz3DFZkvB5hZ0N/QUkiXWCACML2jXViIQEQc2MLg==",
+      "dev": true,
+      "requires": {
+        "arr-flatten": "^1.0.1",
+        "arr-map": "^2.0.0",
+        "bach": "^1.0.0",
+        "collection-map": "^1.0.0",
+        "es6-weak-map": "^2.0.1",
+        "fast-levenshtein": "^1.0.0",
+        "last-run": "^1.1.0",
+        "object.defaults": "^1.0.0",
+        "object.reduce": "^1.0.0",
+        "undertaker-registry": "^1.0.0"
+      }
+    },
+    "undertaker-registry": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/undertaker-registry/-/undertaker-registry-1.0.1.tgz",
+      "integrity": "sha512-UR1khWeAjugW3548EfQmL9Z7pGMlBgXteQpr1IZeZBtnkCJQJIJ1Scj0mb9wQaPvUZ9Q17XqW6TIaPchJkyfqw==",
+      "dev": true
+    },
+    "union-value": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
+      "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==",
+      "dev": true,
+      "requires": {
+        "arr-union": "^3.1.0",
+        "get-value": "^2.0.6",
+        "is-extendable": "^0.1.1",
+        "set-value": "^2.0.1"
+      }
+    },
+    "unique-stream": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz",
+      "integrity": "sha512-2nY4TnBE70yoxHkDli7DMazpWiP7xMdCYqU2nBRO0UB+ZpEkGsSija7MvmvnZFUeC+mrgiUfcHSr3LmRFIg4+A==",
+      "dev": true,
+      "requires": {
+        "json-stable-stringify-without-jsonify": "^1.0.1",
+        "through2-filter": "^3.0.0"
+      }
+    },
+    "unset-value": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz",
+      "integrity": "sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==",
+      "dev": true,
+      "requires": {
+        "has-value": "^0.3.1",
+        "isobject": "^3.0.0"
+      },
+      "dependencies": {
+        "has-value": {
+          "version": "0.3.1",
+          "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz",
+          "integrity": "sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==",
+          "dev": true,
+          "requires": {
+            "get-value": "^2.0.3",
+            "has-values": "^0.1.4",
+            "isobject": "^2.0.0"
+          },
+          "dependencies": {
+            "isobject": {
+              "version": "2.1.0",
+              "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
+              "integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==",
+              "dev": true,
+              "requires": {
+                "isarray": "1.0.0"
+              }
+            }
+          }
+        },
+        "has-values": {
+          "version": "0.1.4",
+          "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz",
+          "integrity": "sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==",
+          "dev": true
+        }
+      }
+    },
+    "upath": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz",
+      "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==",
+      "dev": true
+    },
+    "urix": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz",
+      "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=",
+      "dev": true
+    },
+    "url": {
+      "version": "0.11.0",
+      "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz",
+      "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=",
+      "dev": true,
+      "requires": {
+        "punycode": "1.3.2",
+        "querystring": "0.2.0"
+      },
+      "dependencies": {
+        "punycode": {
+          "version": "1.3.2",
+          "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
+          "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=",
+          "dev": true
+        }
+      }
+    },
+    "use": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz",
+      "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==",
+      "dev": true
+    },
+    "util": {
+      "version": "0.10.4",
+      "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
+      "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
+      "dev": true,
+      "requires": {
+        "inherits": "2.0.3"
+      }
+    },
+    "util-deprecate": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+      "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
+      "dev": true
+    },
+    "v8flags": {
+      "version": "3.2.0",
+      "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz",
+      "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==",
+      "dev": true,
+      "requires": {
+        "homedir-polyfill": "^1.0.1"
+      }
+    },
+    "validate-npm-package-license": {
+      "version": "3.0.4",
+      "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
+      "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==",
+      "dev": true,
+      "requires": {
+        "spdx-correct": "^3.0.0",
+        "spdx-expression-parse": "^3.0.0"
+      }
+    },
+    "value-or-function": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz",
+      "integrity": "sha512-jdBB2FrWvQC/pnPtIqcLsMaQgjhdb6B7tk1MMyTKapox+tQZbdRP4uLxu/JY0t7fbfDCUMnuelzEYv5GsxHhdg==",
+      "dev": true
+    },
+    "vinyl": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
+      "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
+      "dev": true,
+      "requires": {
+        "clone": "^2.1.1",
+        "clone-buffer": "^1.0.0",
+        "clone-stats": "^1.0.0",
+        "cloneable-readable": "^1.0.0",
+        "remove-trailing-separator": "^1.0.1",
+        "replace-ext": "^1.0.0"
+      },
+      "dependencies": {
+        "clone": {
+          "version": "2.1.2",
+          "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
+          "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=",
+          "dev": true
+        },
+        "clone-stats": {
+          "version": "1.0.0",
+          "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
+          "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=",
+          "dev": true
+        },
+        "replace-ext": {
+          "version": "1.0.0",
+          "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
+          "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=",
+          "dev": true
+        }
+      }
+    },
+    "vinyl-buffer": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/vinyl-buffer/-/vinyl-buffer-1.0.1.tgz",
+      "integrity": "sha1-lsGjR5uMU5JULGEgKQE7Wyf4i78=",
+      "dev": true,
+      "requires": {
+        "bl": "^1.2.1",
+        "through2": "^2.0.3"
+      }
+    },
+    "vinyl-fs": {
+      "version": "3.0.3",
+      "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz",
+      "integrity": "sha512-vIu34EkyNyJxmP0jscNzWBSygh7VWhqun6RmqVfXePrOwi9lhvRs//dOaGOTRUQr4tx7/zd26Tk5WeSVZitgng==",
+      "dev": true,
+      "requires": {
+        "fs-mkdirp-stream": "^1.0.0",
+        "glob-stream": "^6.1.0",
+        "graceful-fs": "^4.0.0",
+        "is-valid-glob": "^1.0.0",
+        "lazystream": "^1.0.0",
+        "lead": "^1.0.0",
+        "object.assign": "^4.0.4",
+        "pumpify": "^1.3.5",
+        "readable-stream": "^2.3.3",
+        "remove-bom-buffer": "^3.0.0",
+        "remove-bom-stream": "^1.2.0",
+        "resolve-options": "^1.1.0",
+        "through2": "^2.0.0",
+        "to-through": "^2.0.0",
+        "value-or-function": "^3.0.0",
+        "vinyl": "^2.0.0",
+        "vinyl-sourcemap": "^1.1.0"
+      }
+    },
+    "vinyl-source-stream": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/vinyl-source-stream/-/vinyl-source-stream-2.0.0.tgz",
+      "integrity": "sha1-84pa+53R6Ttl1VBGmsYYKsT1S44=",
+      "dev": true,
+      "requires": {
+        "through2": "^2.0.3",
+        "vinyl": "^2.1.0"
+      }
+    },
+    "vinyl-sourcemap": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz",
+      "integrity": "sha512-NiibMgt6VJGJmyw7vtzhctDcfKch4e4n9TBeoWlirb7FMg9/1Ov9k+A5ZRAtywBpRPiyECvQRQllYM8dECegVA==",
+      "dev": true,
+      "requires": {
+        "append-buffer": "^1.0.2",
+        "convert-source-map": "^1.5.0",
+        "graceful-fs": "^4.1.6",
+        "normalize-path": "^2.1.1",
+        "now-and-later": "^2.0.0",
+        "remove-bom-buffer": "^3.0.0",
+        "vinyl": "^2.0.0"
+      },
+      "dependencies": {
+        "convert-source-map": {
+          "version": "1.8.0",
+          "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz",
+          "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==",
+          "dev": true,
+          "requires": {
+            "safe-buffer": "~5.1.1"
+          }
+        }
+      }
+    },
+    "vinyl-sourcemaps-apply": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz",
+      "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=",
+      "dev": true,
+      "requires": {
+        "source-map": "^0.5.1"
+      }
+    },
+    "vm-browserify": {
+      "version": "0.0.4",
+      "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
+      "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=",
+      "dev": true,
+      "requires": {
+        "indexof": "0.0.1"
+      }
+    },
+    "which": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
+      "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
+      "dev": true,
+      "requires": {
+        "isexe": "^2.0.0"
+      }
+    },
+    "which-module": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz",
+      "integrity": "sha512-F6+WgncZi/mJDrammbTuHe1q0R5hOXv/mBaiNA2TCNT/LTHusX0V+CJnj9XT8ki5ln2UZyyddDgHfCzyrOH7MQ==",
+      "dev": true
+    },
+    "wrap-ansi": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
+      "integrity": "sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==",
+      "dev": true,
+      "requires": {
+        "string-width": "^1.0.1",
+        "strip-ansi": "^3.0.1"
+      }
+    },
+    "wrappy": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+      "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
+      "dev": true
+    },
+    "xtend": {
+      "version": "4.0.1",
+      "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
+      "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=",
+      "dev": true
+    },
+    "y18n": {
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz",
+      "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==",
+      "dev": true
+    },
+    "yargs": {
+      "version": "7.1.2",
+      "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.2.tgz",
+      "integrity": "sha512-ZEjj/dQYQy0Zx0lgLMLR8QuaqTihnxirir7EwUHp1Axq4e3+k8jXU5K0VLbNvedv1f4EWtBonDIZm0NUr+jCcA==",
+      "dev": true,
+      "requires": {
+        "camelcase": "^3.0.0",
+        "cliui": "^3.2.0",
+        "decamelize": "^1.1.1",
+        "get-caller-file": "^1.0.1",
+        "os-locale": "^1.4.0",
+        "read-pkg-up": "^1.0.1",
+        "require-directory": "^2.1.1",
+        "require-main-filename": "^1.0.1",
+        "set-blocking": "^2.0.0",
+        "string-width": "^1.0.2",
+        "which-module": "^1.0.0",
+        "y18n": "^3.2.1",
+        "yargs-parser": "^5.0.1"
+      }
+    },
+    "yargs-parser": {
+      "version": "5.0.1",
+      "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-5.0.1.tgz",
+      "integrity": "sha512-wpav5XYiddjXxirPoCTUPbqM0PXvJ9hiBMvuJgInvo4/lAOTZzUprArw17q2O1P2+GHhbBr18/iQwjL5Z9BqfA==",
+      "dev": true,
+      "requires": {
+        "camelcase": "^3.0.0",
+        "object.assign": "^4.1.0"
+      }
+    }
+  }
+}
diff --git a/utils/haddock/haddock-api/resources/html/package.json b/utils/haddock/haddock-api/resources/html/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..224e5ef2494fd2fe5c22cfd2e6ba4465fc568a57
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/package.json
@@ -0,0 +1,33 @@
+{
+  "name": "haddock-quick-jump",
+  "version": "0.1.0",
+  "description": "A drop-down search on Haddock docs for navigating quickly to definitions of Haskell functions and types in the current package",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "build": "gulp"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/haskell/haddock.git"
+  },
+  "author": "Tim Baumann <tim@timbaumann.info>",
+  "contributors": [
+    "Mark Lentczner <markl@glyphic.com>",
+    "Moritz Drexl <mdrexl@fastmail.fm>",
+    "Alex Biehl <alexbiehl@gmail.com>"
+  ],
+  "dependencies": {
+    "fuse.js": "^3.3.0",
+    "preact": "^8.3.1"
+  },
+  "devDependencies": {
+    "browserify": "^14.5.0",
+    "gulp": "^4.0.2",
+    "gulp-sourcemaps": "^2.6.4",
+    "gulp-uglify": "^3.0.1",
+    "tsify": "^3.0.4",
+    "typescript": "^2.9.2",
+    "vinyl-buffer": "^1.0.1",
+    "vinyl-source-stream": "^2.0.0"
+  }
+}
diff --git a/utils/haddock/haddock-api/resources/html/quick-jump.css b/utils/haddock/haddock-api/resources/html/quick-jump.css
new file mode 100644
index 0000000000000000000000000000000000000000..cf10eee48e66e217e81adc2fb3b423604c82973f
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/quick-jump.css
@@ -0,0 +1,221 @@
+/* @group Fundamentals */
+
+.hidden {
+  display: none;
+}
+
+/* @end */
+
+/* @group Search box layout */
+
+#search {
+  position: fixed;
+  top: 3.2em;
+  bottom: 0;
+  left: calc(50% - 22em);
+  width: 44em;
+  z-index: 1000;
+  overflow-y: auto;
+}
+
+@media only screen and (max-width: 999px) {
+  #search {
+    top: 5.7em;
+  }
+}
+
+#search-form, #search-results {
+  box-shadow: 2px 2px 6px rgb(199, 204, 208);
+  pointer-events: all;
+}
+
+#search-form input {
+  font-size: 1.25em; line-height: 2.3em; height: 2.4em;
+  display: block;
+  box-sizing: border-box;
+  width: 100%;
+  margin: 0;
+  padding: 0 0.75em;
+  border: 0.05em solid rgb(151, 179, 202);
+}
+
+#search input:focus {
+  outline: none;
+}
+
+#search p.error {
+  color: rgb(107, 24, 24);
+  font-weight: bold;
+}
+
+#search-results {
+  box-sizing: border-box;
+  border: 0.05em solid #b2d5fb;
+  background: #e8f3ff;
+  max-height: 80%;
+  overflow: scroll;
+}
+
+#search-form input + #search-results {
+  border-top: none;
+  top: 3em;
+  max-height: calc(100% - 3em);
+}
+
+/* @end */
+
+/* @group search results */
+
+#search-results > ul {
+  margin: 0;
+  list-style: none;
+}
+
+#search-results > ul > li,
+#search-results > p,
+#search-results > table {
+  padding: 0.5em 1em;
+  margin: 0;
+}
+
+#search-results > ul > li {
+  border-bottom: 1px solid #b2d5fb;
+}
+
+#search-results > ul > li > ul {
+  list-style: none;
+}
+
+.search-module h4 {
+  margin: 0;
+}
+
+.search-module > ul {
+  margin: 0.5em 0 0.5em 2em;
+}
+
+.search-module > ul > li > a[href] {
+  display: block;
+  color: inherit;
+  padding: 0.25em 0.5em;
+}
+
+.search-module > ul > li > a[href].active-link {
+  background: #faf9dc;
+}
+
+.search-module a[href]:hover {
+  text-decoration: none;
+}
+
+.search-result a a {
+  pointer-events: none;
+}
+
+.search-result ul.subs {
+  display: inline-block;
+  margin: 0; padding: 0;
+}
+
+.search-result ul.subs li {
+  display: none;
+}
+
+.search-result ul.subs::after {
+  display: inline-block;
+  content: "...";
+  color: rgb(78,98,114);
+  margin: 0 0.25em;
+}
+
+.more-results {
+  color: rgb(99, 141, 173);
+  position: relative;
+}
+
+.more-results::before {
+  content: "+";
+  display: inline-block;
+  color: #b2d5fb;
+  font-weight: bold;
+  font-size: 1.25em; line-height: inherit;
+  position: absolute;
+  left: -1em;
+}
+
+/* @end */
+
+/* @group Keyboard shortcuts table */
+
+.keyboard-shortcuts {
+  line-height: 1.6em;
+}
+
+.keyboard-shortcuts th {
+  color: rgb(78,98,114);
+}
+
+.keyboard-shortcuts td:first-child,
+.keyboard-shortcuts th:first-child {
+  text-align: right;
+  padding-right: 0.6em;
+}
+
+.key {
+  display: inline-block;
+  font-size: 0.9em;
+  min-width: 0.8em; line-height: 1.2em;
+  text-align: center;
+  background: #b2d5fb;
+  border: 1px solid #74a3d6;
+  padding: 0 0.2em;
+  margin: 0 0.1em;
+}
+
+/* @end */
+
+/* @group Dropdown menus */
+
+/* Based on #search styling above. */
+
+.dropdown-menu {
+  position: fixed;
+  /* Not robust to window size changes. */
+  top: 3.2em;
+  right: 0;
+  /* To display on top of synopsis menu on right side. */
+  z-index: 1000;
+  border: 0.05em solid #b2d5fb;
+  background: #e8f3ff;
+}
+
+@media only screen and (max-width: 999px) {
+  .dropdown-menu {
+    top: 5.7em;
+  }
+}
+
+.dropdown-menu * {
+  margin: 0.1em;
+}
+
+.dropdown-menu button {
+  border: 1px #5E5184 solid;
+  border-radius: 3px;
+  background: #5E5184;
+  padding: 3px;
+  color: #f4f4f4;
+  min-width: 6em;
+}
+
+.dropdown-menu button:hover {
+  color: #5E5184;
+  background: #f4f4f4;
+}
+
+.dropdown-menu button:active {
+  color: #f4f4f4;
+  background: #5E5184;
+}
+
+/* @end */
diff --git a/utils/haddock/haddock-api/resources/html/quick-jump.min.js b/utils/haddock/haddock-api/resources/html/quick-jump.min.js
new file mode 100644
index 0000000000000000000000000000000000000000..0b0eeb27d1c5b1dbfe95635a7f80c41c4c6c3eeb
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/quick-jump.min.js
@@ -0,0 +1,2 @@
+!function i(s,a,l){function c(t,e){if(!a[t]){if(!s[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(u)return u(t,!0);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}var r=a[t]={exports:{}};s[t][0].call(r.exports,function(e){return c(s[t][1][e]||e)},r,r.exports,i,s,a,l)}return a[t].exports}for(var u="function"==typeof require&&require,e=0;e<l.length;e++)c(l[e]);return c}({1:[function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var i=e("fuse.js"),s=e("preact"),a=s.h,l=s.Component;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.render=function(t){return a("li",null,a("a",{href:"#",onClick:function(e){e.preventDefault(),t.onClick()}},t.title))},t}(l);function u(e,t){return t.length<=e?t:t.slice(0,e)}var h=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.linkIndex=0,e.focusPlease=!1,e.navigatedByKeyboard=!1,e}return r(e,t),e.prototype.componentWillMount=function(){var e,t,n,o,r=this;this.setState({searchString:"",isVisible:!1,expanded:{},activeLinkIndex:-1,moduleResults:[]}),e=this.props.baseUrl+"/doc-index.json",t=function(e){r.setState({fuse:new i(e,{threshold:.25,caseSensitive:!0,includeScore:!0,tokenize:!0,keys:[{name:"name",weight:.7},{name:"module",weight:.3}]}),moduleResults:[]})},n=function(e){console&&console.error("could not load 'doc-index.json' for searching",e),r.setState({failedLoading:!0})},(o=new XMLHttpRequest).onreadystatechange=function(){if(o.readyState===XMLHttpRequest.DONE)if(200===o.status){if(t)try{t(JSON.parse(o.responseText))}catch(e){n(o)}}else n&&n(o)},o.open("GET",e,!0),o.send(),document.addEventListener("mousedown",this.hide.bind(this)),document.addEventListener("keydown",function(e){r.state.isVisible&&("Escape"===e.key?r.hide():"ArrowUp"===e.key||"k"===e.key&&e.ctrlKey?(e.preventDefault(),r.navigateLinks(-1)):"ArrowDown"===e.key||"j"===e.key&&e.ctrlKey?(e.preventDefault(),r.navigateLinks(1)):"Enter"===e.key&&0<=r.state.activeLinkIndex&&r.followActiveLink()),"s"===e.key&&"input"!==e.target.tagName.toLowerCase()&&(e.preventDefault(),r.show())})},e.prototype.hide=function(){this.setState({isVisible:!1,searchString:""})},e.prototype.show=function(){this.state.isVisible||(this.focusPlease=!0,this.setState({isVisible:!0,activeLinkIndex:-1}))},e.prototype.toggleVisibility=function(){this.state.isVisible?this.hide():this.show()},e.prototype.navigateLinks=function(e){var t=Math.max(-1,Math.min(this.linkIndex-1,this.state.activeLinkIndex+e));this.navigatedByKeyboard=!0,this.setState({activeLinkIndex:t})},e.prototype.followActiveLink=function(){this.activeLinkAction&&this.activeLinkAction()},e.prototype.updateResults=function(){var e=this.input&&this.input.value||"",t=this.state.fuse.search(e),o={};t.forEach(function(e){var t=e.item.module;(o[t]||(o[t]=[])).push(e)});var r=[],n=function(e){var t=o[e],n=0;t.forEach(function(e){n+=1/e.score}),r.push({module:e,totalScore:1/n,items:t})};for(var i in o)n(i);r.sort(function(e,t){return e.totalScore-t.totalScore}),this.setState({searchString:e,isVisible:!0,moduleResults:r})},e.prototype.componentDidUpdate=function(){if(this.searchResults&&this.activeLink&&this.navigatedByKeyboard){var e=this.activeLink.getClientRects()[0],t=this.searchResults.getClientRects()[0].top;e.bottom>window.innerHeight?this.searchResults.scrollTop+=e.bottom-window.innerHeight+80:e.top<t&&(this.searchResults.scrollTop-=t-e.top+80)}this.focusPlease&&this.input&&this.input.focus(),this.navigatedByKeyboard=!1,this.focusPlease=!1},e.prototype.componentDidMount=function(){this.props.showHideTrigger(this.toggleVisibility.bind(this))},e.prototype.render=function(e,t){var r=this;if(t.failedLoading){var n="file:"==window.location.protocol;return a("div",{id:"search",class:t.isVisible?"":"hidden"},a("div",{id:"search-results"},a("p",{class:"error"},"Failed to load file 'doc-index.json' containing definitions in this package."),n?a("p",{class:"error"},"To use quick jump, load this page with HTTP (from a local static file web server) instead of using the ",a("code",null,"file://")," protocol. (For security reasons, it is not possible to fetch auxiliary files using JS in a HTML page opened with ",a("code",null,"file://"),".)"):[]))}this.linkIndex=0;var o=function(e){e.stopPropagation()},i=u(10,t.moduleResults).map(function(e){return r.renderResultsInModule(e)});return a("div",{id:"search",class:t.isVisible?"":"hidden"},a("div",{id:"search-form",onMouseDown:o},a("input",{placeholder:"Search in package by name",ref:function(e){r.input=e},onFocus:this.show.bind(this),onClick:this.show.bind(this),onInput:this.updateResults.bind(this)})),a("div",{id:"search-results",ref:function(e){r.searchResults=e},onMouseDown:o,onMouseOver:function(e){for(var t=e.target;t&&"function"==typeof t.getAttribute;){var n=t.getAttribute("data-link-index");if("string"==typeof n){var o=parseInt(n,10);r.setState({activeLinkIndex:o});break}t=t.parentNode}}},""===t.searchString?[a(f,null),a(d,null)]:0==i.length?a(v,{searchString:t.searchString}):a("ul",null,i)))},e.prototype.renderResultsInModule=function(e){var n=this,t=e.items,o=e.module,r=this.state.expanded[o]||t.length<=10,i=r?t:u(8,t);return a("li",{class:"search-module"},a("h4",null,o),a("ul",null,i.map(function(e){return t=e.item,a("li",{class:"search-result"},n.navigationLink(n.props.baseUrl+"/"+t.link,{},a(p,{html:t.display_html})));var t}),r?[]:a("li",{class:"more-results"},this.actionLink(function(){var e=Object.assign({},n.state.expanded);e[o]=!0,n.setState({expanded:e})},{},"show "+(t.length-i.length)+" more results from this module"))))},e.prototype.navigationLink=function(e,t){for(var n=this,o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];var i=Object.assign({href:e,onClick:this.hide.bind(this)},t);return this.menuLink.apply(this,[i,function(){window.location.href=e,n.hide()}].concat(o))},e.prototype.actionLink=function(t,e){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=Object.assign({href:"#",onClick:function(e){e.preventDefault(),t()}},e);return this.menuLink.apply(this,[r,t].concat(n))},e.prototype.menuLink=function(e,t){for(var n=this,o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];var i=this.linkIndex;i===this.state.activeLinkIndex&&(e.class=(e.class?e.class+" ":"")+"active-link",e.ref=function(e){e&&(n.activeLink=e)},this.activeLinkAction=t);var s=Object.assign({"data-link-index":i},e);return this.linkIndex+=1,a.apply(void 0,["a",s].concat(o))},e}(l),p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.shouldComponentUpdate=function(e){return this.props.html!==e.html},t.prototype.render=function(e){return a("div",{dangerouslySetInnerHTML:{__html:e.html}})},t}(l);function d(){return a("table",{class:"keyboard-shortcuts"},a("tr",null,a("th",null,"Key"),a("th",null,"Shortcut")),a("tr",null,a("td",null,a("span",{class:"key"},"s")),a("td",null,"Open this search box")),a("tr",null,a("td",null,a("span",{class:"key"},"esc")),a("td",null,"Close this search box")),a("tr",null,a("td",null,a("span",{class:"key"},"↓"),",",a("span",{class:"key"},"ctrl")," + ",a("span",{class:"key"},"j")),a("td",null,"Move down in search results")),a("tr",null,a("td",null,a("span",{class:"key"},"↑"),",",a("span",{class:"key"},"ctrl")," + ",a("span",{class:"key"},"k")),a("td",null,"Move up in search results")),a("tr",null,a("td",null,a("span",{class:"key"},"↵")),a("td",null,"Go to active search result")))}function f(){return a("p",null,"You can find any exported type, constructor, class, function or pattern defined in this package by (approximate) name.")}function v(e){var t=[a("p",null,"Your search for '",e.searchString,"' produced the following list of results: ",a("code",null,"[]"),"."),a("p",null,a("code",null,"Nothing")," matches your query for '",e.searchString,"'."),a("p",null,a("code",null,"Left \"no matches for '",e.searchString,"'\" :: Either String (NonEmpty SearchResult)"))];return t[(e.searchString||"a").charCodeAt(0)%t.length]}function g(e,t){var n,o=document.getElementById("quick-jump-button");o&&s.render(a(h,{baseUrl:e||".",showHideTrigger:t||(n=o,function(e){var t=document.querySelector("#page-menu");s.render(a(c,{onClick:e,title:"Quick Jump"}),t,n)})}),document.body)}n.init=g,window.quickNav={init:g}},{"fuse.js":2,preact:3}],2:[function(e,t,n){var o,r;o=this,r=function(){return function(n){var o={};function r(e){if(o[e])return o[e].exports;var t=o[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,r),t.l=!0,t.exports}return r.m=n,r.c=o,r.i=function(e){return e},r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=8)}([function(e,t,n){"use strict";e.exports=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";var o=function(){function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}}();var u=n(5),h=n(7),y=n(4),r=function(){function m(e,t){var n=t.location,o=void 0===n?0:n,r=t.distance,i=void 0===r?100:r,s=t.threshold,a=void 0===s?.6:s,l=t.maxPatternLength,c=void 0===l?32:l,u=t.isCaseSensitive,h=void 0!==u&&u,p=t.tokenSeparator,d=void 0===p?/ +/g:p,f=t.findAllMatches,v=void 0!==f&&f,g=t.minMatchCharLength,_=void 0===g?1:g;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,m),this.options={location:o,distance:i,threshold:a,maxPatternLength:c,isCaseSensitive:h,tokenSeparator:d,findAllMatches:v,minMatchCharLength:_},this.pattern=this.options.isCaseSensitive?e:e.toLowerCase(),this.pattern.length<=c&&(this.patternAlphabet=y(this.pattern))}return o(m,[{key:"search",value:function(e){if(this.options.isCaseSensitive||(e=e.toLowerCase()),this.pattern===e)return{isMatch:!0,score:0,matchedIndices:[[0,e.length-1]]};var t=this.options,n=t.maxPatternLength,o=t.tokenSeparator;if(this.pattern.length>n)return u(e,this.pattern,o);var r=this.options,i=r.location,s=r.distance,a=r.threshold,l=r.findAllMatches,c=r.minMatchCharLength;return h(e,this.pattern,this.patternAlphabet,{location:i,distance:s,threshold:a,findAllMatches:l,minMatchCharLength:c})}}]),m}();e.exports=r},function(e,t,n){"use strict";var u=n(0);e.exports=function(e,t){return function e(t,n,o){if(n){var r=n.indexOf("."),i=n,s=null;-1!==r&&(i=n.slice(0,r),s=n.slice(r+1));var a=t[i];if(null!=a)if(s||"string"!=typeof a&&"number"!=typeof a)if(u(a))for(var l=0,c=a.length;l<c;l+=1)e(a[l],s,o);else s&&e(a,s,o);else o.push(a.toString())}else o.push(t);return o}(e,t,[])}},function(e,t,n){"use strict";e.exports=function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=[],o=-1,r=-1,i=0,s=e.length;i<s;i+=1){var a=e[i];a&&-1===o?o=i:a||-1===o||(t<=(r=i-1)-o+1&&n.push([o,r]),o=-1)}return e[i-1]&&t<=i-o&&n.push([o,i-1]),n}},function(e,t,n){"use strict";e.exports=function(e){for(var t={},n=e.length,o=0;o<n;o+=1)t[e.charAt(o)]=0;for(var r=0;r<n;r+=1)t[e.charAt(r)]|=1<<n-r-1;return t}},function(e,t,n){"use strict";var u=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:/ +/g,o=new RegExp(t.replace(u,"\\$&").replace(n,"|")),r=e.match(o),i=!!r,s=[];if(i)for(var a=0,l=r.length;a<l;a+=1){var c=r[a];s.push([e.indexOf(c),c.length-1])}return{score:i?.5:1,isMatch:i,matchedIndices:s}}},function(e,t,n){"use strict";e.exports=function(e,t){var n=t.errors,o=void 0===n?0:n,r=t.currentLocation,i=void 0===r?0:r,s=t.expectedLocation,a=void 0===s?0:s,l=t.distance,c=void 0===l?100:l,u=o/e.length,h=Math.abs(a-i);return c?u+h/c:h?1:u}},function(e,t,n){"use strict";var U=n(6),R=n(3);e.exports=function(e,t,n,o){for(var r=o.location,i=void 0===r?0:r,s=o.distance,a=void 0===s?100:s,l=o.threshold,c=void 0===l?.6:l,u=o.findAllMatches,h=void 0!==u&&u,p=o.minMatchCharLength,d=void 0===p?1:p,f=i,v=e.length,g=c,_=e.indexOf(t,f),m=t.length,y=[],k=0;k<v;k+=1)y[k]=0;if(-1!==_){var b=U(t,{errors:0,currentLocation:_,expectedLocation:f,distance:a});if(g=Math.min(b,g),-1!==(_=e.lastIndexOf(t,f+m))){var x=U(t,{errors:0,currentLocation:_,expectedLocation:f,distance:a});g=Math.min(x,g)}}_=-1;for(var S=[],w=1,L=m+v,C=1<<m-1,M=0;M<m;M+=1){for(var A=0,I=L;A<I;){U(t,{errors:M,currentLocation:f+I,expectedLocation:f,distance:a})<=g?A=I:L=I,I=Math.floor((L-A)/2+A)}L=I;var N=Math.max(1,f-I+1),T=h?v:Math.min(f+I,v)+m,O=Array(T+2);O[T+1]=(1<<M)-1;for(var P=T;N<=P;P-=1){var j=P-1,E=n[e.charAt(j)];if(E&&(y[j]=1),O[P]=(O[P+1]<<1|1)&E,0!==M&&(O[P]|=(S[P+1]|S[P])<<1|1|S[P+1]),O[P]&C&&(w=U(t,{errors:M,currentLocation:j,expectedLocation:f,distance:a}))<=g){if(g=w,(_=j)<=f)break;N=Math.max(1,2*f-_)}}if(g<U(t,{errors:M+1,currentLocation:f,expectedLocation:f,distance:a}))break;S=O}return{isMatch:0<=_,score:0===w?.001:w,matchedIndices:R(y,d)}}},function(e,t,n){"use strict";var o=function(){function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}}();var i=n(1),F=n(2),U=n(0),r=function(){function D(e,t){var n=t.location,o=void 0===n?0:n,r=t.distance,i=void 0===r?100:r,s=t.threshold,a=void 0===s?.6:s,l=t.maxPatternLength,c=void 0===l?32:l,u=t.caseSensitive,h=void 0!==u&&u,p=t.tokenSeparator,d=void 0===p?/ +/g:p,f=t.findAllMatches,v=void 0!==f&&f,g=t.minMatchCharLength,_=void 0===g?1:g,m=t.id,y=void 0===m?null:m,k=t.keys,b=void 0===k?[]:k,x=t.shouldSort,S=void 0===x||x,w=t.getFn,L=void 0===w?F:w,C=t.sortFn,M=void 0===C?function(e,t){return e.score-t.score}:C,A=t.tokenize,I=void 0!==A&&A,N=t.matchAllTokens,T=void 0!==N&&N,O=t.includeMatches,P=void 0!==O&&O,j=t.includeScore,E=void 0!==j&&j,U=t.verbose,R=void 0!==U&&U;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,D),this.options={location:o,distance:i,threshold:a,maxPatternLength:c,isCaseSensitive:h,tokenSeparator:d,findAllMatches:v,minMatchCharLength:_,id:y,keys:b,includeMatches:P,includeScore:E,shouldSort:S,getFn:L,sortFn:M,verbose:R,tokenize:I,matchAllTokens:T},this.setCollection(e)}return o(D,[{key:"setCollection",value:function(e){return this.list=e}},{key:"search",value:function(e){this._log('---------\nSearch pattern: "'+e+'"');var t=this._prepareSearchers(e),n=t.tokenSearchers,o=t.fullSearcher,r=this._search(n,o),i=r.weights,s=r.results;return this._computeScore(i,s),this.options.shouldSort&&this._sort(s),this._format(s)}},{key:"_prepareSearchers",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=[];if(this.options.tokenize)for(var n=e.split(this.options.tokenSeparator),o=0,r=n.length;o<r;o+=1)t.push(new i(n[o],this.options));return{tokenSearchers:t,fullSearcher:new i(e,this.options)}}},{key:"_search",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],n=this.list,o={},r=[];if("string"==typeof n[0]){for(var i=0,s=n.length;i<s;i+=1)this._analyze({key:"",value:n[i],record:i,index:i},{resultMap:o,results:r,tokenSearchers:e,fullSearcher:t});return{weights:null,results:r}}for(var a={},l=0,c=n.length;l<c;l+=1)for(var u=n[l],h=0,p=this.options.keys.length;h<p;h+=1){var d=this.options.keys[h];if("string"!=typeof d){if(a[d.name]={weight:1-d.weight||1},d.weight<=0||1<d.weight)throw new Error("Key weight has to be > 0 and <= 1");d=d.name}else a[d]={weight:1};this._analyze({key:d,value:this.options.getFn(u,d),record:u,index:l},{resultMap:o,results:r,tokenSearchers:e,fullSearcher:t})}return{weights:a,results:r}}},{key:"_analyze",value:function(e,t){var n=e.key,o=e.arrayIndex,r=void 0===o?-1:o,i=e.value,s=e.record,a=e.index,l=t.tokenSearchers,c=void 0===l?[]:l,u=t.fullSearcher,h=void 0===u?[]:u,p=t.resultMap,d=void 0===p?{}:p,f=t.results,v=void 0===f?[]:f;if(null!=i){var g=!1,_=-1,m=0;if("string"==typeof i){this._log("\nKey: "+(""===n?"-":n));var y=h.search(i);if(this._log('Full text: "'+i+'", score: '+y.score),this.options.tokenize){for(var k=i.split(this.options.tokenSeparator),b=[],x=0;x<c.length;x+=1){var S=c[x];this._log('\nPattern: "'+S.pattern+'"');for(var w=!1,L=0;L<k.length;L+=1){var C=k[L],M=S.search(C),A={};M.isMatch?(A[C]=M.score,w=g=!0,b.push(M.score)):(A[C]=1,this.options.matchAllTokens||b.push(1)),this._log('Token: "'+C+'", score: '+A[C])}w&&(m+=1)}_=b[0];for(var I=b.length,N=1;N<I;N+=1)_+=b[N];_/=I,this._log("Token score average:",_)}var T=y.score;-1<_&&(T=(T+_)/2),this._log("Score average:",T);var O=!this.options.tokenize||!this.options.matchAllTokens||m>=c.length;if(this._log("\nCheck Matches: "+O),(g||y.isMatch)&&O){var P=d[a];P?P.output.push({key:n,arrayIndex:r,value:i,score:T,matchedIndices:y.matchedIndices}):(d[a]={item:s,output:[{key:n,arrayIndex:r,value:i,score:T,matchedIndices:y.matchedIndices}]},v.push(d[a]))}}else if(U(i))for(var j=0,E=i.length;j<E;j+=1)this._analyze({key:n,arrayIndex:j,value:i[j],record:s,index:a},{resultMap:d,results:v,tokenSearchers:c,fullSearcher:h})}}},{key:"_computeScore",value:function(e,t){this._log("\n\nComputing score:\n");for(var n=0,o=t.length;n<o;n+=1){for(var r=t[n].output,i=r.length,s=1,a=1,l=0;l<i;l+=1){var c=e?e[r[l].key].weight:1,u=(1===c?r[l].score:r[l].score||.001)*c;1!==c?a=Math.min(a,u):s*=r[l].nScore=u}t[n].score=1===a?s:a,this._log(t[n])}}},{key:"_sort",value:function(e){this._log("\n\nSorting...."),e.sort(this.options.sortFn)}},{key:"_format",value:function(e){var t=[];this.options.verbose&&this._log("\n\nOutput:\n\n",JSON.stringify(e));var n=[];this.options.includeMatches&&n.push(function(e,t){var n=e.output;t.matches=[];for(var o=0,r=n.length;o<r;o+=1){var i=n[o];if(0!==i.matchedIndices.length){var s={indices:i.matchedIndices,value:i.value};i.key&&(s.key=i.key),i.hasOwnProperty("arrayIndex")&&-1<i.arrayIndex&&(s.arrayIndex=i.arrayIndex),t.matches.push(s)}}}),this.options.includeScore&&n.push(function(e,t){t.score=e.score});for(var o=0,r=e.length;o<r;o+=1){var i=e[o];if(this.options.id&&(i.item=this.options.getFn(i.item,this.options.id)[0]),n.length){for(var s={item:i.item},a=0,l=n.length;a<l;a+=1)n[a](i,s);t.push(s)}else t.push(i.item)}return t}},{key:"_log",value:function(){var e;this.options.verbose&&(e=console).log.apply(e,arguments)}}]),D}();e.exports=r}])},"object"==typeof n&&"object"==typeof t?t.exports=r():"function"==typeof define&&define.amd?define("Fuse",[],r):"object"==typeof n?n.Fuse=r():o.Fuse=r()},{}],3:[function(e,m,t){!function(){"use strict";function n(e,t){var n,o,r,i,s=h;for(i=arguments.length;2<i--;)u.push(arguments[i]);for(t&&null!=t.children&&(u.length||u.push(t.children),delete t.children);u.length;)if((o=u.pop())&&void 0!==o.pop)for(i=o.length;i--;)u.push(o[i]);else"boolean"==typeof o&&(o=null),(r="function"!=typeof e)&&(null==o?o="":"number"==typeof o?o=String(o):"string"!=typeof o&&(r=!1)),r&&n?s[s.length-1]+=o:s===h?s=[o]:s.push(o),n=r;var a=new c;return a.nodeName=e,a.children=s,a.attributes=null==t?void 0:t,a.key=null==t?void 0:t.key,void 0!==R.vnode&&R.vnode(a),a}function C(e,t){for(var n in t)e[n]=t[n];return e}function i(e){!e.__d&&(e.__d=!0)&&1==d.push(e)&&(R.debounceRendering||r)(t)}function t(){var e,t=d;for(d=[];e=t.pop();)e.__d&&E(e)}function L(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function M(e){var t=C({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var o in n)void 0===t[o]&&(t[o]=n[o]);return t}function A(e){var t=e.parentNode;t&&t.removeChild(e)}function v(e,t,n,o,r){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)n&&n(null),o&&o(e);else if("class"!==t||r)if("style"===t){if(o&&"string"!=typeof o&&"string"!=typeof n||(e.style.cssText=o||""),o&&"object"==typeof o){if("string"!=typeof n)for(var i in n)i in o||(e.style[i]="");for(var i in o)e.style[i]="number"==typeof o[i]&&!1===p.test(i)?o[i]+"px":o[i]}}else if("dangerouslySetInnerHTML"===t)o&&(e.innerHTML=o.__html||"");else if("o"==t[0]&&"n"==t[1]){var s=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),o?n||e.addEventListener(t,l,s):e.removeEventListener(t,l,s),(e.__l||(e.__l={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e){try{e[t]=null==o?"":o}catch(e){}null!=o&&!1!==o||"spellcheck"==t||e.removeAttribute(t)}else{var a=r&&t!==(t=t.replace(/^xlink:?/,""));null==o||!1===o?a?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof o&&(a?e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),o):e.setAttribute(t,o))}else e.className=o||""}function l(e){return this.__l[e.type](R.event&&R.event(e)||e)}function I(){for(var e;e=D.pop();)R.afterMount&&R.afterMount(e),e.componentDidMount&&e.componentDidMount()}function N(e,t,n,o,r,i){F++||(g=null!=r&&void 0!==r.ownerSVGElement,_=null!=e&&!("__preactattr_"in e));var s=T(e,t,n,o,i);return r&&s.parentNode!==r&&r.appendChild(s),--F||(_=!1,i||I()),s}function T(e,t,n,o,r){var i=e,s=g;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||r)?e.nodeValue!=t&&(e.nodeValue=t):(i=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(i,e),O(e,!0))),i.__preactattr_=!0,i;var a,l,c=t.nodeName;if("function"==typeof c)return function(e,t,n,o){var r=e&&e._component,i=r,s=e,a=r&&e._componentConstructor===t.nodeName,l=a,c=M(t);for(;r&&!l&&(r=r.__u);)l=r.constructor===t.nodeName;r&&l&&(!o||r._component)?(j(r,c,3,n,o),e=r.base):(i&&!a&&(U(i),e=s=null),r=P(t.nodeName,c,n),e&&!r.__b&&(r.__b=e,s=null),j(r,c,1,n,o),e=r.base,s&&e!==s&&(s._component=null,O(s,!1)));return e}(e,t,n,o);if(g="svg"===c||"foreignObject"!==c&&g,c=String(c),(!e||!L(e,c))&&(a=c,(l=g?document.createElementNS("http://www.w3.org/2000/svg",a):document.createElement(a)).__n=a,i=l,e)){for(;e.firstChild;)i.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(i,e),O(e,!0)}var u=i.firstChild,h=i.__preactattr_,p=t.children;if(null==h){h=i.__preactattr_={};for(var d=i.attributes,f=d.length;f--;)h[d[f].name]=d[f].value}return!_&&p&&1===p.length&&"string"==typeof p[0]&&null!=u&&void 0!==u.splitText&&null==u.nextSibling?u.nodeValue!=p[0]&&(u.nodeValue=p[0]):(p&&p.length||null!=u)&&function(e,t,n,o,r){var i,s,a,l,c,u=e.childNodes,h=[],p={},d=0,f=0,v=u.length,g=0,_=t?t.length:0;if(0!==v)for(var m=0;m<v;m++){var y=u[m],k=y.__preactattr_,b=_&&k?y._component?y._component.__k:k.key:null;null!=b?(d++,p[b]=y):(k||(void 0!==y.splitText?!r||y.nodeValue.trim():r))&&(h[g++]=y)}if(0!==_)for(var m=0;m<_;m++){l=t[m],c=null;var b=l.key;if(null!=b)d&&void 0!==p[b]&&(c=p[b],p[b]=void 0,d--);else if(f<g)for(i=f;i<g;i++)if(void 0!==h[i]&&(x=s=h[i],w=r,"string"==typeof(S=l)||"number"==typeof S?void 0!==x.splitText:"string"==typeof S.nodeName?!x._componentConstructor&&L(x,S.nodeName):w||x._componentConstructor===S.nodeName)){c=s,h[i]=void 0,i===g-1&&g--,i===f&&f++;break}c=T(c,l,n,o),a=u[m],c&&c!==e&&c!==a&&(null==a?e.appendChild(c):c===a.nextSibling?A(a):e.insertBefore(c,a))}var x,S,w;if(d)for(var m in p)void 0!==p[m]&&O(p[m],!1);for(;f<=g;)void 0!==(c=h[g--])&&O(c,!1)}(i,p,n,o,_||null!=h.dangerouslySetInnerHTML),function(e,t,n){var o;for(o in n)t&&null!=t[o]||null==n[o]||v(e,o,n[o],n[o]=void 0,g);for(o in t)"children"===o||"innerHTML"===o||o in n&&t[o]===("value"===o||"checked"===o?e[o]:n[o])||v(e,o,n[o],n[o]=t[o],g)}(i,t.attributes,h),g=s,i}function O(e,t){var n=e._component;n?U(n):(null!=e.__preactattr_&&e.__preactattr_.ref&&e.__preactattr_.ref(null),!1!==t&&null!=e.__preactattr_||A(e),o(e))}function o(e){for(e=e.lastChild;e;){var t=e.previousSibling;O(e,!0),e=t}}function P(e,t,n){var o,r=f.length;for(e.prototype&&e.prototype.render?(o=new e(t,n),a.call(o,t,n)):((o=new a(t,n)).constructor=e,o.render=s);r--;)if(f[r].constructor===e)return o.__b=f[r].__b,f.splice(r,1),o;return o}function s(e,t,n){return this.constructor(e,n)}function j(e,t,n,o,r){e.__x||(e.__x=!0,e.__r=t.ref,e.__k=t.key,delete t.ref,delete t.key,void 0===e.constructor.getDerivedStateFromProps&&(!e.base||r?e.componentWillMount&&e.componentWillMount():e.componentWillReceiveProps&&e.componentWillReceiveProps(t,o)),o&&o!==e.context&&(e.__c||(e.__c=e.context),e.context=o),e.__p||(e.__p=e.props),e.props=t,e.__x=!1,0!==n&&(1!==n&&!1===R.syncComponentUpdates&&e.base?i(e):E(e,1,r)),e.__r&&e.__r(e))}function E(e,t,n,o){if(!e.__x){var r,i,s,a=e.props,l=e.state,c=e.context,u=e.__p||a,h=e.__s||l,p=e.__c||c,d=e.base,f=e.__b,v=d||f,g=e._component,_=!1,m=p;if(e.constructor.getDerivedStateFromProps&&(l=C(C({},l),e.constructor.getDerivedStateFromProps(a,l)),e.state=l),d&&(e.props=u,e.state=h,e.context=p,2!==t&&e.shouldComponentUpdate&&!1===e.shouldComponentUpdate(a,l,c)?_=!0:e.componentWillUpdate&&e.componentWillUpdate(a,l,c),e.props=a,e.state=l,e.context=c),e.__p=e.__s=e.__c=e.__b=null,e.__d=!1,!_){r=e.render(a,l,c),e.getChildContext&&(c=C(C({},c),e.getChildContext())),d&&e.getSnapshotBeforeUpdate&&(m=e.getSnapshotBeforeUpdate(u,h));var y,k,b=r&&r.nodeName;if("function"==typeof b){var x=M(r);(i=g)&&i.constructor===b&&x.key==i.__k?j(i,x,1,c,!1):(y=i,e._component=i=P(b,x,c),i.__b=i.__b||f,i.__u=e,j(i,x,0,c,!1),E(i,1,n,!0)),k=i.base}else s=v,(y=g)&&(s=e._component=null),(v||1===t)&&(s&&(s._component=null),k=N(s,r,c,n||!d,v&&v.parentNode,!0));if(v&&k!==v&&i!==g){var S=v.parentNode;S&&k!==S&&(S.replaceChild(k,v),y||(v._component=null,O(v,!1)))}if(y&&U(y),(e.base=k)&&!o){for(var w=e,L=e;L=L.__u;)(w=L).base=k;k._component=w,k._componentConstructor=w.constructor}}for(!d||n?D.unshift(e):_||(e.componentDidUpdate&&e.componentDidUpdate(u,h,m),R.afterUpdate&&R.afterUpdate(e));e.__h.length;)e.__h.pop().call(e);F||o||I()}}function U(e){R.beforeUnmount&&R.beforeUnmount(e);var t=e.base;e.__x=!0,e.componentWillUnmount&&e.componentWillUnmount(),e.base=null;var n=e._component;n?U(n):t&&(t.__preactattr_&&t.__preactattr_.ref&&t.__preactattr_.ref(null),A(e.__b=t),f.push(e),o(t)),e.__r&&e.__r(null)}function a(e,t){this.__d=!0,this.context=t,this.props=e,this.state=this.state||{},this.__h=[]}var c=function(){},R={},u=[],h=[],r="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout,p=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,d=[],D=[],F=0,g=!1,_=!1,f=[];C(a.prototype,{setState:function(e,t){this.__s||(this.__s=this.state),this.state=C(C({},this.state),"function"==typeof e?e(this.state,this.props):e),t&&this.__h.push(t),i(this)},forceUpdate:function(e){e&&this.__h.push(e),E(this,2)},render:function(){}});var e={h:n,createElement:n,cloneElement:function(e,t){return n(e.nodeName,C(C({},e.attributes),t),2<arguments.length?[].slice.call(arguments,2):e.children)},Component:a,render:function(e,t,n){return N(n,e,{},!1,t,!1)},rerender:t,options:R};void 0!==m?m.exports=e:self.preact=e}()},{}]},{},[1]);
+//# sourceMappingURL=quick-jump.min.js.map
diff --git a/utils/haddock/haddock-api/resources/html/solarized.css b/utils/haddock/haddock-api/resources/html/solarized.css
new file mode 100644
index 0000000000000000000000000000000000000000..0146eeddcad8556c030879380ac8278c8d7fcb54
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/solarized.css
@@ -0,0 +1,97 @@
+body {
+	background-color: #fdf6e3;
+}
+
+.hs-identifier {
+	color: #073642;
+}
+
+.hs-identifier.hs-var {
+}
+
+.hs-identifier.hs-type {
+	color: #5f5faf;
+}
+
+.hs-keyword {
+	color: #af005f;
+}
+
+.hs-string, .hs-char {
+	color: #cb4b16;
+}
+
+.hs-number {
+	color: #268bd2;
+}
+
+.hs-operator {
+	color: #d33682;
+}
+
+.hs-glyph, .hs-special {
+	color: #dc322f;
+}
+
+.hs-comment {
+	color: #8a8a8a;
+}
+
+.hs-pragma {
+	color: #2aa198;
+}
+
+.hs-cpp {
+	color: #859900;
+}
+
+a:link, a:visited {
+	text-decoration: none;
+	border-bottom: 1px solid #eee8d5;
+}
+
+a:hover, a.hover-highlight {
+	background-color: #eee8d5;
+}
+
+span.annot{
+    position:relative;
+    color:#000;
+    text-decoration:none
+  }
+
+span.annot:hover{z-index:25; background-color:#ff0}
+
+span.annot span.annottext{
+  display: none;
+  border-radius: 5px 5px;
+
+  -moz-border-radius: 5px;
+  -webkit-border-radius: 5px;
+
+  box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1);
+  -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
+  -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
+
+  position: absolute;
+  left: 1em; top: 2em;
+  z-index: 99;
+  margin-left: 5;
+  background: #FFFFAA;
+  border: 2px solid #FFAD33;
+  padding: 0.8em 1em;
+}
+
+span.annot:hover span.annottext{
+  display:block;
+}
+
+/* This bridges the gap so you can mouse into the tooltip without it disappearing */
+span.annot span.annottext:before{
+  content: "";
+  position: absolute;
+  left: -1em; top: -1em;
+  background: #FFFFFF00;
+  z-index:-1;
+  padding: 2em 2em;
+}
diff --git a/utils/haddock/haddock-api/resources/html/tsconfig.json b/utils/haddock/haddock-api/resources/html/tsconfig.json
new file mode 100644
index 0000000000000000000000000000000000000000..f2c19b597b168d031ece3da20f93d86241be0657
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/html/tsconfig.json
@@ -0,0 +1,17 @@
+{
+  "compilerOptions": {
+    "sourceMap": true,
+    "noImplicitAny": true,
+    "strictNullChecks": true,
+    "noImplicitThis": true,
+    "noFallthroughCasesInSwitch": true,
+    "module": "commonjs",
+    "target": "es5",
+    "jsx": "react",
+    "jsxFactory": "h",
+    "lib": ["es2015", "dom"]
+  },
+  "include": [
+    "js-src/*"
+  ]
+}
\ No newline at end of file
diff --git a/utils/haddock/haddock-api/resources/latex/haddock.sty b/utils/haddock/haddock-api/resources/latex/haddock.sty
new file mode 100644
index 0000000000000000000000000000000000000000..6e031a98b61441ec5feec8830c46504e560b78cf
--- /dev/null
+++ b/utils/haddock/haddock-api/resources/latex/haddock.sty
@@ -0,0 +1,57 @@
+% Default Haddock style definitions.  To use your own style, invoke
+% Haddock with the option --latex-style=mystyle.
+
+\usepackage{tabulary} % see below
+
+% make hyperlinks in the PDF, and add an expandabale index
+\usepackage[pdftex,bookmarks=true]{hyperref}
+
+\newenvironment{haddocktitle}
+  {\begin{center}\bgroup\large\bfseries}
+  {\egroup\end{center}}
+\newenvironment{haddockprologue}{\vspace{1in}}{}
+
+\newcommand{\haddockmoduleheading}[1]{\chapter{\texttt{#1}}}
+
+\newcommand{\haddockbeginheader}{\hrulefill}
+\newcommand{\haddockendheader}{\noindent\hrulefill}
+
+% a little gap before the ``Methods'' header
+\newcommand{\haddockpremethods}{\vspace{2ex}}
+
+% inserted before \\begin{verbatim}
+\newcommand{\haddockverb}{\small}
+
+% an identifier: add an index entry
+\newcommand{\haddockid}[1]{\haddocktt{#1}\index{#1@\texttt{#1}}}
+
+% The tabulary environment lets us have a column that takes up ``the
+% rest of the space''.  Unfortunately it doesn't allow
+% the \end{tabulary} to be in the expansion of a macro, it must appear
+% literally in the document text, so Haddock inserts
+% the \end{tabulary} itself.
+\newcommand{\haddockbeginconstrs}{\begin{tabulary}{\linewidth}{@{}llJ@{}}}
+\newcommand{\haddockbeginargs}{\begin{tabulary}{\linewidth}{@{}llJ@{}}}
+
+\newcommand{\haddocktt}[1]{{\small \texttt{#1}}}
+\newcommand{\haddockdecltt}[1]{{\small\bfseries \texttt{#1}}}
+
+\makeatletter
+\newenvironment{haddockdesc}
+               {\list{}{\labelwidth\z@ \itemindent-\leftmargin
+                        \let\makelabel\haddocklabel}}
+               {\endlist}
+\newcommand*\haddocklabel[1]{\hspace\labelsep\haddockdecltt{#1}}
+\makeatother
+
+% after a declaration, start a new line for the documentation.
+% Otherwise, the documentation starts right after the declaration,
+% because we're using the list environment and the declaration is the
+% ``label''.  I tried making this newline part of the label, but
+% couldn't get that to work reliably (the space seemed to stretch
+% sometimes).
+\newcommand{\haddockbegindoc}{\hfill\\[1ex]}
+
+% spacing between paragraphs and no \parindent looks better
+\parskip=10pt plus2pt minus2pt
+\setlength{\parindent}{0cm}
diff --git a/utils/haddock/haddock-api/src/Documentation/Haddock.hs b/utils/haddock/haddock-api/src/Documentation/Haddock.hs
new file mode 100644
index 0000000000000000000000000000000000000000..297dc5ea671cc03d1a4c1b5233d462f4fadacef8
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Documentation/Haddock.hs
@@ -0,0 +1,91 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Documentation.Haddock
+-- Copyright   :  (c) David Waern 2010
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskellorg
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- The Haddock API: A rudimentary, highly experimental API exposing some of
+-- the internals of Haddock. Don't expect it to be stable.
+module Documentation.Haddock
+  ( -- * Interface
+    Interface (..)
+  , InstalledInterface (..)
+  , toInstalledIface
+  , createInterfaces
+  , processModules
+
+    -- * Export items & declarations
+  , ExportItem (..)
+  , DocForDecl
+  , FnArgsDoc
+
+    -- * Cross-referencing
+  , LinkEnv
+  , DocName (..)
+
+    -- * Instances
+  , DocInstance
+  , InstHead
+
+    -- * Documentation comments
+  , Doc
+  , MDoc
+  , DocH (..)
+  , Example (..)
+  , Hyperlink (..)
+  , DocMarkup
+  , DocMarkupH (..)
+  , Documentation (..)
+  , ArgMap
+  , WarningMap
+  , DocMap
+  , HaddockModInfo (..)
+  , markup
+
+    -- * Interface files
+  , InterfaceFile (..)
+  , readInterfaceFile
+  , freshNameCache
+
+    -- * Flags and options
+  , Flag (..)
+  , DocOption (..)
+
+    -- * Error handling
+  , HaddockException (..)
+
+    -- * Program entry point
+  , haddock
+  , haddockWithGhc
+  , getGhcDirs
+  , withGhc
+  ) where
+
+import Documentation.Haddock.Markup (markup)
+import Haddock
+import Haddock.Interface
+import Haddock.InterfaceFile
+import Haddock.Options
+import Haddock.Types
+
+-- | Create 'Interface' structures from a given list of Haddock command-line
+-- flags and file or module names (as accepted by 'haddock' executable).  Flags
+-- that control documentation generation or show help or version information
+-- are ignored.
+createInterfaces
+  :: [Flag]
+  -- ^ A list of command-line flags
+  -> [String]
+  -- ^ File or module names
+  -> IO [Interface]
+  -- ^ Resulting list of interfaces
+createInterfaces flags modules = do
+  (_, ifaces, _) <- withGhc flags (readPackagesAndProcessModules flags modules)
+  return ifaces
diff --git a/utils/haddock/haddock-api/src/Haddock.hs b/utils/haddock/haddock-api/src/Haddock.hs
new file mode 100644
index 0000000000000000000000000000000000000000..dd5fddf3db07b123cd341a0b49f7961d4cf1cefe
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock.hs
@@ -0,0 +1,820 @@
+{-# LANGUAGE BangPatterns        #-}
+{-# LANGUAGE CPP                 #-}
+{-# LANGUAGE LambdaCase          #-}
+{-# LANGUAGE NamedFieldPuns      #-}
+{-# LANGUAGE OverloadedStrings   #-}
+{-# LANGUAGE Rank2Types          #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# OPTIONS_GHC -Wwarn           #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Haddock
+-- Copyright   :  (c) Simon Marlow 2003-2006,
+--                    David Waern  2006-2010,
+--                    Mateusz Kowalczyk 2014
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Haddock - A Haskell Documentation Tool
+--
+-- Program entry point and top-level code.
+-----------------------------------------------------------------------------
+module Haddock (
+  haddock,
+  haddockWithGhc,
+  getGhcDirs,
+  readPackagesAndProcessModules,
+  withGhc
+) where
+
+import Haddock.Backends.Xhtml
+import Haddock.Backends.Xhtml.Meta
+import Haddock.Backends.Xhtml.Themes (getThemes)
+import Haddock.Backends.LaTeX
+import Haddock.Backends.Hoogle
+import Haddock.Backends.Hyperlinker
+import Haddock.Interface
+import Haddock.Interface.Json
+import Haddock.Parser
+import Haddock.Types
+import Haddock.Version
+import Haddock.InterfaceFile
+import Haddock.Options
+import Haddock.Utils
+import Haddock.GhcUtils (modifySessionDynFlags, setOutputDir)
+
+import Control.DeepSeq (force)
+import Control.Monad hiding (forM_)
+import Control.Monad.IO.Class (MonadIO(..))
+import Data.Bifunctor (second)
+import Data.Foldable (forM_, foldl')
+import Data.Traversable (for)
+import Data.List (find, isPrefixOf, nub)
+import Control.Exception
+import Data.Maybe
+import Data.IORef
+import Data.Map.Strict (Map)
+import Data.Version (makeVersion)
+import qualified Data.Map.Strict as Map
+import System.IO
+import System.Exit
+import System.FilePath
+
+#ifdef IN_GHC_TREE
+import System.Environment (getExecutablePath)
+#else
+import qualified GHC.Paths as GhcPaths
+import Paths_haddock_api (getDataDir)
+#endif
+import System.Directory (doesDirectoryExist, getTemporaryDirectory)
+
+import Text.ParserCombinators.ReadP (readP_to_S)
+import GHC hiding (verbosity)
+import GHC.Settings.Config
+import GHC.Driver.Config.Logger (initLogFlags)
+import GHC.Driver.Env
+import GHC.Driver.Session hiding (projectVersion, verbosity)
+import qualified GHC.Driver.Session as DynFlags (DynFlags(..))
+import GHC.Utils.Error
+import GHC.Utils.Logger
+import GHC.Types.Name.Cache
+import GHC.Unit
+import GHC.Utils.Panic (handleGhcException)
+import GHC.Data.FastString
+
+--------------------------------------------------------------------------------
+-- * Exception handling
+--------------------------------------------------------------------------------
+
+
+handleTopExceptions :: IO a -> IO a
+handleTopExceptions =
+  handleNormalExceptions . handleHaddockExceptions . handleGhcExceptions
+
+
+-- | Either returns normally or throws an ExitCode exception;
+-- all other exceptions are turned into exit exceptions.
+handleNormalExceptions :: IO a -> IO a
+handleNormalExceptions inner =
+  (inner `onException` hFlush stdout)
+  `catches`
+  [  Handler (\(code :: ExitCode) -> exitWith code)
+
+  ,  Handler (\(ex :: AsyncException) ->
+       case ex of
+         StackOverflow -> do
+           putStrLn "stack overflow: use -g +RTS -K<size> to increase it"
+           exitFailure
+         _ -> do
+           putStrLn ("haddock: " ++ show ex)
+           exitFailure)
+
+  ,  Handler (\(ex :: SomeException) -> do
+        putStrLn ("haddock: internal error: " ++ show ex)
+        exitFailure)
+  ]
+
+
+handleHaddockExceptions :: IO a -> IO a
+handleHaddockExceptions inner =
+  catches inner [Handler handler]
+  where
+    handler (e::HaddockException) = do
+      putStrLn $ "haddock: " ++ show e
+      exitFailure
+
+
+handleGhcExceptions :: IO a -> IO a
+handleGhcExceptions =
+  -- error messages propagated as exceptions
+  handleGhcException $ \e -> do
+    hFlush stdout
+    print (e :: GhcException)
+    exitFailure
+
+
+-------------------------------------------------------------------------------
+-- * Top level
+-------------------------------------------------------------------------------
+
+
+-- | Run Haddock with given list of arguments.
+--
+-- Haddock's own main function is defined in terms of this:
+--
+-- > main = getArgs >>= haddock
+haddock :: [String] -> IO ()
+haddock args = haddockWithGhc withGhc args
+
+haddockWithGhc :: (forall a. [Flag] -> Ghc a -> IO a) -> [String] -> IO ()
+haddockWithGhc ghc args = handleTopExceptions $ do
+
+  -- Parse command-line flags and handle some of them initially.
+  -- TODO: unify all of this (and some of what's in the 'render' function),
+  -- into one function that returns a record with a field for each option,
+  -- or which exits with an error or help message.
+  (flags, files) <- parseHaddockOpts args
+  shortcutFlags flags
+
+  -- If argument tracing is enabled, print the arguments we were given
+  when (Flag_TraceArgs `elem` flags) $ do
+    putStrLn $ "haddock received arguments:"
+    mapM_ (putStrLn . ("  " ++)) args
+
+  qual <- rightOrThrowE (qualification flags)
+  sinceQual <- rightOrThrowE (sinceQualification flags)
+
+  -- Inject dynamic-too into ghc options if the ghc we are using was built with
+  -- dynamic linking
+  flags'' <- ghc flags $ do
+        df <- getDynFlags
+        case lookup "GHC Dynamic" (compilerInfo df) of
+          Just "YES" -> return $ Flag_OptGhc "-dynamic-too" : flags
+          _ -> return flags
+
+  -- Inject `-j` into ghc options, if given to Haddock
+  flags' <- pure $ case optParCount flags'' of
+    Nothing       -> flags''
+    Just Nothing  -> Flag_OptGhc "-j" : flags''
+    Just (Just n) -> Flag_OptGhc ("-j" ++ show n) : flags''
+
+  -- Whether or not to bypass the interface version check
+  let noChecks = Flag_BypassInterfaceVersonCheck `elem` flags
+
+  -- Create a temporary directory and redirect GHC output there (unless user
+  -- requested otherwise).
+  --
+  -- Output dir needs to be set before calling 'depanal' since 'depanal' uses it
+  -- to compute output file names that are stored in the 'DynFlags' of the
+  -- resulting 'ModSummary's.
+  let withDir | Flag_NoTmpCompDir `elem` flags = id
+              | otherwise = withTempOutputDir
+
+  -- Output warnings about potential misuse of some flags
+  unless (Flag_NoWarnings `elem` flags) $ do
+    hypSrcWarnings flags
+    mapM_ (hPutStrLn stderr) (optGhcWarnings args)
+    when noChecks $
+      hPutStrLn stderr noCheckWarning
+
+  ghc flags' $ withDir $ do
+    dflags <- getDynFlags
+    logger <- getLogger
+    !unit_state <- hsc_units <$> getSession
+
+    -- If any --show-interface was used, show the given interfaces
+    forM_ (optShowInterfaceFile flags) $ \path -> liftIO $ do
+      name_cache <- freshNameCache
+      mIfaceFile <- readInterfaceFiles name_cache [(("", Nothing), Visible, path)] noChecks
+      forM_ mIfaceFile $ \(_,_,_, ifaceFile) -> do
+        putMsg logger $ renderJson (jsonInterfaceFile ifaceFile)
+
+    -- If we were given source files to generate documentation from, do it
+    if not (null files) then do
+      (packages, ifaces, homeLinks) <- readPackagesAndProcessModules flags files
+      let packageInfo = PackageInfo { piPackageName =
+                                        fromMaybe (PackageName mempty) (optPackageName flags)
+                                    , piPackageVersion =
+                                        fromMaybe (makeVersion []) (optPackageVersion flags)
+                                    }
+
+      -- Dump an "interface file" (.haddock file), if requested.
+      forM_ (optDumpInterfaceFile flags) $ \path -> liftIO $ do
+        writeInterfaceFile path InterfaceFile {
+            ifInstalledIfaces = map toInstalledIface ifaces
+          , ifPackageInfo     = packageInfo
+          , ifLinkEnv         = homeLinks
+          }
+
+      -- Render the interfaces.
+      liftIO $ renderStep logger dflags unit_state flags sinceQual qual packages ifaces
+
+    -- If we were not given any input files, error if documentation was
+    -- requested
+    else do
+      when (any (`elem` [Flag_Html, Flag_Hoogle, Flag_LaTeX]) flags) $
+        throwE "No input file(s)."
+
+      -- Get packages supplied with --read-interface.
+      name_cache <- liftIO $ freshNameCache
+      packages <- liftIO $ readInterfaceFiles name_cache (readIfaceArgs flags) noChecks
+
+      -- Render even though there are no input files (usually contents/index).
+      liftIO $ renderStep logger dflags unit_state flags sinceQual qual packages []
+
+-- | Run the GHC action using a temporary output directory
+withTempOutputDir :: Ghc a -> Ghc a
+withTempOutputDir action = do
+  tmp <- liftIO getTemporaryDirectory
+  x   <- liftIO getProcessID
+  let dir = tmp </> ".haddock-" ++ show x
+  modifySessionDynFlags (setOutputDir dir)
+  withTempDir dir action
+
+-- | Create warnings about potential misuse of -optghc
+optGhcWarnings :: [String] -> [String]
+optGhcWarnings = map format . filter (isPrefixOf "-optghc")
+  where
+    format arg = concat ["Warning: `", arg, "' means `-o ", drop 2 arg, "', did you mean `-", arg, "'?"]
+
+-- | Create a warning about bypassing the interface version check
+noCheckWarning :: String
+noCheckWarning = "Warning: `--bypass-interface-version-check' can cause " ++
+                 "Haddock to crash when reading Haddock interface files."
+
+withGhc :: [Flag] -> Ghc a -> IO a
+withGhc flags action = do
+  libDir <- fmap (fromMaybe (error "No GhcDir found") . snd) (getGhcDirs flags)
+
+  -- Catches all GHC source errors, then prints and re-throws them.
+  let handleSrcErrors action' = flip handleSourceError action' $ \err -> do
+        printException err
+        liftIO exitFailure
+      needHieFiles = Flag_HyperlinkedSource `elem` flags
+
+  withGhc' libDir needHieFiles (ghcFlags flags) (\_ -> handleSrcErrors action)
+
+
+readPackagesAndProcessModules :: [Flag] -> [String]
+                              -> Ghc ([(DocPaths, Visibility, FilePath, InterfaceFile)], [Interface], LinkEnv)
+readPackagesAndProcessModules flags files = do
+    -- Whether or not we bypass the interface file version check
+    let noChecks = Flag_BypassInterfaceVersonCheck `elem` flags
+
+    -- Read package dependency interface files supplied with --read-interface
+    name_cache <- hsc_NC <$> getSession
+    packages <- liftIO $ readInterfaceFiles name_cache (readIfaceArgs flags) noChecks
+
+    -- Create the interfaces for the given modules -- this is the core part of Haddock
+    let ifaceFiles = map (\(_, _, _, ifaceFile) -> ifaceFile) packages
+    (ifaces, homeLinks) <- processModules (verbosity flags) files flags ifaceFiles
+
+    return (packages, ifaces, homeLinks)
+
+
+renderStep :: Logger -> DynFlags -> UnitState -> [Flag] -> SinceQual -> QualOption
+           -> [(DocPaths, Visibility, FilePath, InterfaceFile)] -> [Interface] -> IO ()
+renderStep logger dflags unit_state flags sinceQual nameQual pkgs interfaces = do
+  updateHTMLXRefs (map (\(docPath, _ifaceFilePath, _showModules, ifaceFile) ->
+                          ( case baseUrl flags of
+                              Nothing  -> fst docPath
+                              Just url -> url </> packageName (ifUnitId ifaceFile)
+                          , ifaceFile)) pkgs)
+  let
+    installedIfaces =
+      map
+        (\(_, showModules, ifaceFilePath, ifaceFile)
+          -> (ifaceFilePath, mkPackageInterfaces showModules ifaceFile))
+        pkgs
+    extSrcMap = Map.fromList $ do
+      ((_, Just path), _, _, ifile) <- pkgs
+      iface <- ifInstalledIfaces ifile
+      return (instMod iface, path)
+  render logger dflags unit_state flags sinceQual nameQual interfaces installedIfaces extSrcMap
+  where
+    -- get package name from unit-id
+    packageName :: Unit -> String
+    packageName unit =
+      case lookupUnit unit_state unit of
+        Nothing  -> show unit
+        Just pkg -> unitPackageNameString pkg
+
+-- | Render the interfaces with whatever backend is specified in the flags.
+render :: Logger -> DynFlags -> UnitState -> [Flag] -> SinceQual -> QualOption -> [Interface]
+       -> [(FilePath, PackageInterfaces)] -> Map Module FilePath -> IO ()
+render log' dflags unit_state flags sinceQual qual ifaces packages extSrcMap = do
+
+  let
+    packageInfo = PackageInfo { piPackageName    = fromMaybe (PackageName mempty)
+                                                 $ optPackageName flags
+                              , piPackageVersion = fromMaybe (makeVersion [])
+                                                 $ optPackageVersion flags
+                              }
+
+    title                = fromMaybe "" (optTitle flags)
+    unicode              = Flag_UseUnicode `elem` flags
+    pretty               = Flag_PrettyHtml `elem` flags
+    opt_wiki_urls        = wikiUrls          flags
+    opt_base_url         = baseUrl           flags
+    opt_contents_url     = optContentsUrl    flags
+    opt_index_url        = optIndexUrl       flags
+    odir                 = outputDir         flags
+    opt_latex_style      = optLaTeXStyle     flags
+    opt_source_css       = optSourceCssFile  flags
+    opt_mathjax          = optMathjax        flags
+    dflags'
+      | unicode          = gopt_set dflags Opt_PrintUnicodeSyntax
+      | otherwise        = dflags
+    logger               = setLogFlags log' (initLogFlags dflags')
+
+    visibleIfaces    = [ i | i <- ifaces, OptHide `notElem` ifaceOptions i ]
+
+    -- /All/ interfaces including external package modules, grouped by
+    -- interface file (package).
+    allPackages      :: [PackageInterfaces]
+    allPackages      = [PackageInterfaces
+                         { piPackageInfo = packageInfo
+                         , piVisibility  = Visible
+                         , piInstalledInterfaces  = map toInstalledIface ifaces
+                         }]
+                    ++ map snd packages
+
+    -- /All/ visible interfaces including external package modules, grouped by
+    -- interface file (package).
+    allVisiblePackages :: [PackageInterfaces]
+    allVisiblePackages = [ pinfo { piInstalledInterfaces =
+                                     filter (\i -> OptHide `notElem` instOptions i)
+                                            piInstalledInterfaces
+                                 }
+                         | pinfo@PackageInterfaces
+                             { piVisibility = Visible
+                             , piInstalledInterfaces
+                             } <- allPackages
+                         ]
+
+    -- /All/ installed interfaces.
+    allInstalledIfaces :: [InstalledInterface]
+    allInstalledIfaces = concatMap (piInstalledInterfaces . snd) packages
+
+    pkgMod           = fmap ifaceMod (listToMaybe ifaces)
+    pkgKey           = fmap moduleUnit pkgMod
+    pkgStr           = fmap unitString pkgKey
+    pkgNameVer       = modulePackageInfo unit_state flags pkgMod
+    pkgName          = fmap (unpackFS . (\(PackageName n) -> n)) (fst pkgNameVer)
+    sincePkg         = case sinceQual of
+                         External -> pkgName
+                         Always -> Nothing
+
+    (srcBase, srcModule, srcEntity, srcLEntity) = sourceUrls flags
+
+    srcModule'
+      | Flag_HyperlinkedSource `elem` flags = Just hypSrcModuleUrlFormat
+      | otherwise = srcModule
+
+    srcMap = Map.union
+      (Map.map SrcExternal extSrcMap)
+      (Map.fromList [ (ifaceMod iface, SrcLocal) | iface <- ifaces ])
+
+    pkgSrcMap = Map.mapKeys moduleUnit extSrcMap
+    pkgSrcMap'
+      | Flag_HyperlinkedSource `elem` flags
+      , Just k <- pkgKey
+      = Map.insert k hypSrcModuleNameUrlFormat pkgSrcMap
+      | Just srcNameUrl <- srcEntity
+      , Just k <- pkgKey
+      = Map.insert k srcNameUrl pkgSrcMap
+      | otherwise = pkgSrcMap
+
+    -- TODO: Get these from the interface files as with srcMap
+    pkgSrcLMap'
+      | Flag_HyperlinkedSource `elem` flags
+      , Just k <- pkgKey
+      = Map.singleton k hypSrcModuleLineUrlFormat
+      | Just path <- srcLEntity
+      , Just k <- pkgKey
+      = Map.singleton k path
+      | otherwise = Map.empty
+
+    sourceUrls' = (srcBase, srcModule', pkgSrcMap', pkgSrcLMap')
+
+    installedMap :: Map Module InstalledInterface
+    installedMap = Map.fromList [ (unwire (instMod iface), iface) | iface <- allInstalledIfaces ]
+
+    -- The user gives use base-4.9.0.0, but the InstalledInterface
+    -- records the *wired in* identity base.  So untranslate it
+    -- so that we can service the request.
+    unwire :: Module -> Module
+    unwire m = m { moduleUnit = unwireUnit unit_state (moduleUnit m) }
+
+  reexportedIfaces <- concat `fmap` (for (reexportFlags flags) $ \mod_str -> do
+    let warn' = hPutStrLn stderr . ("Warning: " ++)
+    case readP_to_S parseHoleyModule mod_str of
+      [(m, "")]
+        | Just iface <- Map.lookup m installedMap
+        -> return [iface]
+        | otherwise
+        -> warn' ("Cannot find reexported module '" ++ mod_str ++ "'") >> return []
+      _ -> warn' ("Cannot parse reexported module flag '" ++ mod_str ++ "'") >> return [])
+
+  libDir   <- getHaddockLibDir flags
+  !prologue <- force <$> getPrologue dflags' flags
+  themes   <- getThemes libDir flags >>= either bye return
+
+  let withQuickjump = Flag_QuickJumpIndex `elem` flags
+      withBaseURL = isJust
+                  . find (\flag -> case flag of
+                           Flag_BaseURL base_url ->
+                             base_url /= "." && base_url /= "./"
+                           _ -> False
+                         )
+                  $ flags
+
+  when (Flag_GenIndex `elem` flags) $ do
+    withTiming logger "ppHtmlIndex" (const ()) $ do
+      _ <- {-# SCC ppHtmlIndex #-}
+           ppHtmlIndex odir title pkgStr
+                  themes opt_mathjax opt_contents_url sourceUrls' opt_wiki_urls
+                  withQuickjump
+                  (concatMap piInstalledInterfaces allVisiblePackages) pretty
+      return ()
+
+    unless withBaseURL $
+      copyHtmlBits odir libDir themes withQuickjump
+
+  when (Flag_GenContents `elem` flags) $ do
+    withTiming logger "ppHtmlContents" (const ()) $ do
+      _ <- {-# SCC ppHtmlContents #-}
+           ppHtmlContents unit_state odir title pkgStr
+                     themes opt_mathjax opt_index_url sourceUrls' opt_wiki_urls
+                     withQuickjump
+                     allVisiblePackages True prologue pretty
+                     sincePkg (makeContentsQual qual)
+      return ()
+    copyHtmlBits odir libDir themes withQuickjump
+
+  when withQuickjump $ void $
+            ppJsonIndex odir sourceUrls' opt_wiki_urls
+                        unicode Nothing qual
+                        ifaces
+                        ( nub
+                        . map fst
+                        . filter ((== Visible) . piVisibility . snd)
+                        $ packages)
+
+  when (Flag_Html `elem` flags) $ do
+    withTiming logger "ppHtml" (const ()) $ do
+      _ <- {-# SCC ppHtml #-}
+           ppHtml unit_state title pkgStr visibleIfaces reexportedIfaces odir
+                  prologue
+                  themes opt_mathjax sourceUrls' opt_wiki_urls opt_base_url
+                  opt_contents_url opt_index_url unicode sincePkg packageInfo
+                  qual pretty withQuickjump
+      return ()
+    unless withBaseURL $ do
+      copyHtmlBits odir libDir themes withQuickjump
+      writeHaddockMeta odir withQuickjump
+
+  -- TODO: we throw away Meta for both Hoogle and LaTeX right now,
+  -- might want to fix that if/when these two get some work on them
+  when (Flag_Hoogle `elem` flags) $ do
+    case pkgNameVer of
+      (Just (PackageName pkgNameFS), mpkgVer) ->
+          let
+            pkgNameStr | unpackFS pkgNameFS == "main" && title /= [] = title
+                       | otherwise = unpackFS pkgNameFS
+
+            pkgVer =
+              fromMaybe (makeVersion []) mpkgVer
+          in ppHoogle dflags' unit_state pkgNameStr pkgVer title (fmap _doc prologue)
+               visibleIfaces odir
+      _ -> putStrLn . unlines $
+          [ "haddock: Unable to find a package providing module "
+            ++ maybe "<no-mod>" (moduleNameString . moduleName) pkgMod
+            ++ ", skipping Hoogle."
+          , ""
+          , "         Perhaps try specifying the desired package explicitly"
+            ++ " using the --package-name"
+          , "         and --package-version arguments."
+          ]
+
+  when (Flag_LaTeX `elem` flags) $ do
+    withTiming logger "ppLatex" (const ()) $ do
+      _ <- {-# SCC ppLatex #-}
+           ppLaTeX title pkgStr visibleIfaces odir (fmap _doc prologue) opt_latex_style
+                   libDir
+      return ()
+
+  when (Flag_HyperlinkedSource `elem` flags && not (null ifaces)) $ do
+    withTiming logger "ppHyperlinkedSource" (const ()) $ do
+      _ <- {-# SCC ppHyperlinkedSource #-}
+           ppHyperlinkedSource (verbosity flags) odir libDir opt_source_css pretty srcMap ifaces
+      return ()
+
+
+-------------------------------------------------------------------------------
+-- * Reading and dumping interface files
+-------------------------------------------------------------------------------
+
+
+readInterfaceFiles :: NameCache
+                   -> [(DocPaths, Visibility, FilePath)]
+                   -> Bool
+                   -> IO [(DocPaths, Visibility, FilePath, InterfaceFile)]
+readInterfaceFiles name_cache_accessor pairs bypass_version_check = do
+  catMaybes `liftM` mapM ({-# SCC readInterfaceFile #-} tryReadIface) pairs
+  where
+    -- try to read an interface, warn if we can't
+    tryReadIface (paths, vis, file) =
+      readInterfaceFile name_cache_accessor file bypass_version_check >>= \case
+        Left err -> do
+          putStrLn ("Warning: Cannot read " ++ file ++ ":")
+          putStrLn ("   " ++ err)
+          putStrLn "Skipping this interface."
+          return Nothing
+        Right f -> return (Just (paths, vis, file, f))
+
+
+-------------------------------------------------------------------------------
+-- * Creating a GHC session
+-------------------------------------------------------------------------------
+
+
+-- | Start a GHC session with the -haddock flag set. Also turn off
+-- compilation and linking. Then run the given 'Ghc' action.
+withGhc' :: String -> Bool -> [String] -> (DynFlags -> Ghc a) -> IO a
+withGhc' libDir needHieFiles flags ghcActs = runGhc (Just libDir) $ do
+    logger <- getLogger
+
+    -- Set default GHC verbosity to 1. This is better for hi-haddock since -v0
+    -- creates an awkward silence during the load operation
+    default_dflags <- getSessionDynFlags >>= \dflags ->
+      pure dflags { DynFlags.verbosity = 1 }
+
+    dynflags' <- parseGhcFlags logger default_dflags
+
+    -- Disable pattern match warnings because they can be very expensive to
+    -- check, set optimization level to 0 for fastest compilation.
+    let dynflags'' = unsetPatternMatchWarnings $ updOptLevel 0 dynflags'
+
+    -- 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
+    -- ignore sublists of flags that start with "+RTS" and end in "-RTS"
+    --
+    -- See https://github.com/haskell/haddock/issues/666
+    filterRtsFlags :: [String] -> [String]
+    filterRtsFlags flgs = foldr go (const []) flgs True
+      where go "-RTS" func _ = func True
+            go "+RTS" func _ = func False
+            go _      func False = func False
+            go arg    func True = arg : func True
+
+    parseGhcFlags :: MonadIO m => Logger -> DynFlags -> m DynFlags
+    parseGhcFlags logger dynflags = do
+      -- TODO: handle warnings?
+
+      let extra_opts =
+            [ -- Include docstrings in .hi files.
+              Opt_Haddock
+
+              -- Do not recompile because of changes to optimization flags
+            , Opt_IgnoreOptimChanges
+            ]
+              -- Write .hie files if we need them for hyperlinked src
+              ++ if needHieFiles
+                    then [Opt_WriteHie] -- Generate .hie-files
+                    else []
+          dynflags' = (foldl' gopt_set dynflags extra_opts)
+                        { backend = noBackend
+                        , ghcMode = CompManager
+                        , ghcLink = NoLink
+                        }
+          flags' = filterRtsFlags flags
+
+      (dynflags'', rest, _) <- parseDynamicFlags logger dynflags' (map noLoc flags')
+      if not (null rest)
+        then throwE ("Couldn't parse GHC options: " ++ unwords flags')
+        else return dynflags''
+
+unsetPatternMatchWarnings :: DynFlags -> DynFlags
+unsetPatternMatchWarnings dflags =
+  foldl' wopt_unset dflags pattern_match_warnings
+  where
+    pattern_match_warnings =
+      [ Opt_WarnIncompletePatterns
+      , Opt_WarnIncompleteUniPatterns
+      , Opt_WarnIncompletePatternsRecUpd
+      , Opt_WarnOverlappingPatterns
+      ]
+
+-------------------------------------------------------------------------------
+-- * Misc
+-------------------------------------------------------------------------------
+
+
+getHaddockLibDir :: [Flag] -> IO FilePath
+getHaddockLibDir flags =
+  case [str | Flag_Lib str <- flags] of
+    [] -> do
+#ifdef IN_GHC_TREE
+
+      -- When in the GHC tree, we should be able to locate the "lib" folder
+      -- based on the location of the current executable.
+      base_dir <- getBaseDir      -- Provided by GHC
+      let res_dirs = [ d | Just d <- [base_dir] ] ++
+
+#else
+
+      -- When Haddock was installed by @cabal@, the resources (which are listed
+      -- under @data-files@ in the Cabal file) will have been copied to a
+      -- special directory.
+      data_dir <- getDataDir      -- Provided by Cabal
+      let res_dirs = [ data_dir ] ++
+
+#endif
+
+      -- When Haddock is built locally (eg. regular @cabal new-build@), the data
+      -- directory does not exist and we are probably invoking from either
+      -- @./haddock-api@ or @./@
+                     [ "resources"
+                     , "haddock-api/resources"
+                     ]
+
+      res_dir <- check res_dirs
+      case res_dir of
+        Just p -> return p
+        _      -> die "Haddock's resource directory does not exist!\n"
+
+    fs -> return (last fs)
+  where
+    -- Pick the first path that corresponds to a directory that exists
+    check :: [FilePath] -> IO (Maybe FilePath)
+    check [] = pure Nothing
+    check (path : other_paths) = do
+      exists <- doesDirectoryExist path
+      if exists then pure (Just path) else check other_paths
+
+-- | Find the @lib@ directory for GHC and the path to @ghc@
+getGhcDirs :: [Flag] -> IO (Maybe FilePath, Maybe FilePath)
+getGhcDirs flags = do
+
+#ifdef IN_GHC_TREE
+  base_dir <- getBaseDir
+  let ghc_path = Nothing
+#else
+  let base_dir = Just GhcPaths.libdir
+      ghc_path = Just GhcPaths.ghc
+#endif
+
+  -- If the user explicitly specifies a lib dir, use that
+  let ghc_dir = case [ dir | Flag_GhcLibDir dir <- flags ] of
+                  [] -> base_dir
+                  xs -> Just (last xs)
+
+  pure (ghc_path, ghc_dir)
+
+
+#ifdef IN_GHC_TREE
+
+-- | See 'getBaseDir' in "SysTools.BaseDir"
+getBaseDir :: IO (Maybe FilePath)
+getBaseDir = do
+
+  -- Getting executable path can fail. Turn that into 'Nothing'
+  exec_path_opt <- catch (Just <$> getExecutablePath)
+                         (\(_ :: SomeException) -> pure Nothing)
+
+  -- Check that the path we are about to return actually exists
+  case exec_path_opt of
+    Nothing -> pure Nothing
+    Just exec_path -> do
+      let base_dir = takeDirectory (takeDirectory exec_path) </> "lib"
+      exists <- doesDirectoryExist base_dir
+      pure (if exists then Just base_dir else Nothing)
+
+#endif
+
+shortcutFlags :: [Flag] -> IO ()
+shortcutFlags flags = do
+  usage <- getUsage
+
+  when (Flag_Help             `elem` flags) (bye usage)
+  when (Flag_Version          `elem` flags) byeVersion
+  when (Flag_InterfaceVersion `elem` flags) (bye (show binaryInterfaceVersion ++ "\n"))
+  when (Flag_CompatibleInterfaceVersions `elem` flags)
+    (bye (unwords (map show binaryInterfaceVersionCompatibility) ++ "\n"))
+  when (Flag_GhcVersion       `elem` flags) (bye (cProjectVersion ++ "\n"))
+
+  when (Flag_PrintGhcPath `elem` flags) $ do
+    path <- fmap fst (getGhcDirs flags)
+    bye $ fromMaybe "not available" path ++ "\n"
+
+  when (Flag_PrintGhcLibDir `elem` flags) $ do
+    dir <- fmap snd (getGhcDirs flags)
+    bye $ fromMaybe "not available" dir ++ "\n"
+
+  when (Flag_UseUnicode `elem` flags && Flag_Html `notElem` flags) $
+    throwE "Unicode can only be enabled for HTML output."
+
+  when ((Flag_GenIndex `elem` flags || Flag_GenContents `elem` flags)
+        && Flag_Html `elem` flags) $
+    throwE "-h/--html cannot be used with --gen-index or --gen-contents"
+
+  when ((Flag_GenIndex `elem` flags || Flag_GenContents `elem` flags)
+        && Flag_Hoogle `elem` flags) $
+    throwE "--hoogle cannot be used with --gen-index or --gen-contents"
+
+  when ((Flag_GenIndex `elem` flags || Flag_GenContents `elem` flags)
+        && Flag_LaTeX `elem` flags) $
+    throwE "--latex cannot be used with --gen-index or --gen-contents"
+  where
+    byeVersion = bye $
+      "Haddock version " ++ projectVersion ++ ", (c) Simon Marlow 2006\n"
+      ++ "Ported to use the GHC API by David Waern 2006-2008\n"
+
+
+-- | Generate some warnings about potential misuse of @--hyperlinked-source@.
+hypSrcWarnings :: [Flag] -> IO ()
+hypSrcWarnings flags = do
+    when (hypSrc && any isSourceUrlFlag flags) $
+        hPutStrLn stderr $ concat
+            [ "Warning: "
+            , "--source-* options are ignored when "
+            , "--hyperlinked-source is enabled."
+            ]
+    when (not hypSrc && any isSourceCssFlag flags) $
+        hPutStrLn stderr $ concat
+            [ "Warning: "
+            , "source CSS file is specified but "
+            , "--hyperlinked-source is disabled."
+            ]
+  where
+    hypSrc :: Bool
+    hypSrc = Flag_HyperlinkedSource `elem` flags
+
+    isSourceUrlFlag :: Flag -> Bool
+    isSourceUrlFlag (Flag_SourceBaseURL _) = True
+    isSourceUrlFlag (Flag_SourceModuleURL _) = True
+    isSourceUrlFlag (Flag_SourceEntityURL _) = True
+    isSourceUrlFlag (Flag_SourceLEntityURL _) = True
+    isSourceUrlFlag _ = False
+
+    isSourceCssFlag :: Flag -> Bool
+    isSourceCssFlag (Flag_SourceCss _) = True
+    isSourceCssFlag _ = False
+
+
+updateHTMLXRefs :: [(FilePath, InterfaceFile)] -> IO ()
+updateHTMLXRefs packages = do
+  let !modMap     = force $ Map.fromList mapping
+      !modNameMap = force $ Map.fromList mapping'
+  writeIORef html_xrefs_ref  modMap
+  writeIORef html_xrefs_ref' modNameMap
+  where
+    mapping = [ (instMod iface, html) | (html, ifaces) <- packages
+              , iface <- ifInstalledIfaces ifaces ]
+    mapping' = [ (moduleName m, html) | (m, html) <- mapping ]
+
+
+getPrologue :: DynFlags -> [Flag] -> IO (Maybe (MDoc RdrName))
+getPrologue dflags flags =
+  case [filename | Flag_Prologue filename <- flags ] of
+    [] -> return Nothing
+    [filename] -> do
+      h <- openFile filename ReadMode
+      hSetEncoding h utf8
+      str <- hGetContents h -- semi-closes the handle
+      return . Just $! second (fmap rdrName) $ parseParas dflags Nothing str
+    _ -> throwE "multiple -p/--prologue options"
+
+
+rightOrThrowE :: Either String b -> IO b
+rightOrThrowE (Left msg) = throwE msg
+rightOrThrowE (Right x) = pure x
+
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/HaddockDB.hs b/utils/haddock/haddock-api/src/Haddock/Backends/HaddockDB.hs
new file mode 100644
index 0000000000000000000000000000000000000000..abdcecb69aa24d555b4831386f855652af9041e5
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/HaddockDB.hs
@@ -0,0 +1,178 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.HaddockDB
+-- Copyright   :  (c) Simon Marlow 2003
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.HaddockDB (ppDocBook) where
+
+{-
+import HaddockTypes
+import HaddockUtil
+import HsSyn2
+
+import Text.PrettyPrint
+-}
+
+-----------------------------------------------------------------------------
+-- Printing the results in DocBook format
+
+ppDocBook :: a
+ppDocBook = error "not working"
+
+{-
+ppDocBook :: FilePath -> [(Module, Interface)] -> String
+ppDocBook odir mods = render (ppIfaces mods)
+
+ppIfaces mods
+  =  text "<!DOCTYPE BOOK PUBLIC \"-//OASIS//DTD DocBook V3.1//EN\" ["
+  $$ text "]>"
+  $$ text "<book>"
+  $$ text "<bookinfo>"
+  $$ text "<author><othername>HaskellDoc version 0.0</othername></author>"
+  $$ text "</bookinfo>"
+  $$ text "<article>"
+  $$ vcat (map do_mod mods)
+  $$ text "</article></book>"
+  where
+     do_mod (Module mod, iface)
+        =  text "<sect1 id=\"sec-" <> text mod <> text "\">"
+        $$ text "<title><literal>"
+	   <> text mod
+	   <> text "</literal></title>"
+	$$ text "<indexterm><primary><literal>"
+	   <> text mod
+	   <> text "</literal></primary></indexterm>"
+	$$ text "<variablelist>"
+	$$ vcat (map (do_export mod) (eltsFM (iface_decls iface)))
+	$$ text "</variablelist>"
+	$$ text "</sect1>"
+
+     do_export mod decl | (nm:_) <- declBinders decl
+	=  text "<varlistentry id=" <> ppLinkId mod nm <> char '>'
+	$$ text "<term><literal>"
+		<> do_decl decl
+		<> text "</literal></term>"
+	$$ text "<listitem>"
+	$$ text "<para>"
+	$$ text "</para>"
+	$$ text "</listitem>"
+	$$ text "</varlistentry>"
+     do_export _ _ = empty
+
+     do_decl (HsTypeSig _ [nm] ty _)
+	=  ppHsName nm <> text " :: " <> ppHsType ty
+     do_decl (HsTypeDecl _ nm args ty _)
+	=  hsep ([text "type", ppHsName nm ]
+		 ++ map ppHsName args
+		 ++ [equals, ppHsType ty])
+     do_decl (HsNewTypeDecl loc ctx nm args con drv _)
+	= hsep ([text "data", ppHsName nm] -- data, not newtype
+		++ map ppHsName args
+		) <+> equals <+> ppHsConstr con -- ToDo: derivings
+     do_decl (HsDataDecl loc ctx nm args cons drv _)
+	= hsep ([text "data", {-ToDo: context-}ppHsName nm]
+	        ++ map ppHsName args)
+            <+> vcat (zipWith (<+>) (equals : repeat (char '|'))
+                                    (map ppHsConstr cons))
+     do_decl (HsClassDecl loc ty fds decl _)
+	= hsep [text "class", ppHsType ty]
+     do_decl decl
+	= empty
+
+ppHsConstr :: HsConDecl -> Doc
+ppHsConstr (HsRecDecl pos name tvs ctxt fieldList maybe_doc) =
+	 ppHsName name
+	 <> (braces . hsep . punctuate comma . map ppField $ fieldList)
+ppHsConstr (HsConDecl pos name tvs ctxt typeList maybe_doc) =
+	 hsep (ppHsName name : map ppHsBangType typeList)
+
+ppField (HsFieldDecl ns ty doc)
+   = hsep (punctuate comma (map ppHsName ns) ++
+	 	[text "::", ppHsBangType ty])
+
+ppHsBangType :: HsBangType -> Doc
+ppHsBangType (HsBangedTy ty) = char '!' <> ppHsType ty
+ppHsBangType (HsUnBangedTy ty) = ppHsType ty
+
+ppHsContext :: HsContext -> Doc
+ppHsContext []      = empty
+ppHsContext context = parenList (map (\ (a,b) -> ppHsQName a <+>
+					 hsep (map ppHsAType b)) context)
+
+ppHsType :: HsType -> Doc
+ppHsType (HsForAllType _ Nothing context htype) =
+     hsep [ ppHsContext context, text "=>", ppHsType htype]
+ppHsType (HsForAllType fvf (Just tvs) [] htype) =
+     hsep (text "forall" : map ppHsName tvs ++ pprHsForAllSeparator fvf :
+       [ppHsType htype])
+ppHsType (HsForAllType fvf (Just tvs) context htype) =
+     hsep (text "forall" : map ppHsName tvs ++ pprHsForAllSeparator fvf :
+	   ppHsContext context : text "=>" : [ppHsType htype])
+ppHsType (HsTyFun a b) = fsep [ppHsBType a, text "-&gt;", ppHsType b]
+ppHsType (HsTyIP n t)  = fsep [(char '?' <> ppHsName n), text "::", ppHsType t]
+ppHsType t = ppHsBType t
+
+ppHsForAllSeparator :: ForallVisFlag -> Doc
+ppHsForAllSeparator ForallVis   = text "-&gt;"
+ppHsForAllSeparator ForallInvis = text "."
+
+ppHsBType (HsTyApp (HsTyCon (Qual (Module "Prelude") (HsTyClsName (HsSpecial "[]")))) b )
+  = brackets $ ppHsType b
+ppHsBType (HsTyApp a b) = fsep [ppHsBType a, ppHsAType b]
+ppHsBType t = ppHsAType t
+
+ppHsAType :: HsType -> Doc
+ppHsAType (HsTyTuple True l)  = parenList . map ppHsType $ l
+ppHsAType (HsTyTuple False l) = ubxParenList . map ppHsType $ l
+-- special case
+ppHsAType (HsTyApp (HsTyCon (Qual (Module "Prelude") (HsTyClsName (HsSpecial "[]")))) b )
+  = brackets $ ppHsType b
+ppHsAType (HsTyVar name) = ppHsName name
+ppHsAType (HsTyCon name) = ppHsQName name
+ppHsAType t = parens $ ppHsType t
+
+ppHsQName :: HsQName -> Doc
+ppHsQName (UnQual str)			= ppHsName str
+ppHsQName n@(Qual (Module mod) str)
+	 | n == unit_con_name		= ppHsName str
+	 | isSpecial str 		= ppHsName str
+	 | otherwise
+		=  text "<link linkend=" <> ppLinkId mod str <> char '>'
+		<> ppHsName str
+		<> text "</link>"
+
+isSpecial (HsTyClsName id) | HsSpecial _ <- id = True
+isSpecial (HsVarName id) | HsSpecial _ <- id = True
+isSpecial _ = False
+
+ppHsName :: HsName -> Doc
+ppHsName (HsTyClsName id) = ppHsIdentifier id
+ppHsName (HsVarName id) = ppHsIdentifier id
+
+ppHsIdentifier :: HsIdentifier -> Doc
+ppHsIdentifier (HsIdent str)	= text str
+ppHsIdentifier (HsSymbol str) = text str
+ppHsIdentifier (HsSpecial str) = text str
+
+ppLinkId :: String -> HsName -> Doc
+ppLinkId mod str
+  = hcat [char '\"', text mod, char '.', ppHsName str, char '\"']
+
+-- -----------------------------------------------------------------------------
+-- * Misc
+
+parenList :: [Doc] -> Doc
+parenList = parens . fsep . punctuate comma
+
+ubxParenList :: [Doc] -> Doc
+ubxParenList = ubxparens . fsep . punctuate comma
+
+ubxparens p = text "(#" <> p <> text "#)"
+-}
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs
new file mode 100644
index 0000000000000000000000000000000000000000..775ce98a5ad93102b5ac0135d424867c359705cf
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs
@@ -0,0 +1,503 @@
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE TypeFamilies #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.Hoogle
+-- Copyright   :  (c) Neil Mitchell 2006-2008
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Write out Hoogle compatible documentation
+-- http://www.haskell.org/hoogle/
+module Haddock.Backends.Hoogle
+  ( -- * Main entry point to Hoogle output generation
+    ppHoogle
+
+    -- * Utilities for generating Hoogle output during interface creation
+  , ppExportD
+  ) where
+
+import Documentation.Haddock.Markup
+import Haddock.GhcUtils
+import Haddock.Types hiding (Version)
+import Haddock.Utils hiding (out)
+
+import GHC
+import GHC.Core.InstEnv
+import GHC.Driver.Ppr
+import GHC.Plugins (TopLevelFlag (..))
+import GHC.Types.SourceText
+import GHC.Unit.State
+import GHC.Utils.Outputable as Outputable
+import GHC.Utils.Panic
+
+import Data.Char
+import Data.Foldable (toList)
+import Data.List (intercalate, isPrefixOf)
+import Data.Maybe
+import Data.Version
+
+import System.Directory
+import System.FilePath
+
+prefix :: [String]
+prefix =
+  [ "-- Hoogle documentation, generated by Haddock"
+  , "-- See Hoogle, http://www.haskell.org/hoogle/"
+  , ""
+  ]
+
+ppHoogle :: DynFlags -> UnitState -> String -> Version -> String -> Maybe (Doc RdrName) -> [Interface] -> FilePath -> IO ()
+ppHoogle dflags unit_state package version synopsis prologue ifaces odir = do
+  let
+    -- Since Hoogle is line based, we want to avoid breaking long lines.
+    dflags' = dflags{pprCols = maxBound}
+    filename = package ++ ".txt"
+    contents =
+      prefix
+        ++ docWith dflags' (drop 2 $ dropWhile (/= ':') synopsis) prologue
+        ++ ["@package " ++ package]
+        ++ [ "@version " ++ showVersion version
+           | not (null (versionBranch version))
+           ]
+        ++ concat [ppModule dflags' unit_state i | i <- ifaces, OptHide `notElem` ifaceOptions i]
+  createDirectoryIfMissing True odir
+  writeUtf8File (odir </> filename) (unlines contents)
+
+ppModule :: DynFlags -> UnitState -> Interface -> [String]
+ppModule dflags unit_state iface =
+  ""
+    : ppDocumentation dflags (ifaceDoc iface)
+    ++ ["module " ++ moduleString (ifaceMod iface)]
+    ++ concatMap ppExportItem (ifaceRnExportItems $ iface)
+    ++ concatMap (ppInstance dflags unit_state) (ifaceInstances iface)
+
+-- | If the export item is an 'ExportDecl', get the attached Hoogle textual
+-- database entries for that export declaration.
+ppExportItem :: ExportItem DocNameI -> [String]
+ppExportItem (ExportDecl RnExportD{rnExpDHoogle = o}) = o
+ppExportItem _ = []
+
+---------------------------------------------------------------------
+-- Utility functions
+
+dropHsDocTy :: HsSigType GhcRn -> HsSigType GhcRn
+dropHsDocTy = drop_sig_ty
+  where
+    drop_sig_ty (HsSig x a b) = HsSig x a (drop_lty b)
+    drop_sig_ty x@XHsSigType{} = x
+
+    drop_lty (L src x) = L src (drop_ty x)
+
+    drop_ty (HsForAllTy x a e) = HsForAllTy x a (drop_lty e)
+    drop_ty (HsQualTy x a e) = HsQualTy x a (drop_lty e)
+    drop_ty (HsBangTy x a b) = HsBangTy x a (drop_lty b)
+    drop_ty (HsAppTy x a b) = HsAppTy x (drop_lty a) (drop_lty b)
+    drop_ty (HsAppKindTy x a b) = HsAppKindTy x (drop_lty a) (drop_lty b)
+    drop_ty (HsFunTy x w a b) = HsFunTy x w (drop_lty a) (drop_lty b)
+    drop_ty (HsListTy x a) = HsListTy x (drop_lty a)
+    drop_ty (HsTupleTy x a b) = HsTupleTy x a (map drop_lty b)
+    drop_ty (HsOpTy x p a b c) = HsOpTy x p (drop_lty a) b (drop_lty c)
+    drop_ty (HsParTy x a) = HsParTy x (drop_lty a)
+    drop_ty (HsKindSig x a b) = HsKindSig x (drop_lty a) b
+    drop_ty (HsDocTy _ a _) = drop_ty $ unL a
+    drop_ty x = x
+
+outHsSigType :: DynFlags -> HsSigType GhcRn -> String
+outHsSigType dflags = out dflags . reparenSigType . dropHsDocTy
+
+dropComment :: String -> String
+dropComment (' ' : '-' : '-' : ' ' : _) = []
+dropComment (x : xs) = x : dropComment xs
+dropComment [] = []
+
+outWith :: Outputable a => (SDoc -> String) -> a -> [Char]
+outWith p =
+  f
+    . unwords
+    . map (dropWhile isSpace)
+    . lines
+    . p
+    . ppr
+  where
+    f xs | " <document comment>" `isPrefixOf` xs = f $ drop 19 xs
+    f (x : xs) = x : f xs
+    f [] = []
+
+out :: Outputable a => DynFlags -> a -> String
+out dflags = outWith $ showSDoc dflags
+
+operator :: String -> String
+operator (x : xs) | not (isAlphaNum x) && x `notElem` "_' ([{" = '(' : x : xs ++ ")"
+operator x = x
+
+commaSeparate :: Outputable a => DynFlags -> [a] -> String
+commaSeparate dflags = showSDoc dflags . interpp'SP
+
+---------------------------------------------------------------------
+-- How to print each export
+
+ppExportD :: DynFlags -> ExportD GhcRn -> [String]
+ppExportD
+  dflags
+  ExportD
+    { expDDecl = L _ decl
+    , expDPats = bundledPats
+    , expDMbDoc = mbDoc
+    , expDSubDocs = subdocs
+    , expDFixities = fixities
+    } =
+    concat
+      [ ppDocumentation dflags' dc ++ f d
+      | (d, (dc, _)) <- (decl, mbDoc) : bundledPats
+      ]
+      ++ ppFixities
+    where
+      -- Since Hoogle is line based, we want to avoid breaking long lines.
+      dflags' :: DynFlags
+      dflags' = dflags{pprCols = maxBound}
+
+      f :: HsDecl GhcRn -> [String]
+      f (TyClD _ d@DataDecl{}) = ppData dflags' d subdocs
+      f (TyClD _ d@SynDecl{}) = ppSynonym dflags' d
+      f (TyClD _ d@ClassDecl{}) = ppClass dflags' d subdocs
+      f (TyClD _ (FamDecl _ d)) = ppFam dflags' d
+      f (ForD _ (ForeignImport _ name typ _)) = [pp_sig dflags' [name] typ]
+      f (ForD _ (ForeignExport _ name typ _)) = [pp_sig dflags' [name] typ]
+      f (SigD _ sig) = ppSig dflags' sig
+      f _ = []
+
+      ppFixities :: [String]
+      ppFixities = concatMap (ppFixity dflags') fixities
+
+ppSigWithDoc :: DynFlags -> Sig GhcRn -> [(Name, DocForDecl Name)] -> [String]
+ppSigWithDoc dflags sig subdocs = case sig of
+  TypeSig _ names t -> concatMap (mkDocSig "" (dropWildCards t)) names
+  PatSynSig _ names t -> concatMap (mkDocSig "pattern " t) names
+  _ -> []
+  where
+    mkDocSig leader typ n =
+      mkSubdocN
+        dflags
+        n
+        subdocs
+        [leader ++ pp_sig dflags [n] typ]
+
+ppSig :: DynFlags -> Sig GhcRn -> [String]
+ppSig dflags x = ppSigWithDoc dflags x []
+
+pp_sig :: DynFlags -> [LocatedN Name] -> LHsSigType GhcRn -> String
+pp_sig dflags names (L _ typ) =
+  operator prettyNames ++ " :: " ++ outHsSigType dflags typ
+  where
+    prettyNames = intercalate ", " $ map (out dflags) names
+
+-- note: does not yet output documentation for class methods
+ppClass :: DynFlags -> TyClDecl GhcRn -> [(Name, DocForDecl Name)] -> [String]
+ppClass dflags decl@(ClassDecl{}) subdocs =
+  (ppDecl ++ ppTyFams) : ppMethods
+  where
+    ppDecl :: String
+    ppDecl =
+      out
+        dflags
+        decl
+          { tcdSigs = []
+          , tcdATs = []
+          , tcdATDefs = []
+          , tcdMeths = emptyLHsBinds
+          }
+
+    ppMethods :: [String]
+    ppMethods = concat . map (ppSig' . unLoc . add_ctxt) $ tcdSigs decl
+
+    ppSig' = flip (ppSigWithDoc dflags) subdocs
+
+    add_ctxt = addClassContext (tcdName decl) (tyClDeclTyVars decl)
+
+    ppTyFams :: String
+    ppTyFams
+      | null $ tcdATs decl = ""
+      | otherwise =
+          (" " ++) . showSDoc dflags . whereWrapper $
+            concat
+              [ map pprTyFam (tcdATs decl)
+              , map (pprTyFamInstDecl NotTopLevel . unLoc) (tcdATDefs decl)
+              ]
+
+    pprTyFam :: LFamilyDecl GhcRn -> SDoc
+    pprTyFam (L _ at) =
+      vcat' $
+        map text $
+          mkSubdocN
+            dflags
+            (fdLName at)
+            subdocs
+            -- Associated type families should not be printed as top-level
+            -- (avoid printing the `family` keyword)
+            (ppFam dflags at{fdTopLevel = NotTopLevel})
+
+    whereWrapper elems =
+      vcat'
+        [ text "where" <+> lbrace
+        , nest 4 . vcat . map (Outputable.<> semi) $ elems
+        , rbrace
+        ]
+ppClass _ _non_cls_decl _ = []
+
+ppFam :: DynFlags -> FamilyDecl GhcRn -> [String]
+ppFam dflags decl@(FamilyDecl{fdInfo = info}) =
+  [out dflags decl']
+  where
+    decl' = case info of
+      -- We don't need to print out a closed type family's equations
+      -- for Hoogle, so pretend it doesn't have any.
+      ClosedTypeFamily{} -> decl{fdInfo = OpenTypeFamily}
+      _ -> decl
+
+ppInstance :: DynFlags -> UnitState -> ClsInst -> [String]
+ppInstance dflags unit_state x =
+  [dropComment $ outWith (showSDocForUser dflags unit_state alwaysQualify) cls]
+  where
+    -- As per #168, we don't want safety information about the class
+    -- in Hoogle output. The easiest way to achieve this is to set the
+    -- safety information to a state where the Outputable instance
+    -- produces no output which means no overlap and unsafe (or [safe]
+    -- is generated).
+    cls =
+      x
+        { is_flag =
+            OverlapFlag
+              { overlapMode = NoOverlap NoSourceText
+              , isSafeOverlap = False
+              }
+        }
+
+ppSynonym :: DynFlags -> TyClDecl GhcRn -> [String]
+ppSynonym dflags x = [out dflags x]
+
+ppData :: DynFlags -> TyClDecl GhcRn -> [(Name, DocForDecl Name)] -> [String]
+ppData dflags decl@DataDecl{tcdLName = name, tcdTyVars = tvs, tcdFixity = fixity, tcdDataDefn = defn} subdocs =
+  out dflags (ppDataDefnHeader (pp_vanilla_decl_head name tvs fixity) defn)
+    : concatMap (ppCtor dflags decl subdocs . unLoc) (dd_cons defn)
+ppData _ _ _ = panic "ppData"
+
+-- | for constructors, and named-fields...
+lookupCon :: DynFlags -> [(Name, DocForDecl Name)] -> LocatedN Name -> [String]
+lookupCon dflags subdocs (L _ name) = case lookup name subdocs of
+  Just (d, _) -> ppDocumentation dflags d
+  _ -> []
+
+ppCtor :: DynFlags -> TyClDecl GhcRn -> [(Name, DocForDecl Name)] -> ConDecl GhcRn -> [String]
+ppCtor dflags dat subdocs con@ConDeclH98{con_args = con_args'} =
+  -- AZ:TODO get rid of the concatMap
+  concatMap (lookupCon dflags subdocs) [con_name con] ++ f con_args'
+  where
+    f (PrefixCon _ args) = [typeSig name $ (map hsScaledThing args) ++ [resType]]
+    f (InfixCon a1 a2) = f $ PrefixCon [] [a1, a2]
+    f (RecCon (L _ recs)) =
+      f (PrefixCon [] $ map (hsLinear . cd_fld_type . unLoc) recs)
+        ++ concat
+          [ (concatMap (lookupCon dflags subdocs . noLocA . foExt . unLoc) (cd_fld_names r))
+            ++ [out dflags (map (foExt . unLoc) $ cd_fld_names r) `typeSig` [resType, cd_fld_type r]]
+          | r <- map unLoc recs
+          ]
+
+    funs = foldr1 (\x y -> reL $ HsFunTy noExtField (HsUnrestrictedArrow noExtField) x y)
+    apps = foldl1 (\x y -> reL $ HsAppTy noExtField x y)
+
+    typeSig nm flds =
+      operator nm
+        ++ " :: "
+        ++ outHsSigType dflags (unL $ mkEmptySigType $ funs flds)
+
+    -- We print the constructors as comma-separated list. See GHC
+    -- docs for con_names on why it is a list to begin with.
+    name = commaSeparate dflags . toList $ unL <$> getConNames con
+
+    tyVarArg (UserTyVar _ _ n) = HsTyVar noAnn NotPromoted n
+    tyVarArg (KindedTyVar _ _ n lty) = HsKindSig noAnn (reL (HsTyVar noAnn NotPromoted n)) lty
+    tyVarArg _ = panic "ppCtor"
+
+    resType =
+      apps $
+        map reL $
+          (HsTyVar noAnn NotPromoted (reL (tcdName dat)))
+            : map (tyVarArg . unLoc) (hsQTvExplicit $ tyClDeclTyVars dat)
+ppCtor
+  dflags
+  _dat
+  subdocs
+  ( ConDeclGADT
+      { con_names = names
+      , con_bndrs = L _ outer_bndrs
+      , con_mb_cxt = mcxt
+      , con_g_args = args
+      , con_res_ty = res_ty
+      }
+    ) =
+    concatMap (lookupCon dflags subdocs) names ++ [typeSig]
+    where
+      typeSig = operator name ++ " :: " ++ outHsSigType dflags con_sig_ty
+      name = out dflags $ unL <$> names
+      con_sig_ty = HsSig noExtField outer_bndrs theta_ty
+        where
+          theta_ty = case mcxt of
+            Just theta -> noLocA (HsQualTy{hst_xqual = noExtField, hst_ctxt = theta, hst_body = tau_ty})
+            Nothing -> tau_ty
+          tau_ty = foldr mkFunTy res_ty $
+            case args of
+              PrefixConGADT _ pos_args -> map hsScaledThing pos_args
+              RecConGADT _ (L _ flds) -> map (cd_fld_type . unL) flds
+          mkFunTy a b = noLocA (HsFunTy noExtField (HsUnrestrictedArrow noExtField) a b)
+
+ppFixity :: DynFlags -> (Name, Fixity) -> [String]
+ppFixity dflags (name, fixity) = [out dflags ((FixitySig NoNamespaceSpecifier [noLocA name] fixity) :: FixitySig GhcRn)]
+
+---------------------------------------------------------------------
+-- DOCUMENTATION
+
+ppDocumentation :: Outputable o => DynFlags -> Documentation o -> [String]
+ppDocumentation dflags (Documentation d w) = mdoc dflags d ++ doc dflags w
+
+doc :: Outputable o => DynFlags -> Maybe (Doc o) -> [String]
+doc dflags = docWith dflags ""
+
+mdoc :: Outputable o => DynFlags -> Maybe (MDoc o) -> [String]
+mdoc dflags = docWith dflags "" . fmap _doc
+
+docWith :: Outputable o => DynFlags -> String -> Maybe (Doc o) -> [String]
+docWith _ [] Nothing = []
+docWith dflags header d =
+  ("" :) $
+    zipWith (++) ("-- | " : repeat "--   ") $
+      lines header
+        ++ ["" | header /= "" && isJust d]
+        ++ maybe [] (showTags . markup (markupTag dflags)) d
+
+mkSubdocN :: DynFlags -> LocatedN Name -> [(Name, DocForDecl Name)] -> [String] -> [String]
+mkSubdocN dflags n subdocs s = mkSubdoc dflags (la2la n) subdocs s
+
+mkSubdoc :: DynFlags -> LocatedA Name -> [(Name, DocForDecl Name)] -> [String] -> [String]
+mkSubdoc dflags n subdocs s = concatMap (ppDocumentation dflags) getDoc ++ s
+  where
+    getDoc = maybe [] (return . fst) (lookup (unLoc n) subdocs)
+
+data Tag = TagL Char [Tags] | TagP Tags | TagPre Tags | TagInline String Tags | Str String
+  deriving (Show)
+
+type Tags = [Tag]
+
+box :: (a -> b) -> a -> [b]
+box f x = [f x]
+
+str :: String -> [Tag]
+str a = [Str a]
+
+-- want things like paragraph, pre etc to be handled by blank lines in the source document
+-- and things like \n and \t converted away
+-- much like blogger in HTML mode
+-- everything else wants to be included as tags, neatly nested for some (ul,li,ol)
+-- or inlne for others (a,i,tt)
+-- entities (&,>,<) should always be appropriately escaped
+
+markupTag :: Outputable o => DynFlags -> DocMarkup o [Tag]
+markupTag dflags =
+  Markup
+    { markupParagraph = box TagP
+    , markupEmpty = str ""
+    , markupString = str
+    , markupAppend = (++)
+    , markupIdentifier = box (TagInline "a") . str . out dflags
+    , markupIdentifierUnchecked = box (TagInline "a") . str . showWrapped (out dflags . snd)
+    , markupModule = \(ModLink m label) -> box (TagInline "a") (fromMaybe (str m) label)
+    , markupWarning = box (TagInline "i")
+    , markupEmphasis = box (TagInline "i")
+    , markupBold = box (TagInline "b")
+    , markupMonospaced = box (TagInline "tt")
+    , markupPic = const $ str " "
+    , markupMathInline = const $ str "<math>"
+    , markupMathDisplay = const $ str "<math>"
+    , markupUnorderedList = box (TagL 'u')
+    , markupOrderedList = box (TagL 'o') . map snd
+    , markupDefList = box (TagL 'u') . map (\(a, b) -> TagInline "i" a : Str " " : b)
+    , markupCodeBlock = box TagPre
+    , markupHyperlink = \(Hyperlink url mLabel) -> box (TagInline "a") (fromMaybe (str url) mLabel)
+    , markupAName = const $ str ""
+    , markupProperty = box TagPre . str
+    , markupExample = box TagPre . str . unlines . map exampleToString
+    , markupHeader = \(Header l h) -> box (TagInline $ "h" ++ show l) h
+    , markupTable = \(Table _ _) -> str "TODO: table"
+    }
+
+showTags :: [Tag] -> [String]
+showTags = intercalate [""] . map showBlock
+
+showBlock :: Tag -> [String]
+showBlock (TagP xs) = showInline xs
+showBlock (TagL t xs) = ['<' : t : "l>"] ++ mid ++ ['<' : '/' : t : "l>"]
+  where
+    mid = concatMap (showInline . box (TagInline "li")) xs
+showBlock (TagPre xs) = ["<pre>"] ++ showPre xs ++ ["</pre>"]
+showBlock x = showInline [x]
+
+asInline :: Tag -> Tags
+asInline (TagP xs) = xs
+asInline (TagPre xs) = [TagInline "pre" xs]
+asInline (TagL t xs) = [TagInline (t : "l") $ map (TagInline "li") xs]
+asInline x = [x]
+
+showInline :: [Tag] -> [String]
+showInline = unwordsWrap 70 . words . concatMap f
+  where
+    fs = concatMap f
+    f (Str x) = escape x
+    f (TagInline s xs) = "<" ++ s ++ ">" ++ (if s == "li" then trim else id) (fs xs) ++ "</" ++ s ++ ">"
+    f x = fs $ asInline x
+
+    trim = dropWhile isSpace . reverse . dropWhile isSpace . reverse
+
+showPre :: [Tag] -> [String]
+showPre = trimFront . trimLines . lines . concatMap f
+  where
+    trimLines = dropWhile null . reverse . dropWhile null . reverse
+    trimFront xs = map (drop i) xs
+      where
+        ns = [length a | x <- xs, let (a, b) = span isSpace x, b /= ""]
+        i = if null ns then 0 else minimum ns
+
+    fs = concatMap f
+    f (Str x) = escape x
+    f (TagInline s xs) = "<" ++ s ++ ">" ++ fs xs ++ "</" ++ s ++ ">"
+    f x = fs $ asInline x
+
+unwordsWrap :: Int -> [String] -> [String]
+unwordsWrap n = f n []
+  where
+    f _ s [] = [g s | s /= []]
+    f i s (x : xs)
+      | nx > i = g s : f (n - nx - 1) [x] xs
+      | otherwise = f (i - nx - 1) (x : s) xs
+      where
+        nx = length x
+
+    g = unwords . reverse
+
+escape :: String -> String
+escape = concatMap f
+  where
+    f '<' = "&lt;"
+    f '>' = "&gt;"
+    f '&' = "&amp;"
+    f x = [x]
+
+-- | Just like 'vcat' but uses '($+$)' instead of '($$)'.
+vcat' :: [SDoc] -> SDoc
+vcat' = foldr ($+$) empty
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
new file mode 100644
index 0000000000000000000000000000000000000000..3c29ec0866ab0ac148ca373c5df9cb791441a04c
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
@@ -0,0 +1,128 @@
+{-# LANGUAGE OverloadedRecordDot #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE PatternSynonyms #-}
+
+module Haddock.Backends.Hyperlinker
+  ( ppHyperlinkedSource
+  , module Haddock.Backends.Hyperlinker.Types
+  , module Haddock.Backends.Hyperlinker.Utils
+  ) where
+
+import Haddock.Backends.Hyperlinker.Parser
+import Haddock.Backends.Hyperlinker.Renderer
+import Haddock.Backends.Hyperlinker.Types
+import Haddock.Backends.Hyperlinker.Utils
+import Haddock.Backends.Xhtml.Utils (renderToString)
+import Haddock.InterfaceFile
+import Haddock.Types
+import Haddock.Utils (Verbosity, out, verbose, writeUtf8File)
+
+import Data.Maybe
+import System.Directory
+import System.FilePath
+
+import Data.Map as M
+import GHC.Data.FastString (mkFastString)
+import GHC.Iface.Ext.Binary (hie_file_result, readHieFile)
+import GHC.Iface.Ext.Types (HieAST (..), HieASTs (..), HieFile (..), SourcedNodeInfo (..), pattern HiePath)
+import GHC.Types.SrcLoc (mkRealSrcLoc, realSrcLocSpan, srcSpanFile)
+import GHC.Unit.Module (Module, moduleName)
+
+-- | Generate hyperlinked source for given interfaces.
+--
+-- Note that list of interfaces should also contain interfaces normally hidden
+-- when generating documentation. Otherwise this could lead to dead links in
+-- produced source.
+ppHyperlinkedSource
+  :: Verbosity
+  -> FilePath
+  -- ^ Output directory
+  -> FilePath
+  -- ^ Resource directory
+  -> Maybe FilePath
+  -- ^ Custom CSS file path
+  -> Bool
+  -- ^ Flag indicating whether to pretty-print HTML
+  -> M.Map Module SrcPath
+  -- ^ Paths to sources
+  -> [Interface]
+  -- ^ Interfaces for which we create source
+  -> IO ()
+ppHyperlinkedSource verbosity outdir libdir mstyle pretty srcs' ifaces = do
+  createDirectoryIfMissing True srcdir
+  let cssFile = fromMaybe (defaultCssFile libdir) mstyle
+  copyFile cssFile $ srcdir </> srcCssFile
+  copyFile (libdir </> "html" </> highlightScript) $
+    srcdir </> highlightScript
+  mapM_ (ppHyperlinkedModuleSource verbosity srcdir pretty srcs) ifaces
+  where
+    srcdir = outdir </> hypSrcDir
+    srcs = (srcs', M.mapKeys moduleName srcs')
+
+-- | Generate hyperlinked source for particular interface.
+ppHyperlinkedModuleSource :: Verbosity -> FilePath -> Bool -> SrcMaps -> Interface -> IO ()
+ppHyperlinkedModuleSource verbosity srcdir pretty srcs iface = do
+  -- Parse the GHC-produced HIE file
+  nc <- freshNameCache
+  HieFile
+    { hie_hs_file = file
+    , hie_asts = HieASTs asts
+    , hie_types = types
+    , hie_hs_src = rawSrc
+    } <-
+    hie_file_result
+      <$> (readHieFile nc iface.ifaceHieFile)
+
+  -- Get the AST and tokens corresponding to the source file we want
+  let fileFs = mkFastString file
+      mast
+        | M.size asts == 1 = snd <$> M.lookupMin asts
+        | otherwise = M.lookup (HiePath (mkFastString file)) asts
+      tokens' = parse df file rawSrc
+      ast = fromMaybe (emptyHieAst fileFs) mast
+      fullAst = recoverFullIfaceTypes df types ast
+
+  -- Warn if we didn't find an AST, but there were still ASTs
+  if M.null asts
+    then pure ()
+    else
+      out verbosity verbose $
+        unwords
+          [ "couldn't find ast for"
+          , file
+          , show (M.keys asts)
+          ]
+
+  -- The C preprocessor can double the backslashes on tokens (see #19236),
+  -- which means the source spans will not be comparable and we will not
+  -- be able to associate the HieAST with the correct tokens.
+  --
+  -- We work around this by setting the source span of the tokens to the file
+  -- name from the HieAST
+  let tokens = fmap (\tk -> tk{tkSpan = (tkSpan tk){srcSpanFile = srcSpanFile $ nodeSpan fullAst}}) tokens'
+
+  -- Produce and write out the hyperlinked sources
+  writeUtf8File path . renderToString pretty . render' fullAst $ tokens
+  where
+    df = ifaceDynFlags iface
+    render' = render (Just srcCssFile) (Just highlightScript) srcs
+    path = srcdir </> hypSrcModuleFile (ifaceMod iface)
+
+    emptyHieAst fileFs =
+      Node
+        { nodeSpan = realSrcLocSpan (mkRealSrcLoc fileFs 1 0)
+        , nodeChildren = []
+        , sourcedNodeInfo = SourcedNodeInfo mempty
+        }
+
+-- | Name of CSS file in output directory.
+srcCssFile :: FilePath
+srcCssFile = "style.css"
+
+-- | Name of highlight script in output and resource directory.
+highlightScript :: FilePath
+highlightScript = "highlight.js"
+
+-- | Path to default CSS file.
+defaultCssFile :: FilePath -> FilePath
+defaultCssFile libdir = libdir </> "html" </> "solarized.css"
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
new file mode 100644
index 0000000000000000000000000000000000000000..5a0c6117804f5fa7ddc719ed4d70c2cf5922731d
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -0,0 +1,426 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Haddock.Backends.Hyperlinker.Parser (parse) where
+
+import Control.Applicative (Alternative (..))
+import Control.Monad.Trans.Class
+import Control.Monad.Trans.Maybe
+import Data.List (isPrefixOf, isSuffixOf)
+
+import qualified Data.ByteString as BS
+
+import GHC.Data.Bag (bagToList)
+import GHC.Data.FastString (mkFastString)
+import GHC.Data.StringBuffer (StringBuffer, atEnd)
+import GHC.Driver.Config.Diagnostic
+import GHC.Driver.Ppr (showSDoc)
+import GHC.Driver.Session
+import GHC.Parser.Errors.Ppr ()
+import GHC.Parser.Lexer as Lexer
+  ( P (..)
+  , PState (..)
+  , ParseResult (..)
+  , Token (..)
+  , getPsErrorMessages
+  , initParserState
+  , lexer
+  , mkParserOpts
+  )
+import GHC.Platform
+import qualified GHC.Types.Error as E
+import GHC.Types.SourceText
+import GHC.Types.SrcLoc
+import GHC.Utils.Error (pprLocMsgEnvelopeDefault)
+import GHC.Utils.Outputable (text, ($$))
+import GHC.Utils.Panic (panic)
+
+import Haddock.Backends.Hyperlinker.Types as T
+import Haddock.GhcUtils
+
+-- | Turn source code string into a stream of more descriptive tokens.
+--
+-- Result should retain original file layout (including comments,
+-- whitespace, and CPP).
+parse
+  :: DynFlags
+  -- ^ Flags for this module
+  -> FilePath
+  -- ^ Path to the source of this module
+  -> BS.ByteString
+  -- ^ Raw UTF-8 encoded source of this module
+  -> [T.Token]
+parse dflags fpath bs = case unP (go False []) initState of
+  POk _ toks -> reverse toks
+  PFailed pst ->
+    let err : _ = bagToList (E.getMessages $ getPsErrorMessages pst)
+     in panic $
+          showSDoc dflags $
+            text "Hyperlinker parse error:" $$ pprLocMsgEnvelopeDefault err
+  where
+    initState = initParserState pflags buf start
+    buf = stringBufferFromByteString bs
+    start = mkRealSrcLoc (mkFastString fpath) 1 1
+    arch_os = platformArchOS (targetPlatform dflags)
+    pflags =
+      mkParserOpts
+        (extensionFlags dflags)
+        (initDiagOpts dflags)
+        (supportedLanguagesAndExtensions arch_os)
+        (safeImportsOn dflags)
+        False -- lex Haddocks as comment tokens
+        True -- produce comment tokens
+        False -- produce position pragmas tokens
+    go
+      :: Bool
+      -- \^ are we currently in a pragma?
+      -> [T.Token]
+      -- \^ tokens accumulated so far (in reverse)
+      -> P [T.Token]
+    go inPrag toks = do
+      (b, _) <- getInput
+      if not (atEnd b)
+        then do
+          mtok <- runMaybeT (parseCppLine <|> parsePlainTok inPrag)
+          (newToks, inPrag') <- case mtok of
+            Nothing -> unknownLine
+            Just a -> pure a
+          go inPrag' (newToks ++ toks)
+        else pure toks
+
+    -- \| Like 'Lexer.lexer', but slower, with a better API, and filtering out empty tokens
+    wrappedLexer :: P (RealLocated Lexer.Token)
+    wrappedLexer = Lexer.lexer False andThen
+      where
+        andThen (L (RealSrcSpan s _) t)
+          | srcSpanStartLine s /= srcSpanEndLine s
+              || srcSpanStartCol s /= srcSpanEndCol s =
+              pure (L s t)
+        andThen (L (RealSrcSpan s _) ITeof) = pure (L s ITeof)
+        andThen _ = wrappedLexer
+
+    -- \| Try to parse a CPP line (can fail)
+    parseCppLine :: MaybeT P ([T.Token], Bool)
+    parseCppLine = MaybeT $ do
+      (b, l) <- getInput
+      case tryCppLine l b of
+        Just (cppBStr, l', b') ->
+          let cppTok =
+                T.Token
+                  { tkType = TkCpp
+                  , tkValue = cppBStr
+                  , tkSpan = mkRealSrcSpan l l'
+                  }
+           in setInput (b', l') *> pure (Just ([cppTok], False))
+        _ -> return Nothing
+
+    -- \| Try to parse a regular old token (can fail)
+    parsePlainTok :: Bool -> MaybeT P ([T.Token], Bool) -- return list is only ever 0-2 elements
+    parsePlainTok inPrag = do
+      (bInit, lInit) <- lift getInput
+      L sp tok <- tryP (Lexer.lexer False return)
+      (bEnd, _) <- lift getInput
+      case sp of
+        UnhelpfulSpan _ -> pure ([], False) -- pretend the token never existed
+        RealSrcSpan rsp _ -> do
+          let typ = if inPrag then TkPragma else classify tok
+              RealSrcLoc lStart _ = srcSpanStart sp -- safe since @sp@ is real
+              (spaceBStr, bStart) = spanPosition lInit lStart bInit
+              inPragDef = inPragma inPrag tok
+
+          (bEnd', inPrag') <- case tok of
+            -- Update internal line + file position if this is a LINE pragma
+            ITline_prag _ -> tryOrElse (bEnd, inPragDef) $ do
+              L _ (ITinteger (IL{il_value = line})) <- tryP wrappedLexer
+              L _ (ITstring _ file) <- tryP wrappedLexer
+              L spF ITclose_prag <- tryP wrappedLexer
+
+              let newLoc = mkRealSrcLoc file (fromIntegral line - 1) (srcSpanEndCol spF)
+              (bEnd'', _) <- lift getInput
+              lift $ setInput (bEnd'', newLoc)
+
+              pure (bEnd'', False)
+
+            -- Update internal column position if this is a COLUMN pragma
+            ITcolumn_prag _ -> tryOrElse (bEnd, inPragDef) $ do
+              L _ (ITinteger (IL{il_value = col})) <- tryP wrappedLexer
+              L spF ITclose_prag <- tryP wrappedLexer
+
+              let newLoc = mkRealSrcLoc (srcSpanFile spF) (srcSpanEndLine spF) (fromIntegral col)
+              (bEnd'', _) <- lift getInput
+              lift $ setInput (bEnd'', newLoc)
+
+              pure (bEnd'', False)
+            _ -> pure (bEnd, inPragDef)
+
+          let tokBStr = splitStringBuffer bStart bEnd'
+              plainTok =
+                T.Token
+                  { tkType = typ
+                  , tkValue = tokBStr
+                  , tkSpan = rsp
+                  }
+              spaceTok =
+                T.Token
+                  { tkType = TkSpace
+                  , tkValue = spaceBStr
+                  , tkSpan = mkRealSrcSpan lInit lStart
+                  }
+
+          pure (plainTok : [spaceTok | not (BS.null spaceBStr)], inPrag')
+
+    -- \| Parse whatever remains of the line as an unknown token (can't fail)
+    unknownLine :: P ([T.Token], Bool)
+    unknownLine = do
+      (b, l) <- getInput
+      let (unkBStr, l', b') = spanLine l b
+          unkTok =
+            T.Token
+              { tkType = TkUnknown
+              , tkValue = unkBStr
+              , tkSpan = mkRealSrcSpan l l'
+              }
+      setInput (b', l')
+      pure ([unkTok], False)
+
+-- | Get the input
+getInput :: P (StringBuffer, RealSrcLoc)
+getInput = P $ \p@PState{buffer = buf, loc = srcLoc} -> POk p (buf, psRealLoc srcLoc)
+
+-- | Set the input
+setInput :: (StringBuffer, RealSrcLoc) -> P ()
+setInput (buf, srcLoc) =
+  P $ \p@PState{loc = PsLoc _ buf_loc} ->
+    POk (p{buffer = buf, loc = PsLoc srcLoc buf_loc}) ()
+
+tryP :: P a -> MaybeT P a
+tryP (P f) = MaybeT $ P $ \s -> case f s of
+  POk s' a -> POk s' (Just a)
+  PFailed _ -> POk s Nothing
+
+tryOrElse :: Alternative f => a -> f a -> f a
+tryOrElse x p = p <|> pure x
+
+-- | Classify given tokens as appropriate Haskell token type.
+classify :: Lexer.Token -> TokenType
+classify tok =
+  case tok of
+    ITas -> TkKeyword
+    ITcase -> TkKeyword
+    ITclass -> TkKeyword
+    ITdata -> TkKeyword
+    ITdefault -> TkKeyword
+    ITderiving -> TkKeyword
+    ITdo{} -> TkKeyword
+    ITelse -> TkKeyword
+    IThiding -> TkKeyword
+    ITforeign -> TkKeyword
+    ITif -> TkKeyword
+    ITimport -> TkKeyword
+    ITin -> TkKeyword
+    ITinfix -> TkKeyword
+    ITinfixl -> TkKeyword
+    ITinfixr -> TkKeyword
+    ITinstance -> TkKeyword
+    ITlet -> TkKeyword
+    ITmodule -> TkKeyword
+    ITnewtype -> TkKeyword
+    ITof -> TkKeyword
+    ITqualified -> TkKeyword
+    ITthen -> TkKeyword
+    ITtype -> TkKeyword
+    ITvia -> TkKeyword
+    ITwhere -> TkKeyword
+    ITforall{} -> TkKeyword
+    ITexport -> TkKeyword
+    ITlabel -> TkKeyword
+    ITdynamic -> TkKeyword
+    ITsafe -> TkKeyword
+    ITinterruptible -> TkKeyword
+    ITunsafe -> TkKeyword
+    ITstdcallconv -> TkKeyword
+    ITccallconv -> TkKeyword
+    ITcapiconv -> TkKeyword
+    ITprimcallconv -> TkKeyword
+    ITjavascriptcallconv -> TkKeyword
+    ITmdo{} -> TkKeyword
+    ITfamily -> TkKeyword
+    ITrole -> TkKeyword
+    ITgroup -> TkKeyword
+    ITby -> TkKeyword
+    ITusing -> TkKeyword
+    ITpattern -> TkKeyword
+    ITstatic -> TkKeyword
+    ITstock -> TkKeyword
+    ITanyclass -> TkKeyword
+    ITunit -> TkKeyword
+    ITsignature -> TkKeyword
+    ITdependency -> TkKeyword
+    ITrequires -> TkKeyword
+    ITinline_prag{} -> TkPragma
+    ITopaque_prag{} -> TkPragma
+    ITspec_prag{} -> TkPragma
+    ITspec_inline_prag{} -> TkPragma
+    ITsource_prag{} -> TkPragma
+    ITrules_prag{} -> TkPragma
+    ITwarning_prag{} -> TkPragma
+    ITdeprecated_prag{} -> TkPragma
+    ITline_prag{} -> TkPragma
+    ITcolumn_prag{} -> TkPragma
+    ITscc_prag{} -> TkPragma
+    ITunpack_prag{} -> TkPragma
+    ITnounpack_prag{} -> TkPragma
+    ITann_prag{} -> TkPragma
+    ITcomplete_prag{} -> TkPragma
+    ITclose_prag -> TkPragma
+    IToptions_prag{} -> TkPragma
+    ITinclude_prag{} -> TkPragma
+    ITlanguage_prag -> TkPragma
+    ITminimal_prag{} -> TkPragma
+    IToverlappable_prag{} -> TkPragma
+    IToverlapping_prag{} -> TkPragma
+    IToverlaps_prag{} -> TkPragma
+    ITincoherent_prag{} -> TkPragma
+    ITctype{} -> TkPragma
+    ITdotdot -> TkGlyph
+    ITcolon -> TkGlyph
+    ITdcolon{} -> TkGlyph
+    ITequal -> TkGlyph
+    ITlam -> TkGlyph
+    ITlcase -> TkGlyph
+    ITlcases -> TkGlyph
+    ITvbar -> TkGlyph
+    ITlarrow{} -> TkGlyph
+    ITrarrow{} -> TkGlyph
+    ITlolly{} -> TkGlyph
+    ITat -> TkGlyph
+    ITtilde -> TkGlyph
+    ITdarrow{} -> TkGlyph
+    ITminus -> TkGlyph
+    ITprefixminus -> TkGlyph
+    ITbang -> TkGlyph
+    ITdot -> TkOperator
+    ITproj{} -> TkOperator
+    ITstar{} -> TkOperator
+    ITtypeApp -> TkGlyph
+    ITpercent -> TkGlyph
+    ITbiglam -> TkGlyph
+    ITocurly -> TkSpecial
+    ITccurly -> TkSpecial
+    ITvocurly -> TkSpecial
+    ITvccurly -> TkSpecial
+    ITobrack -> TkSpecial
+    ITopabrack -> TkSpecial
+    ITcpabrack -> TkSpecial
+    ITcbrack -> TkSpecial
+    IToparen -> TkSpecial
+    ITcparen -> TkSpecial
+    IToubxparen -> TkSpecial
+    ITcubxparen -> TkSpecial
+    ITsemi -> TkSpecial
+    ITcomma -> TkSpecial
+    ITunderscore -> TkIdentifier
+    ITbackquote -> TkSpecial
+    ITsimpleQuote -> TkSpecial
+    ITvarid{} -> TkIdentifier
+    ITconid{} -> TkIdentifier
+    ITvarsym{} -> TkOperator
+    ITconsym{} -> TkOperator
+    ITqvarid{} -> TkIdentifier
+    ITqconid{} -> TkIdentifier
+    ITqvarsym{} -> TkOperator
+    ITqconsym{} -> TkOperator
+    ITdupipvarid{} -> TkUnknown
+    ITlabelvarid{} -> TkUnknown
+    ITchar{} -> TkChar
+    ITstring{} -> TkString
+    ITinteger{} -> TkNumber
+    ITrational{} -> TkNumber
+    ITprimchar{} -> TkChar
+    ITprimstring{} -> TkString
+    ITprimint{} -> TkNumber
+    ITprimword{} -> TkNumber
+    ITprimint8{} -> TkNumber
+    ITprimint16{} -> TkNumber
+    ITprimint32{} -> TkNumber
+    ITprimint64{} -> TkNumber
+    ITprimword8{} -> TkNumber
+    ITprimword16{} -> TkNumber
+    ITprimword32{} -> TkNumber
+    ITprimword64{} -> TkNumber
+    ITprimfloat{} -> TkNumber
+    ITprimdouble{} -> TkNumber
+    ITopenExpQuote{} -> TkSpecial
+    ITopenPatQuote -> TkSpecial
+    ITopenDecQuote -> TkSpecial
+    ITopenTypQuote -> TkSpecial
+    ITcloseQuote{} -> TkSpecial
+    ITopenTExpQuote{} -> TkSpecial
+    ITcloseTExpQuote -> TkSpecial
+    ITdollar -> TkSpecial
+    ITdollardollar -> TkSpecial
+    ITtyQuote -> TkSpecial
+    ITquasiQuote{} -> TkUnknown
+    ITqQuasiQuote{} -> TkUnknown
+    ITproc -> TkKeyword
+    ITrec -> TkKeyword
+    IToparenbar{} -> TkGlyph
+    ITcparenbar{} -> TkGlyph
+    ITlarrowtail{} -> TkGlyph
+    ITrarrowtail{} -> TkGlyph
+    ITLarrowtail{} -> TkGlyph
+    ITRarrowtail{} -> TkGlyph
+    ITcomment_line_prag -> TkUnknown
+    ITunknown{} -> TkUnknown
+    ITeof -> TkUnknown
+    ITlineComment{} -> TkComment
+    ITdocComment{} -> TkComment
+    ITdocOptions{} -> TkComment
+    -- The lexer considers top-level pragmas as comments (see `pragState` in
+    -- the GHC lexer for more), so we have to manually reverse this. The
+    -- following is a hammer: it smashes _all_ pragma-like block comments into
+    -- pragmas.
+    ITblockComment c _
+      | isPrefixOf "{-#" c
+      , isSuffixOf "#-}" c ->
+          TkPragma
+      | otherwise -> TkComment
+
+-- | Classify given tokens as beginning pragmas (or not).
+inPragma
+  :: Bool
+  -- ^ currently in pragma
+  -> Lexer.Token
+  -- ^ current token
+  -> Bool
+  -- ^ new information about whether we are in a pragma
+inPragma _ ITclose_prag = False
+inPragma True _ = True
+inPragma False tok =
+  case tok of
+    ITinline_prag{} -> True
+    ITopaque_prag{} -> True
+    ITspec_prag{} -> True
+    ITspec_inline_prag{} -> True
+    ITsource_prag{} -> True
+    ITrules_prag{} -> True
+    ITwarning_prag{} -> True
+    ITdeprecated_prag{} -> True
+    ITline_prag{} -> True
+    ITcolumn_prag{} -> True
+    ITscc_prag{} -> True
+    ITunpack_prag{} -> True
+    ITnounpack_prag{} -> True
+    ITann_prag{} -> True
+    ITcomplete_prag{} -> True
+    IToptions_prag{} -> True
+    ITinclude_prag{} -> True
+    ITlanguage_prag -> True
+    ITminimal_prag{} -> True
+    IToverlappable_prag{} -> True
+    IToverlapping_prag{} -> True
+    IToverlaps_prag{} -> True
+    ITincoherent_prag{} -> True
+    ITctype{} -> True
+    _ -> False
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
new file mode 100644
index 0000000000000000000000000000000000000000..64028296e7d40cd6b74bc5353fcc4df3069f0cf2
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
@@ -0,0 +1,309 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE ViewPatterns #-}
+
+module Haddock.Backends.Hyperlinker.Renderer (render) where
+
+import Haddock.Backends.Hyperlinker.Types
+import Haddock.Backends.Hyperlinker.Utils
+
+import qualified Data.ByteString as BS
+
+import GHC.Iface.Ext.Types
+import GHC.Iface.Ext.Utils (emptyNodeInfo, isEvidenceContext)
+import GHC.Types.Name (Name, getOccString, isInternalName, nameModule, nameUnique)
+import GHC.Types.SrcLoc
+import GHC.Types.Unique (getKey)
+import GHC.Unit.Module (ModuleName, moduleNameString)
+import GHC.Utils.Encoding (utf8DecodeByteString)
+
+import System.FilePath.Posix ((</>))
+
+import qualified Data.List as List
+import qualified Data.Map as Map
+import qualified Data.Set as Set
+
+import Text.XHtml (Html, HtmlAttr, (!))
+import qualified Text.XHtml as Html
+
+type StyleClass = String
+
+-- | Produce the HTML corresponding to a hyperlinked Haskell source
+render
+  :: Maybe FilePath
+  -- ^ path to the CSS file
+  -> Maybe FilePath
+  -- ^ path to the JS file
+  -> SrcMaps
+  -- ^ Paths to sources
+  -> HieAST PrintedType
+  -- ^ ASTs from @.hie@ files
+  -> [Token]
+  -- ^ tokens to render
+  -> Html
+render mcss mjs srcs ast tokens = header mcss mjs <> body srcs ast tokens
+
+body :: SrcMaps -> HieAST PrintedType -> [Token] -> Html
+body srcs ast tokens = Html.body . Html.pre $ hypsrc
+  where
+    hypsrc = renderWithAst srcs ast tokens
+
+header :: Maybe FilePath -> Maybe FilePath -> Html
+header Nothing Nothing = Html.noHtml
+header mcss mjs = Html.header $ css mcss <> js mjs
+  where
+    css Nothing = Html.noHtml
+    css (Just cssFile) =
+      Html.thelink Html.noHtml
+        ! [ Html.rel "stylesheet"
+          , Html.thetype "text/css"
+          , Html.href cssFile
+          ]
+    js Nothing = Html.noHtml
+    js (Just scriptFile) =
+      Html.script Html.noHtml
+        ! [ Html.thetype "text/javascript"
+          , Html.src scriptFile
+          ]
+
+splitTokens :: HieAST PrintedType -> [Token] -> ([Token], [Token], [Token])
+splitTokens ast toks = (before, during, after)
+  where
+    (before, rest) = span leftOf toks
+    (during, after) = span inAst rest
+    leftOf t = realSrcSpanEnd (tkSpan t) <= realSrcSpanStart nodeSp
+    inAst t = nodeSp `containsSpan` tkSpan t
+    nodeSp = nodeSpan ast
+
+-- | Turn a list of tokens into hyperlinked sources, threading in relevant link
+-- information from the 'HieAST'.
+renderWithAst :: SrcMaps -> HieAST PrintedType -> [Token] -> Html
+renderWithAst srcs Node{..} toks = anchored $ case toks of
+  [tok] | nodeSpan == tkSpan tok -> richToken srcs nodeInfo tok
+  -- NB: the GHC lexer lexes backquoted identifiers and parenthesized operators
+  -- as multiple tokens.
+  --
+  --  * @a `elem` b@ turns into @[a, `, elem, `, b]@ (excluding space tokens)
+  --  * @(+) 1 2@    turns into @[(, +, ), 1, 2]@    (excluding space tokens)
+  --
+  -- However, the HIE ast considers @`elem`@ and @(+)@ to be single nodes. In
+  -- order to make sure these get hyperlinked properly, we intercept these
+  -- special sequences of tokens and merge them into just one identifier or
+  -- operator token.
+  [BacktickTok s1, tok@Token{tkType = TkIdentifier}, BacktickTok s2]
+    | realSrcSpanStart s1 == realSrcSpanStart nodeSpan
+    , realSrcSpanEnd s2 == realSrcSpanEnd nodeSpan ->
+        richToken
+          srcs
+          nodeInfo
+          ( Token
+              { tkValue = "`" <> tkValue tok <> "`"
+              , tkType = TkOperator
+              , tkSpan = nodeSpan
+              }
+          )
+  [OpenParenTok s1, tok@Token{tkType = TkOperator}, CloseParenTok s2]
+    | realSrcSpanStart s1 == realSrcSpanStart nodeSpan
+    , realSrcSpanEnd s2 == realSrcSpanEnd nodeSpan ->
+        richToken
+          srcs
+          nodeInfo
+          ( Token
+              { tkValue = "(" <> tkValue tok <> ")"
+              , tkType = TkOperator
+              , tkSpan = nodeSpan
+              }
+          )
+  _ -> go nodeChildren toks
+  where
+    nodeInfo = maybe emptyNodeInfo id (Map.lookup SourceInfo $ getSourcedNodeInfo sourcedNodeInfo)
+    go _ [] = mempty
+    go [] xs = foldMap renderToken xs
+    go (cur : rest) xs =
+      foldMap renderToken before <> renderWithAst srcs cur during <> go rest after
+      where
+        (before, during, after) = splitTokens cur xs
+    anchored c = Map.foldrWithKey anchorOne c (nodeIdentifiers nodeInfo)
+    anchorOne n dets c = externalAnchor n d $ internalAnchor n d c
+      where
+        d = identInfo dets
+
+renderToken :: Token -> Html
+renderToken Token{..}
+  | BS.null tkValue = mempty
+  | tkType == TkSpace = renderSpace (srcSpanStartLine tkSpan) tkValue'
+  | otherwise = tokenSpan ! [multiclass style]
+  where
+    tkValue' = filterCRLF $ utf8DecodeByteString tkValue
+    style = tokenStyle tkType
+    tokenSpan = Html.thespan (Html.toHtml tkValue')
+
+-- | Given information about the source position of definitions, render a token
+richToken :: SrcMaps -> NodeInfo PrintedType -> Token -> Html
+richToken srcs details Token{..}
+  | tkType == TkSpace = renderSpace (srcSpanStartLine tkSpan) tkValue'
+  | otherwise = annotate details $ linked content
+  where
+    tkValue' = filterCRLF $ utf8DecodeByteString tkValue
+    content = tokenSpan ! [multiclass style]
+    tokenSpan = Html.thespan (Html.toHtml tkValue')
+    style = tokenStyle tkType ++ concatMap (richTokenStyle (null (nodeType details))) contexts
+
+    contexts = concatMap (Set.elems . identInfo) . Map.elems . nodeIdentifiers $ details
+
+    -- pick an arbitrary non-evidence identifier to hyperlink with
+    identDet = Map.lookupMin $ Map.filter notEvidence $ nodeIdentifiers details
+    notEvidence = not . any isEvidenceContext . identInfo
+
+    -- If we have name information, we can make links
+    linked = case identDet of
+      Just (n, _) -> hyperlink srcs n
+      Nothing -> id
+
+-- | Remove CRLFs from source
+filterCRLF :: String -> String
+filterCRLF ('\r' : '\n' : cs) = '\n' : filterCRLF cs
+filterCRLF (c : cs) = c : filterCRLF cs
+filterCRLF [] = []
+
+annotate :: NodeInfo PrintedType -> Html -> Html
+annotate ni content =
+  Html.thespan (annot <> content) ! [Html.theclass "annot"]
+  where
+    annot
+      | not (null annotation) =
+          Html.thespan (Html.toHtml annotation) ! [Html.theclass "annottext"]
+      | otherwise = mempty
+    annotation = typ ++ identTyps
+    typ = unlines (nodeType ni)
+    typedIdents =
+      [ (n, t) | (n, c@(identType -> Just t)) <- Map.toList $ nodeIdentifiers ni, not (any isEvidenceContext $ identInfo c)
+      ]
+    identTyps
+      | length typedIdents > 1 || null (nodeType ni) =
+          concatMap (\(n, t) -> printName n ++ " :: " ++ t ++ "\n") typedIdents
+      | otherwise = ""
+
+    printName :: Either ModuleName Name -> String
+    printName = either moduleNameString getOccString
+
+richTokenStyle
+  :: Bool
+  -- ^ are we lacking a type annotation?
+  -> ContextInfo
+  -- ^ in what context did this token show up?
+  -> [StyleClass]
+richTokenStyle True Use = ["hs-type"]
+richTokenStyle False Use = ["hs-var"]
+richTokenStyle _ RecField{} = ["hs-var"]
+richTokenStyle _ PatternBind{} = ["hs-var"]
+richTokenStyle _ MatchBind{} = ["hs-var"]
+richTokenStyle _ TyVarBind{} = ["hs-type"]
+richTokenStyle _ ValBind{} = ["hs-var"]
+richTokenStyle _ TyDecl = ["hs-type"]
+richTokenStyle _ ClassTyDecl{} = ["hs-type"]
+richTokenStyle _ Decl{} = ["hs-var"]
+richTokenStyle _ IEThing{} = [] -- could be either a value or type
+richTokenStyle _ EvidenceVarBind{} = []
+richTokenStyle _ EvidenceVarUse{} = []
+
+tokenStyle :: TokenType -> [StyleClass]
+tokenStyle TkIdentifier = ["hs-identifier"]
+tokenStyle TkKeyword = ["hs-keyword"]
+tokenStyle TkString = ["hs-string"]
+tokenStyle TkChar = ["hs-char"]
+tokenStyle TkNumber = ["hs-number"]
+tokenStyle TkOperator = ["hs-operator"]
+tokenStyle TkGlyph = ["hs-glyph"]
+tokenStyle TkSpecial = ["hs-special"]
+tokenStyle TkSpace = []
+tokenStyle TkComment = ["hs-comment"]
+tokenStyle TkCpp = ["hs-cpp"]
+tokenStyle TkPragma = ["hs-pragma"]
+tokenStyle TkUnknown = []
+
+multiclass :: [StyleClass] -> HtmlAttr
+multiclass = Html.theclass . unwords
+
+externalAnchor :: Identifier -> Set.Set ContextInfo -> Html -> Html
+externalAnchor (Right name) contexts content
+  | not (isInternalName name)
+  , any isBinding contexts =
+      Html.thespan content ! [Html.identifier $ externalAnchorIdent name]
+externalAnchor _ _ content = content
+
+isBinding :: ContextInfo -> Bool
+isBinding (ValBind RegularBind _ _) = True
+isBinding PatternBind{} = True
+isBinding Decl{} = True
+isBinding (RecField RecFieldDecl _) = True
+isBinding TyVarBind{} = True
+isBinding ClassTyDecl{} = True
+isBinding _ = False
+
+internalAnchor :: Identifier -> Set.Set ContextInfo -> Html -> Html
+internalAnchor (Right name) contexts content
+  | isInternalName name
+  , any isBinding contexts =
+      Html.thespan content ! [Html.identifier $ internalAnchorIdent name]
+internalAnchor _ _ content = content
+
+externalAnchorIdent :: Name -> String
+externalAnchorIdent = hypSrcNameUrl
+
+internalAnchorIdent :: Name -> String
+internalAnchorIdent = ("local-" ++) . show . getKey . nameUnique
+
+-- | Generate the HTML hyperlink for an identifier
+hyperlink :: SrcMaps -> Identifier -> Html -> Html
+hyperlink (srcs, srcs') ident = case ident of
+  Right name
+    | isInternalName name -> internalHyperlink name
+    | otherwise -> externalNameHyperlink name
+  Left name -> externalModHyperlink name
+  where
+    -- In a Nix environment, we have file:// URLs with absolute paths
+    makeHyperlinkUrl url | List.isPrefixOf "file://" url = url
+    makeHyperlinkUrl url = ".." </> url
+
+    internalHyperlink name content =
+      Html.anchor content ! [Html.href $ "#" ++ internalAnchorIdent name]
+
+    externalNameHyperlink name content = case Map.lookup mdl srcs of
+      Just SrcLocal ->
+        Html.anchor content
+          ! [Html.href $ hypSrcModuleNameUrl mdl name]
+      Just (SrcExternal path) ->
+        let hyperlinkUrl = makeHyperlinkUrl path </> hypSrcModuleNameUrl mdl name
+         in Html.anchor content
+              ! [Html.href $ spliceURL (Just mdl) (Just name) Nothing hyperlinkUrl]
+      Nothing -> content
+      where
+        mdl = nameModule name
+
+    externalModHyperlink moduleName content =
+      case Map.lookup moduleName srcs' of
+        Just SrcLocal ->
+          Html.anchor content
+            ! [Html.href $ hypSrcModuleUrl' moduleName]
+        Just (SrcExternal path) ->
+          let hyperlinkUrl = makeHyperlinkUrl path </> hypSrcModuleUrl' moduleName
+           in Html.anchor content
+                ! [Html.href $ spliceURL' (Just moduleName) Nothing Nothing hyperlinkUrl]
+        Nothing -> content
+
+renderSpace :: Int -> String -> Html
+renderSpace !_ "" = Html.noHtml
+renderSpace !line ('\n' : rest) =
+  mconcat
+    [ Html.thespan (Html.toHtml '\n')
+    , lineAnchor (line + 1)
+    , renderSpace (line + 1) rest
+    ]
+renderSpace line space =
+  let (hspace, rest) = span (/= '\n') space
+   in (Html.thespan . Html.toHtml) hspace <> renderSpace line rest
+
+lineAnchor :: Int -> Html
+lineAnchor line = Html.thespan Html.noHtml ! [Html.identifier $ hypSrcLineUrl line]
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Types.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Types.hs
new file mode 100644
index 0000000000000000000000000000000000000000..2ed49f9b60d0c15cfe7a60b34c1e5ab0fb65627f
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Types.hs
@@ -0,0 +1,53 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE PatternSynonyms #-}
+
+module Haddock.Backends.Hyperlinker.Types where
+
+import qualified GHC
+
+import Data.ByteString (ByteString)
+
+import Data.Map (Map)
+
+data Token = Token
+  { tkType :: TokenType
+  , tkValue :: ByteString
+  -- ^ UTF-8 encoded
+  , tkSpan :: {-# UNPACK #-} !Span
+  }
+  deriving (Show)
+
+pattern BacktickTok, OpenParenTok, CloseParenTok :: Span -> Token
+pattern BacktickTok sp = Token TkSpecial "`" sp
+pattern OpenParenTok sp = Token TkSpecial "(" sp
+pattern CloseParenTok sp = Token TkSpecial ")" sp
+
+type Position = GHC.RealSrcLoc
+type Span = GHC.RealSrcSpan
+
+data TokenType
+  = TkIdentifier
+  | TkKeyword
+  | TkString
+  | TkChar
+  | TkNumber
+  | TkOperator
+  | TkGlyph
+  | TkSpecial
+  | TkSpace
+  | TkComment
+  | TkCpp
+  | TkPragma
+  | TkUnknown
+  deriving (Show, Eq)
+
+-- | Path for making cross-package hyperlinks in generated sources.
+--
+-- Used in 'SrcMap' to determine whether module originates in current package
+-- or in an external package.
+data SrcPath
+  = SrcExternal FilePath
+  | SrcLocal
+
+-- | Mapping from modules to cross-package source paths.
+type SrcMaps = (Map GHC.Module SrcPath, Map GHC.ModuleName SrcPath)
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs
new file mode 100644
index 0000000000000000000000000000000000000000..0274cd0a3800114ba656b80e51c756b0d27f9bac
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs
@@ -0,0 +1,156 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Haddock.Backends.Hyperlinker.Utils
+  ( hypSrcDir
+  , hypSrcModuleFile
+  , hypSrcModuleFile'
+  , hypSrcModuleUrl
+  , hypSrcModuleUrl'
+  , hypSrcNameUrl
+  , hypSrcLineUrl
+  , hypSrcModuleNameUrl
+  , hypSrcModuleLineUrl
+  , hypSrcModuleUrlFormat
+  , hypSrcModuleNameUrlFormat
+  , hypSrcModuleLineUrlFormat
+  , spliceURL
+  , spliceURL'
+
+    -- * HIE file processing
+  , PrintedType
+  , recoverFullIfaceTypes
+  ) where
+
+import Haddock.Backends.Xhtml.Utils
+import Haddock.Utils
+
+import GHC
+import GHC.Driver.Ppr (showSDoc)
+import GHC.Iface.Ext.Types (HieAST (..), HieArgs (..), HieType (..), HieTypeFlat, TypeIndex)
+import GHC.Iface.Type
+import GHC.Types.Name (getOccFS, getOccString)
+import GHC.Types.Var (TypeOrConstraint (..), VarBndr (..), invisArg, visArg)
+
+import System.FilePath.Posix ((<.>), (</>))
+
+import qualified Data.Array as A
+
+{-# INLINE hypSrcDir #-}
+hypSrcDir :: FilePath
+hypSrcDir = "src"
+
+{-# INLINE hypSrcModuleFile #-}
+hypSrcModuleFile :: Module -> FilePath
+hypSrcModuleFile m = moduleNameString (moduleName m) <.> "html"
+
+hypSrcModuleFile' :: ModuleName -> FilePath
+hypSrcModuleFile' mdl =
+  spliceURL'
+    (Just mdl)
+    Nothing
+    Nothing
+    moduleFormat
+
+hypSrcModuleUrl :: Module -> String
+hypSrcModuleUrl = hypSrcModuleFile
+
+hypSrcModuleUrl' :: ModuleName -> String
+hypSrcModuleUrl' = hypSrcModuleFile'
+
+{-# INLINE hypSrcNameUrl #-}
+hypSrcNameUrl :: Name -> String
+hypSrcNameUrl = escapeStr . getOccString
+
+{-# INLINE hypSrcLineUrl #-}
+hypSrcLineUrl :: Int -> String
+hypSrcLineUrl line = "line-" ++ show line
+
+{-# INLINE hypSrcModuleNameUrl #-}
+hypSrcModuleNameUrl :: Module -> Name -> String
+hypSrcModuleNameUrl mdl name = hypSrcModuleUrl mdl ++ "#" ++ hypSrcNameUrl name
+
+{-# INLINE hypSrcModuleLineUrl #-}
+hypSrcModuleLineUrl :: Module -> Int -> String
+hypSrcModuleLineUrl mdl line = hypSrcModuleUrl mdl ++ "#" ++ hypSrcLineUrl line
+
+hypSrcModuleUrlFormat :: String
+hypSrcModuleUrlFormat = hypSrcDir </> moduleFormat
+
+hypSrcModuleNameUrlFormat :: String
+hypSrcModuleNameUrlFormat = hypSrcModuleUrlFormat ++ "#" ++ nameFormat
+
+hypSrcModuleLineUrlFormat :: String
+hypSrcModuleLineUrlFormat = hypSrcModuleUrlFormat ++ "#" ++ lineFormat
+
+moduleFormat :: String
+moduleFormat = "%{MODULE}.html"
+
+nameFormat :: String
+nameFormat = "%{NAME}"
+
+lineFormat :: String
+lineFormat = "line-%{LINE}"
+
+-- * HIE file processing
+
+-- This belongs in GHC.Iface.Ext.Utils...
+
+-- | Pretty-printed type, ready to be turned into HTML by @xhtml@
+type PrintedType = String
+
+-- | Expand the flattened HIE AST into one where the types printed out and
+-- ready for end-users to look at.
+--
+-- Using just primitives found in GHC's HIE utilities, we could write this as
+-- follows:
+--
+-- > 'recoverFullIfaceTypes' dflags hieTypes hieAst
+-- >     = 'fmap' (\ti -> 'showSDoc' df .
+-- >                      'pprIfaceType' $
+-- >                      'recoverFullType' ti hieTypes)
+-- >       hieAst
+--
+-- However, this is very inefficient (both in time and space) because the
+-- multiple calls to 'recoverFullType' don't share intermediate results. This
+-- function fixes that.
+recoverFullIfaceTypes
+  :: DynFlags
+  -> A.Array TypeIndex HieTypeFlat
+  -- ^ flat types
+  -> HieAST TypeIndex
+  -- ^ flattened AST
+  -> HieAST PrintedType
+  -- ^ full AST
+recoverFullIfaceTypes df flattened ast = fmap (printed A.!) ast
+  where
+    -- Splitting this out into its own array is also important: we don't want
+    -- to pretty print the same type many times
+    printed :: A.Array TypeIndex PrintedType
+    printed = fmap (showSDoc df . pprIfaceType) unflattened
+
+    -- The recursion in 'unflattened' is crucial - it's what gives us sharing
+    -- between the IfaceType's produced
+    unflattened :: A.Array TypeIndex IfaceType
+    unflattened = fmap (\flatTy -> go (fmap (unflattened A.!) flatTy)) flattened
+
+    -- Unfold an 'HieType' whose subterms have already been unfolded
+    go :: HieType IfaceType -> IfaceType
+    go (HTyVarTy n) = IfaceTyVar (mkIfLclName $ getOccFS n)
+    go (HAppTy a b) = IfaceAppTy a (hieToIfaceArgs b)
+    go (HLitTy l) = IfaceLitTy l
+    go (HForAllTy ((n, k), af) t) =
+      let b = (mkIfLclName $ getOccFS n, k)
+       in IfaceForAllTy (Bndr (IfaceTvBndr b) af) t
+    go (HFunTy w a b) = IfaceFunTy (visArg TypeLike) w a b -- t1 -> t2
+    go (HQualTy con b) = IfaceFunTy (invisArg TypeLike) many_ty con b -- c => t
+    go (HCastTy a) = a
+    go HCoercionTy = IfaceTyVar $ mkIfLclName "<coercion type>"
+    go (HTyConApp a xs) = IfaceTyConApp a (hieToIfaceArgs xs)
+
+    -- This isn't fully faithful - we can't produce the 'Inferred' case
+    hieToIfaceArgs :: HieArgs IfaceType -> IfaceAppArgs
+    hieToIfaceArgs (HieArgs args) = go' args
+      where
+        go' [] = IA_Nil
+        go' ((True, x) : xs) = IA_Arg x Required $ go' xs
+        go' ((False, x) : xs) = IA_Arg x Specified $ go' xs
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs b/utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b15cec989c3071f14027330e385715d8837c51cd
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs
@@ -0,0 +1,1613 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.LaTeX
+-- Copyright   :  (c) Simon Marlow      2010,
+--                    Mateusz Kowalczyk 2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.LaTeX
+  ( ppLaTeX
+  ) where
+
+import Documentation.Haddock.Markup
+import GHC.Utils.Ppr hiding (Doc, quote)
+import qualified GHC.Utils.Ppr as Pretty
+import Haddock.Doc (combineDocumentation)
+import Haddock.GhcUtils
+import Haddock.Types
+import Haddock.Utils
+
+import GHC hiding (fromMaybeContext)
+import GHC.Core.Type (Specificity (..))
+import GHC.Data.FastString (unpackFS)
+import GHC.Types.Name (getOccString, nameOccName, tidyNameOcc)
+import GHC.Types.Name.Occurrence
+import GHC.Types.Name.Reader (rdrNameOcc)
+
+import Control.Monad
+import Data.Char
+import Data.Foldable (toList)
+import Data.List (sort)
+import Data.List.NonEmpty (NonEmpty (..))
+import qualified Data.Map as Map
+import Data.Maybe
+import System.Directory
+import System.FilePath
+import Prelude hiding ((<>))
+
+{- SAMPLE OUTPUT
+
+\haddockmoduleheading{\texttt{Data.List}}
+\hrulefill
+{\haddockverb\begin{verbatim}
+module Data.List (
+    (++),  head,  last,  tail,  init,  null,  length,  map,  reverse,
+  ) where\end{verbatim}}
+\hrulefill
+
+\section{Basic functions}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+head\ ::\ {\char 91}a{\char 93}\ ->\ a
+\end{tabular}]\haddockbegindoc
+Extract the first element of a list, which must be non-empty.
+\par
+
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+last\ ::\ {\char 91}a{\char 93}\ ->\ a
+\end{tabular}]\haddockbegindoc
+Extract the last element of a list, which must be finite and non-empty.
+\par
+
+\end{haddockdesc}
+-}
+
+{- TODO
+ * don't forget fixity!!
+-}
+
+ppLaTeX
+  :: String -- Title
+  -> Maybe String -- Package name
+  -> [Interface]
+  -> FilePath -- destination directory
+  -> Maybe (Doc GHC.RdrName) -- prologue text, maybe
+  -> Maybe String -- style file
+  -> FilePath
+  -> IO ()
+ppLaTeX title packageStr visible_ifaces odir prologue maybe_style libdir =
+  do
+    createDirectoryIfMissing True odir
+    when (isNothing maybe_style) $
+      copyFile (libdir </> "latex" </> haddockSty) (odir </> haddockSty)
+    ppLaTeXTop title packageStr odir prologue maybe_style visible_ifaces
+    mapM_ (ppLaTeXModule title odir) visible_ifaces
+
+haddockSty :: FilePath
+haddockSty = "haddock.sty"
+
+type LaTeX = Pretty.Doc
+
+-- | Default way of rendering a 'LaTeX'. The width is 90 by default (since 100
+-- often overflows the line).
+latex2String :: LaTeX -> String
+latex2String = fullRender (PageMode True) 90 1 txtPrinter ""
+
+ppLaTeXTop
+  :: String
+  -> Maybe String
+  -> FilePath
+  -> Maybe (Doc GHC.RdrName)
+  -> Maybe String
+  -> [Interface]
+  -> IO ()
+ppLaTeXTop doctitle packageStr odir prologue maybe_style ifaces = do
+  let tex =
+        vcat
+          [ text "\\documentclass{book}"
+          , text "\\usepackage" <> braces (maybe (text "haddock") text maybe_style)
+          , text "\\begin{document}"
+          , text "\\begin{titlepage}"
+          , text "\\begin{haddocktitle}"
+          , text doctitle
+          , text "\\end{haddocktitle}"
+          , case prologue of
+              Nothing -> empty
+              Just d ->
+                vcat
+                  [ text "\\begin{haddockprologue}"
+                  , rdrDocToLaTeX d
+                  , text "\\end{haddockprologue}"
+                  ]
+          , text "\\end{titlepage}"
+          , text "\\tableofcontents"
+          , vcat [text "\\input" <> braces (text mdl) | mdl <- mods]
+          , text "\\end{document}"
+          ]
+
+      mods = sort (map (moduleBasename . ifaceMod) ifaces)
+
+      filename = odir </> (fromMaybe "haddock" packageStr <.> "tex")
+
+  writeUtf8File filename (show tex)
+
+ppLaTeXModule :: String -> FilePath -> Interface -> IO ()
+ppLaTeXModule _title odir iface = do
+  createDirectoryIfMissing True odir
+  let
+    mdl = ifaceMod iface
+    mdl_str = moduleString mdl
+
+    exports = ifaceRnExportItems iface
+
+    tex =
+      vcat
+        [ text "\\haddockmoduleheading" <> braces (text mdl_str)
+        , text "\\label{module:" <> text mdl_str <> char '}'
+        , text "\\haddockbeginheader"
+        , verb $
+            vcat
+              [ text "module" <+> text mdl_str <+> lparen
+              , text "    "
+                  <> fsep
+                    ( punctuate (char ',') $
+                        map exportListItem $
+                          filter forSummary exports
+                    )
+              , text "  ) where"
+              ]
+        , text "\\haddockendheader" $$ text ""
+        , description
+        , body
+        ]
+
+    description =
+      (fromMaybe empty . documentationToLaTeX . ifaceRnDoc) iface
+
+    body = processExports exports
+  --
+  writeUtf8File (odir </> moduleLaTeXFile mdl) (fullRender (PageMode True) 80 1 txtPrinter "" tex)
+
+-- | Prints out an entry in a module export list.
+exportListItem :: ExportItem DocNameI -> LaTeX
+exportListItem
+  ( ExportDecl
+      ( RnExportD
+          { rnExpDExpD =
+            ( ExportD
+                { expDDecl = decl
+                , expDSubDocs = subdocs
+                }
+              )
+          }
+        )
+    ) =
+    let (leader, names) = declNames decl
+        go (n, _)
+          | isDefaultMethodOcc (occName n) = Nothing
+          | otherwise = Just $ ppDocBinder n
+     in sep (punctuate comma [leader <+> ppDocBinder name | name <- names])
+          <> case subdocs of
+            [] -> empty
+            _ -> parens (sep (punctuate comma (mapMaybe go subdocs)))
+exportListItem (ExportNoDecl y []) =
+  ppDocBinder y
+exportListItem (ExportNoDecl y subs) =
+  ppDocBinder y <> parens (sep (punctuate comma (map ppDocBinder subs)))
+exportListItem (ExportModule mdl) =
+  text "module" <+> text (moduleString mdl)
+exportListItem _ =
+  error "exportListItem"
+
+-- Deal with a group of undocumented exports together, to avoid lots
+-- of blank vertical space between them.
+processExports :: [ExportItem DocNameI] -> LaTeX
+processExports [] = empty
+processExports (decl : es)
+  | Just sig <- isSimpleSig decl =
+      multiDecl
+        [ ppTypeSig (map getName names) typ False
+        | (names, typ) <- sig : sigs
+        ]
+        $$ processExports es'
+  where
+    (sigs, es') = spanWith isSimpleSig es
+processExports (ExportModule mdl : es) =
+  declWithDoc (vcat [text "module" <+> text (moduleString m) | m <- mdl : mdls]) Nothing
+    $$ processExports es'
+  where
+    (mdls, es') = spanWith isExportModule es
+processExports (e : es) =
+  processExport e $$ processExports es
+
+isSimpleSig :: ExportItem DocNameI -> Maybe ([DocName], HsSigType DocNameI)
+isSimpleSig
+  ( ExportDecl
+      ( RnExportD
+          { rnExpDExpD =
+            ExportD
+              { expDDecl = L _ (SigD _ (TypeSig _ lnames t))
+              , expDMbDoc = (Documentation Nothing Nothing, argDocs)
+              }
+          }
+        )
+    )
+    | Map.null argDocs = Just (map unLoc lnames, unLoc (dropWildCards t))
+isSimpleSig _ = Nothing
+
+isExportModule :: ExportItem DocNameI -> Maybe Module
+isExportModule (ExportModule m) = Just m
+isExportModule _ = Nothing
+
+processExport :: ExportItem DocNameI -> LaTeX
+processExport (ExportGroup lev _id0 doc) =
+  ppDocGroup lev (docToLaTeX doc)
+processExport (ExportDecl (RnExportD (ExportD decl pats doc subdocs insts fixities _splice) _)) =
+  ppDecl decl pats doc insts subdocs fixities
+processExport (ExportNoDecl y []) =
+  ppDocName y
+processExport (ExportNoDecl y subs) =
+  ppDocName y <> parens (sep (punctuate comma (map ppDocName subs)))
+processExport (ExportModule mdl) =
+  declWithDoc (text "module" <+> text (moduleString mdl)) Nothing
+processExport (ExportDoc doc) =
+  docToLaTeX $ _doc doc
+
+ppDocGroup :: Int -> LaTeX -> LaTeX
+ppDocGroup lev doc = sec lev <> braces doc
+  where
+    sec 1 = text "\\section"
+    sec 2 = text "\\subsection"
+    sec 3 = text "\\subsubsection"
+    sec _ = text "\\paragraph"
+
+-- | Given a declaration, extract out the names being declared
+declNames
+  :: LHsDecl DocNameI
+  -> ( LaTeX --   to print before each name in an export list
+     , [DocName] --   names being declared
+     )
+declNames (L _ decl) = case decl of
+  TyClD _ d -> (empty, [tcdNameI d])
+  SigD _ (TypeSig _ lnames _) -> (empty, map unLoc lnames)
+  SigD _ (PatSynSig _ lnames _) -> (text "pattern", map unLoc lnames)
+  ForD _ (ForeignImport _ (L _ n) _ _) -> (empty, [n])
+  ForD _ (ForeignExport _ (L _ n) _ _) -> (empty, [n])
+  _ -> error "declaration not supported by declNames"
+
+forSummary :: (ExportItem DocNameI) -> Bool
+forSummary (ExportGroup _ _ _) = False
+forSummary (ExportDoc _) = False
+forSummary _ = True
+
+moduleLaTeXFile :: Module -> FilePath
+moduleLaTeXFile mdl = moduleBasename mdl ++ ".tex"
+
+moduleBasename :: Module -> FilePath
+moduleBasename mdl =
+  map
+    (\c -> if c == '.' then '-' else c)
+    (moduleNameString (moduleName mdl))
+
+-------------------------------------------------------------------------------
+
+-- * Decls
+
+-------------------------------------------------------------------------------
+
+-- | Pretty print a declaration
+ppDecl
+  :: LHsDecl DocNameI
+  -- ^ decl to print
+  -> [(HsDecl DocNameI, DocForDecl DocName)]
+  -- ^ all pattern decls
+  -> DocForDecl DocName
+  -- ^ documentation for decl
+  -> [DocInstance DocNameI]
+  -- ^ all instances
+  -> [(DocName, DocForDecl DocName)]
+  -- ^ all subdocs
+  -> [(DocName, Fixity)]
+  -- ^ all fixities
+  -> LaTeX
+ppDecl decl pats (doc, fnArgsDoc) instances subdocs _fxts = case unLoc decl of
+  TyClD _ d@FamDecl{} -> ppFamDecl False doc instances d unicode
+  TyClD _ d@DataDecl{} -> ppDataDecl pats instances subdocs (Just doc) d unicode
+  TyClD _ d@SynDecl{} -> ppTySyn (doc, fnArgsDoc) d unicode
+  TyClD _ d@ClassDecl{} -> ppClassDecl instances doc subdocs d unicode
+  SigD _ (TypeSig _ lnames ty) -> ppFunSig Nothing (doc, fnArgsDoc) (map unLoc lnames) (dropWildCards ty) unicode
+  SigD _ (PatSynSig _ lnames ty) -> ppLPatSig (doc, fnArgsDoc) (map unLoc lnames) ty unicode
+  ForD _ d -> ppFor (doc, fnArgsDoc) d unicode
+  InstD _ _ -> empty
+  DerivD _ _ -> empty
+  _ -> error "declaration not supported by ppDecl"
+  where
+    unicode = False
+
+ppFor :: DocForDecl DocName -> ForeignDecl DocNameI -> Bool -> LaTeX
+ppFor doc (ForeignImport _ (L _ name) typ _) unicode =
+  ppFunSig Nothing doc [name] typ unicode
+ppFor _ _ _ = error "ppFor error in Haddock.Backends.LaTeX"
+
+--  error "foreign declarations are currently not supported by --latex"
+
+-------------------------------------------------------------------------------
+
+-- * Type families
+
+-------------------------------------------------------------------------------
+
+-- | Pretty-print a data\/type family declaration
+ppFamDecl
+  :: Bool
+  -- ^ is the family associated?
+  -> Documentation DocName
+  -- ^ this decl's docs
+  -> [DocInstance DocNameI]
+  -- ^ relevant instances
+  -> TyClDecl DocNameI
+  -- ^ family to print
+  -> Bool
+  -- ^ unicode
+  -> LaTeX
+ppFamDecl associated doc instances decl unicode =
+  declWithDoc
+    (ppFamHeader (tcdFam decl) unicode associated <+> whereBit)
+    (if null body then Nothing else Just (vcat body))
+    $$ instancesBit
+  where
+    body = catMaybes [familyEqns, documentationToLaTeX doc]
+
+    whereBit = case fdInfo (tcdFam decl) of
+      ClosedTypeFamily _ -> keyword "where"
+      _ -> empty
+
+    familyEqns
+      | FamilyDecl{fdInfo = ClosedTypeFamily (Just eqns)} <- tcdFam decl
+      , not (null eqns) =
+          Just
+            ( text "\\haddockbeginargs"
+                $$ vcat [decltt (ppFamDeclEqn eqn) <+> nl | L _ eqn <- eqns]
+                $$ text "\\end{tabulary}\\par"
+            )
+      | otherwise = Nothing
+
+    -- Individual equations of a closed type family
+    ppFamDeclEqn :: TyFamInstEqn DocNameI -> LaTeX
+    ppFamDeclEqn
+      ( FamEqn
+          { feqn_tycon = L _ n
+          , feqn_rhs = rhs
+          , feqn_pats = ts
+          }
+        ) =
+        hsep
+          [ ppAppNameTypeArgs n ts unicode
+          , equals
+          , ppType unicode (unLoc rhs)
+          ]
+
+    instancesBit = ppDocInstances unicode instances
+
+-- | Print the LHS of a type\/data family declaration.
+ppFamHeader
+  :: FamilyDecl DocNameI
+  -- ^ family header to print
+  -> Bool
+  -- ^ unicode
+  -> Bool
+  -- ^ is the family associated?
+  -> LaTeX
+ppFamHeader
+  ( FamilyDecl
+      { fdLName = L _ name
+      , fdTyVars = tvs
+      , fdInfo = info
+      , fdResultSig = L _ result
+      , fdInjectivityAnn = injectivity
+      }
+    )
+  unicode
+  associated =
+    famly leader <+> famName <+> famSig <+> injAnn
+    where
+      leader = case info of
+        OpenTypeFamily -> keyword "type"
+        ClosedTypeFamily _ -> keyword "type"
+        DataFamily -> keyword "data"
+
+      famly
+        | associated = id
+        | otherwise = (<+> keyword "family")
+
+      famName = ppAppDocNameTyVarBndrs unicode name (hsq_explicit tvs)
+
+      famSig = case result of
+        NoSig _ -> empty
+        KindSig _ kind -> dcolon unicode <+> ppLKind unicode kind
+        TyVarSig _ (L _ bndr) -> equals <+> ppHsTyVarBndr unicode bndr
+
+      injAnn = case injectivity of
+        Nothing -> empty
+        Just (L _ (InjectivityAnn _ lhs rhs)) ->
+          hsep
+            ( decltt (text "|")
+                : ppLDocName lhs
+                : arrow unicode
+                : map ppLDocName rhs
+            )
+        Just _ -> empty
+
+-------------------------------------------------------------------------------
+
+-- * Type Synonyms
+
+-------------------------------------------------------------------------------
+
+-- we skip type patterns for now
+ppTySyn :: DocForDecl DocName -> TyClDecl DocNameI -> Bool -> LaTeX
+ppTySyn
+  doc
+  ( SynDecl
+      { tcdLName = L _ name
+      , tcdTyVars = ltyvars
+      , tcdRhs = ltype
+      }
+    )
+  unicode =
+    ppTypeOrFunSig (mkHsImplicitSigTypeI ltype) doc (full, hdr, char '=') unicode
+    where
+      hdr =
+        hsep
+          ( keyword "type"
+              : ppDocBinder name
+              : map ppSymName (tyvarNames ltyvars)
+          )
+      full = hdr <+> char '=' <+> ppLType unicode ltype
+ppTySyn _ _ _ = error "declaration not supported by ppTySyn"
+
+-------------------------------------------------------------------------------
+
+-- * Function signatures
+
+-------------------------------------------------------------------------------
+
+ppFunSig
+  :: Maybe LaTeX
+  -- ^ a prefix to put right before the signature
+  -> DocForDecl DocName
+  -- ^ documentation
+  -> [DocName]
+  -- ^ pattern names in the pattern signature
+  -> LHsSigType DocNameI
+  -- ^ type of the pattern synonym
+  -> Bool
+  -- ^ unicode
+  -> LaTeX
+ppFunSig leader doc docnames (L _ typ) unicode =
+  ppTypeOrFunSig
+    typ
+    doc
+    ( lead $ ppTypeSig names typ False
+    , lead $ hsep . punctuate comma $ map ppSymName names
+    , dcolon unicode
+    )
+    unicode
+  where
+    names = map getName docnames
+    lead = maybe id (<+>) leader
+
+-- | Pretty-print a pattern synonym
+ppLPatSig
+  :: DocForDecl DocName
+  -- ^ documentation
+  -> [DocName]
+  -- ^ pattern names in the pattern signature
+  -> LHsSigType DocNameI
+  -- ^ type of the pattern synonym
+  -> Bool
+  -- ^ unicode
+  -> LaTeX
+ppLPatSig doc docnames ty unicode =
+  ppFunSig (Just (keyword "pattern")) doc docnames ty unicode
+
+-- | Pretty-print a type, adding documentation to the whole type and its
+-- arguments as needed.
+ppTypeOrFunSig
+  :: HsSigType DocNameI
+  -> DocForDecl DocName
+  -- ^ documentation
+  -> ( LaTeX --   first-line (no-argument docs only)
+     , LaTeX --   first-line (argument docs only)
+     , LaTeX --   type prefix (argument docs only)
+     )
+  -> Bool
+  -- ^ unicode
+  -> LaTeX
+ppTypeOrFunSig typ (doc, argDocs) (pref1, pref2, sep0) unicode
+  | Map.null argDocs = declWithDoc pref1 (documentationToLaTeX doc)
+  | otherwise =
+      declWithDoc pref2 $
+        Just $
+          text "\\haddockbeginargs"
+            $$ vcat (map (uncurry (<->)) (ppSubSigLike unicode typ argDocs [] sep0))
+            $$ text "\\end{tabulary}\\par"
+            $$ fromMaybe empty (documentationToLaTeX doc)
+
+-- | This splits up a type signature along @->@ and adds docs (when they exist)
+-- to the arguments. The output is a list of (leader/seperator, argument and
+-- its doc)
+ppSubSigLike
+  :: Bool
+  -- ^ unicode
+  -> HsSigType DocNameI
+  -- ^ type signature
+  -> FnArgsDoc DocName
+  -- ^ docs to add
+  -> [(DocName, DocForDecl DocName)]
+  -- ^ all subdocs (useful when we have `HsRecTy`)
+  -> LaTeX
+  -- ^ seperator (beginning of first line)
+  -> [(LaTeX, LaTeX)]
+  -- ^ arguments (leader/sep, type)
+ppSubSigLike unicode typ argDocs subdocs leader = do_sig_args 0 leader typ
+  where
+    do_sig_args :: Int -> LaTeX -> HsSigType DocNameI -> [(LaTeX, LaTeX)]
+    do_sig_args n leader (HsSig{sig_bndrs = outer_bndrs, sig_body = ltype}) =
+      case outer_bndrs of
+        HsOuterExplicit{hso_bndrs = bndrs} ->
+          [
+            ( decltt leader
+            , decltt (ppHsForAllTelescope (mkHsForAllInvisTeleI bndrs) unicode)
+                <+> ppLType unicode ltype
+            )
+          ]
+        HsOuterImplicit{} -> do_largs n leader ltype
+
+    do_largs :: Int -> LaTeX -> LHsType DocNameI -> [(LaTeX, LaTeX)]
+    do_largs n leader (L _ t) = do_args n leader t
+
+    arg_doc n = rDoc . fmap _doc $ Map.lookup n argDocs
+
+    do_args :: Int -> LaTeX -> HsType DocNameI -> [(LaTeX, LaTeX)]
+    do_args _n leader (HsForAllTy _ tele ltype) =
+      [
+        ( decltt leader
+        , decltt (ppHsForAllTelescope tele unicode)
+            <+> ppLType unicode ltype
+        )
+      ]
+    do_args n leader (HsQualTy _ lctxt ltype) =
+      ( decltt leader
+      , decltt (ppLContextNoArrow lctxt unicode) <+> nl
+      )
+        : do_largs n (darrow unicode) ltype
+    do_args n leader (HsFunTy _ _w (L _ (HsRecTy _ fields)) r) =
+      [ (decltt ldr, latex <+> nl)
+      | (L _ field, ldr) <- zip fields (leader <+> gadtOpen : repeat gadtComma)
+      , let latex = ppSideBySideField subdocs unicode field
+      ]
+        ++ do_largs (n + 1) (gadtEnd <+> arrow unicode) r
+    do_args n leader (HsFunTy _ _w lt r) =
+      (decltt leader, decltt (ppLFunLhType unicode lt) <-> arg_doc n <+> nl)
+        : do_largs (n + 1) (arrow unicode) r
+    do_args n leader t =
+      [(decltt leader, decltt (ppType unicode t) <-> arg_doc n <+> nl)]
+
+    -- FIXME: this should be done more elegantly
+    --
+    -- We need 'gadtComma' and 'gadtEnd' to line up with the `{` from
+    -- 'gadtOpen', so we add 3 spaces to cover for `-> `/`:: ` (3 in unicode
+    -- mode since `->` and `::` are rendered as single characters.
+    gadtComma = hcat (replicate (if unicode then 3 else 4) (char ' ')) <> char ','
+    gadtEnd = hcat (replicate (if unicode then 3 else 4) (char ' ')) <> char '}'
+    gadtOpen = char '{'
+
+ppTypeSig :: [Name] -> HsSigType DocNameI -> Bool -> LaTeX
+ppTypeSig nms ty unicode =
+  hsep (punctuate comma $ map ppSymName nms)
+    <+> dcolon unicode
+    <+> ppSigType unicode ty
+
+ppHsOuterTyVarBndrs :: RenderableBndrFlag flag => HsOuterTyVarBndrs flag DocNameI -> Bool -> LaTeX
+ppHsOuterTyVarBndrs (HsOuterImplicit{}) _ = empty
+ppHsOuterTyVarBndrs (HsOuterExplicit{hso_bndrs = bndrs}) unicode =
+  hsep (forallSymbol unicode : ppTyVars unicode bndrs) <> dot
+
+ppHsForAllTelescope :: HsForAllTelescope DocNameI -> Bool -> LaTeX
+ppHsForAllTelescope tele unicode = case tele of
+  HsForAllVis{hsf_vis_bndrs = bndrs} ->
+    hsep (forallSymbol unicode : ppTyVars unicode bndrs) <> text "\\" <> arrow unicode
+  HsForAllInvis{hsf_invis_bndrs = bndrs} ->
+    hsep (forallSymbol unicode : ppTyVars unicode bndrs) <> dot
+
+ppTyVars :: RenderableBndrFlag flag => Bool -> [LHsTyVarBndr flag DocNameI] -> [LaTeX]
+ppTyVars unicode tvs = map (ppHsTyVarBndr unicode . unLoc) tvs
+
+tyvarNames :: LHsQTyVars DocNameI -> [Name]
+tyvarNames = map (getName . hsLTyVarNameI) . hsQTvExplicit
+
+declWithDoc :: LaTeX -> Maybe LaTeX -> LaTeX
+declWithDoc decl doc =
+  text "\\begin{haddockdesc}"
+    $$ text "\\item[\\begin{tabular}{@{}l}"
+    $$ text (latexMonoFilter (latex2String decl))
+    $$ text "\\end{tabular}]"
+    $$ maybe empty (\x -> text "{\\haddockbegindoc" $$ x <> text "}") doc
+    $$ text "\\end{haddockdesc}"
+
+-- in a group of decls, we don't put them all in the same tabular,
+-- because that would prevent the group being broken over a page
+-- boundary (breaks Foreign.C.Error for example).
+multiDecl :: [LaTeX] -> LaTeX
+multiDecl decls =
+  text "\\begin{haddockdesc}"
+    $$ vcat
+      [ text "\\item[\\begin{tabular}{@{}l}"
+        $$ text (latexMonoFilter (latex2String decl))
+        $$ text "\\end{tabular}]"
+      | decl <- decls
+      ]
+    $$ text "\\end{haddockdesc}"
+
+-------------------------------------------------------------------------------
+
+-- * Rendering Doc
+
+-------------------------------------------------------------------------------
+
+maybeDoc :: Maybe (Doc DocName) -> LaTeX
+maybeDoc = maybe empty docToLaTeX
+
+-- for table cells, we strip paragraphs out to avoid extra vertical space
+-- and don't add a quote environment.
+rDoc :: Maybe (Doc DocName) -> LaTeX
+rDoc = maybeDoc . fmap latexStripTrailingWhitespace
+
+-------------------------------------------------------------------------------
+
+-- * Class declarations
+
+-------------------------------------------------------------------------------
+
+ppClassHdr
+  :: Bool
+  -> Maybe (LocatedC [LHsType DocNameI])
+  -> DocName
+  -> LHsQTyVars DocNameI
+  -> [LHsFunDep DocNameI]
+  -> Bool
+  -> LaTeX
+ppClassHdr summ lctxt n tvs fds unicode =
+  keyword "class"
+    <+> (if not (null $ fromMaybeContext lctxt) then ppLContext lctxt unicode else empty)
+    <+> ppAppDocNameNames summ n (tyvarNames tvs)
+    <+> ppFds fds unicode
+
+-- ppFds :: [Located ([LocatedA DocName], [LocatedA DocName])] -> Bool -> LaTeX
+ppFds :: [LHsFunDep DocNameI] -> Bool -> LaTeX
+ppFds fds unicode =
+  if null fds
+    then empty
+    else char '|' <+> hsep (punctuate comma (map (fundep . unLoc) fds))
+  where
+    fundep (FunDep _ vars1 vars2) =
+      hsep (map (ppDocName . unLoc) vars1)
+        <+> arrow unicode
+        <+> hsep (map (ppDocName . unLoc) vars2)
+    fundep (XFunDep _) = error "ppFds"
+
+-- TODO: associated type defaults, docs on default methods
+ppClassDecl
+  :: [DocInstance DocNameI]
+  -> Documentation DocName
+  -> [(DocName, DocForDecl DocName)]
+  -> TyClDecl DocNameI
+  -> Bool
+  -> LaTeX
+ppClassDecl
+  instances
+  doc
+  subdocs
+  ( ClassDecl
+      { tcdCtxt = lctxt
+      , tcdLName = lname
+      , tcdTyVars = ltyvars
+      , tcdFDs = lfds
+      , tcdSigs = lsigs
+      , tcdATs = ats
+      , tcdATDefs = at_defs
+      }
+    )
+  unicode =
+    declWithDoc classheader (if null body then Nothing else Just (vcat body))
+      $$ instancesBit
+    where
+      classheader
+        | null lsigs = hdr unicode
+        | otherwise = hdr unicode <+> keyword "where"
+
+      hdr = ppClassHdr False lctxt (unLoc lname) ltyvars lfds
+
+      body = catMaybes [documentationToLaTeX doc, body_]
+
+      body_
+        | null lsigs, null ats, null at_defs = Nothing
+        | null ats, null at_defs = Just methodTable
+        | otherwise = Just (atTable $$ methodTable)
+
+      atTable =
+        text "\\haddockpremethods{}" <> emph (text "Associated Types")
+          $$ vcat
+            [ ppFamDecl True (fst doc) [] (FamDecl noExtField decl) True
+            | L _ decl <- ats
+            , let name = unLoc . fdLName $ decl
+                  doc = lookupAnySubdoc name subdocs
+            ]
+
+      methodTable =
+        text "\\haddockpremethods{}" <> emph (text "Methods")
+          $$ vcat
+            [ ppFunSig leader doc names typ unicode
+            | L _ (ClassOpSig _ is_def lnames typ) <- lsigs
+            , let doc
+                    | is_def = noDocForDecl
+                    | otherwise = lookupAnySubdoc (head names) subdocs
+                  names = map (cleanName . unLoc) lnames
+                  leader = if is_def then Just (keyword "default") else Nothing
+            ]
+      -- N.B. taking just the first name is ok. Signatures with multiple
+      -- names are expanded so that each name gets its own signature.
+      -- Get rid of the ugly '$dm' prefix on default method names
+      cleanName n
+        | isDefaultMethodOcc (occName n)
+        , '$' : 'd' : 'm' : occStr <- getOccString n =
+            setName (tidyNameOcc (getName n) (mkOccName varName occStr)) n
+        | otherwise = n
+
+      instancesBit = ppDocInstances unicode instances
+ppClassDecl _ _ _ _ _ = error "declaration type not supported by ppShortClassDecl"
+
+ppDocInstances :: Bool -> [DocInstance DocNameI] -> LaTeX
+ppDocInstances _unicode [] = empty
+ppDocInstances unicode (i : rest)
+  | Just ihead <- isUndocdInstance i =
+      declWithDoc (vcat (map (ppInstDecl unicode) (ihead : is))) Nothing
+        $$ ppDocInstances unicode rest'
+  | otherwise =
+      ppDocInstance unicode i $$ ppDocInstances unicode rest
+  where
+    (is, rest') = spanWith isUndocdInstance rest
+
+isUndocdInstance :: DocInstance a -> Maybe (InstHead a)
+isUndocdInstance (i, Nothing, _, _) = Just i
+isUndocdInstance (i, Just (MetaDoc _ DocEmpty), _, _) = Just i
+isUndocdInstance _ = Nothing
+
+-- | Print a possibly commented instance. The instance header is printed inside
+-- an 'argBox'. The comment is printed to the right of the box in normal comment
+-- style.
+ppDocInstance :: Bool -> DocInstance DocNameI -> LaTeX
+ppDocInstance unicode (instHead, doc, _, _) =
+  declWithDoc (ppInstDecl unicode instHead) (fmap docToLaTeX $ fmap _doc doc)
+
+ppInstDecl :: Bool -> InstHead DocNameI -> LaTeX
+ppInstDecl unicode (InstHead{..}) = case ihdInstType of
+  ClassInst ctx _ _ _ -> keyword "instance" <+> ppContextNoLocs ctx unicode <+> typ
+  TypeInst rhs -> keyword "type" <+> keyword "instance" <+> typ <+> tibody rhs
+  DataInst dd ->
+    let cons = dd_cons (tcdDataDefn dd)
+        pref = case cons of NewTypeCon _ -> keyword "newtype"; DataTypeCons _ _ -> keyword "data"
+     in pref <+> keyword "instance" <+> typ
+  where
+    typ = ppAppNameTypes ihdClsName ihdTypes unicode
+    tibody = maybe empty (\t -> equals <+> ppType unicode t)
+
+lookupAnySubdoc
+  :: Eq name1
+  => name1
+  -> [(name1, DocForDecl name2)]
+  -> DocForDecl name2
+lookupAnySubdoc n subdocs = case lookup n subdocs of
+  Nothing -> noDocForDecl
+  Just docs -> docs
+
+-------------------------------------------------------------------------------
+
+-- * Data & newtype declarations
+
+-------------------------------------------------------------------------------
+
+-- | Pretty-print a data declaration
+ppDataDecl
+  :: [(HsDecl DocNameI, DocForDecl DocName)]
+  -- ^ relevant patterns
+  -> [DocInstance DocNameI]
+  -- ^ relevant instances
+  -> [(DocName, DocForDecl DocName)]
+  -- ^ relevant decl docs
+  -> Maybe (Documentation DocName)
+  -- ^ this decl's docs
+  -> TyClDecl DocNameI
+  -- ^ data decl to print
+  -> Bool
+  -- ^ unicode
+  -> LaTeX
+ppDataDecl pats instances subdocs doc dataDecl unicode =
+  declWithDoc
+    (ppDataHeader dataDecl unicode <+> whereBit)
+    (if null body then Nothing else Just (vcat body))
+    $$ instancesBit
+  where
+    cons = dd_cons (tcdDataDefn dataDecl)
+
+    body = catMaybes [doc >>= documentationToLaTeX, constrBit, patternBit]
+
+    (whereBit, leaders)
+      | null cons
+      , null pats =
+          (empty, [])
+      | null cons = (text "where", repeat empty)
+      | otherwise = case toList cons of
+          L _ ConDeclGADT{} : _ -> (text "where", repeat empty)
+          _ -> (empty, (decltt (text "=") : repeat (decltt (text "|"))))
+
+    constrBit
+      | null cons = Nothing
+      | otherwise =
+          Just $
+            text "\\enspace" <+> emph (text "Constructors") <> text "\\par"
+              $$ text "\\haddockbeginconstrs"
+              $$ vcat (zipWith (ppSideBySideConstr subdocs unicode) leaders (toList cons))
+              $$ text "\\end{tabulary}\\par"
+
+    patternBit
+      | null pats = Nothing
+      | otherwise =
+          Just $
+            text "\\enspace" <+> emph (text "Bundled Patterns") <> text "\\par"
+              $$ text "\\haddockbeginconstrs"
+              $$ vcat
+                [ empty <-> ppSideBySidePat lnames typ d unicode
+                | (SigD _ (PatSynSig _ lnames typ), d) <- pats
+                ]
+              $$ text "\\end{tabulary}\\par"
+
+    instancesBit = ppDocInstances unicode instances
+
+-- ppConstrHdr is for (non-GADT) existentials constructors' syntax
+ppConstrHdr
+  :: Bool
+  -- ^ print explicit foralls
+  -> [LHsTyVarBndr Specificity DocNameI]
+  -- ^ type variables
+  -> HsContext DocNameI
+  -- ^ context
+  -> Bool
+  -- ^ unicode
+  -> LaTeX
+ppConstrHdr forall_ tvs ctxt unicode = ppForall <> ppCtxt
+  where
+    ppForall
+      | null tvs || not forall_ = empty
+      | otherwise = ppHsForAllTelescope (mkHsForAllInvisTeleI tvs) unicode
+
+    ppCtxt
+      | null ctxt = empty
+      | otherwise = ppContextNoArrow ctxt unicode <+> darrow unicode <> space
+
+-- | Pretty-print a constructor
+ppSideBySideConstr
+  :: [(DocName, DocForDecl DocName)]
+  -- ^ all decl docs
+  -> Bool
+  -- ^ unicode
+  -> LaTeX
+  -- ^ prefix to decl
+  -> LConDecl DocNameI
+  -- ^ constructor decl
+  -> LaTeX
+ppSideBySideConstr subdocs unicode leader (L _ con) =
+  leader <-> decltt decl <-> rDoc mbDoc <+> nl
+    $$ fieldPart
+  where
+    -- Find the name of a constructors in the decl (`getConName` always returns
+    -- a non-empty list)
+    L _ aConName :| _ = getConNamesI con
+
+    occ = toList $ nameOccName . getName . unLoc <$> getConNamesI con
+
+    ppOcc = cat (punctuate comma (map ppBinder occ))
+    ppOccInfix = cat (punctuate comma (map ppBinderInfix occ))
+
+    -- Extract out the map of of docs corresponding to the constructors arguments
+    argDocs = maybe Map.empty snd (lookup aConName subdocs)
+    hasArgDocs = not $ Map.null argDocs
+
+    -- First line of the constructor (no doc, no fields, single-line)
+    decl = case con of
+      ConDeclH98
+        { con_args = det
+        , con_ex_tvs = tyVars
+        , con_forall = forall_
+        , con_mb_cxt = cxt
+        } ->
+          let context = fromMaybeContext cxt
+              header_ = ppConstrHdr forall_ tyVars context unicode
+           in case det of
+                -- Prefix constructor, e.g. 'Just a'
+                PrefixCon _ args
+                  | hasArgDocs -> header_ <+> ppOcc
+                  | otherwise ->
+                      hsep
+                        [ header_
+                        , ppOcc
+                        , hsep (map (ppLParendType unicode . hsScaledThing) args)
+                        ]
+                -- Record constructor, e.g. 'Identity { runIdentity :: a }'
+                RecCon _ -> header_ <+> ppOcc
+                -- Infix constructor, e.g. 'a :| [a]'
+                InfixCon arg1 arg2
+                  | hasArgDocs -> header_ <+> ppOcc
+                  | otherwise ->
+                      hsep
+                        [ header_
+                        , ppLParendType unicode (hsScaledThing arg1)
+                        , ppOccInfix
+                        , ppLParendType unicode (hsScaledThing arg2)
+                        ]
+      ConDeclGADT{}
+        | hasArgDocs || not (isEmpty fieldPart) -> ppOcc
+        | otherwise ->
+            hsep
+              [ ppOcc
+              , dcolon unicode
+              , -- ++AZ++ make this prepend "{..}" when it is a record style GADT
+                ppLSigType unicode (getGADTConType con)
+              ]
+
+    fieldPart = case con of
+      ConDeclGADT{con_g_args = con_args'} -> case con_args' of
+        -- GADT record declarations
+        RecConGADT _ _ -> doConstrArgsWithDocs []
+        -- GADT prefix data constructors
+        PrefixConGADT _ args | hasArgDocs -> doConstrArgsWithDocs (map hsScaledThing args)
+        _ -> empty
+      ConDeclH98{con_args = con_args'} -> case con_args' of
+        -- H98 record declarations
+        RecCon (L _ fields) -> doRecordFields fields
+        -- H98 prefix data constructors
+        PrefixCon _ args | hasArgDocs -> doConstrArgsWithDocs (map hsScaledThing args)
+        -- H98 infix data constructor
+        InfixCon arg1 arg2 | hasArgDocs -> doConstrArgsWithDocs (map hsScaledThing [arg1, arg2])
+        _ -> empty
+
+    doRecordFields fields =
+      vcat
+        [ empty <-> tt (text begin) <+> ppSideBySideField subdocs unicode field <+> nl
+        | (begin, L _ field) <- zip ("\\qquad \\{" : repeat "\\qquad ,") fields
+        ]
+        $$ empty <-> tt (text "\\qquad \\}") <+> nl
+
+    doConstrArgsWithDocs args = vcat $ map (\l -> empty <-> text "\\qquad" <+> l) $ case con of
+      ConDeclH98{} ->
+        [ decltt (ppLParendType unicode arg) <-> rDoc (fmap _doc mdoc) <+> nl
+        | (i, arg) <- zip [0 ..] args
+        , let mdoc = Map.lookup i argDocs
+        ]
+      ConDeclGADT{} ->
+        [ l <+> text "\\enspace" <+> r
+        | (l, r) <- ppSubSigLike unicode (unLoc (getGADTConType con)) argDocs subdocs (dcolon unicode)
+        ]
+
+    -- don't use "con_doc con", in case it's reconstructed from a .hi file,
+    -- or also because we want Haddock to do the doc-parsing, not GHC.
+    mbDoc = case getConNamesI con of
+      cn :| _ ->
+        lookup (unLoc cn) subdocs
+          >>= fmap _doc . combineDocumentation . fst
+
+-- | Pretty-print a record field
+ppSideBySideField :: [(DocName, DocForDecl DocName)] -> Bool -> ConDeclField DocNameI -> LaTeX
+ppSideBySideField subdocs unicode (ConDeclField _ names ltype _) =
+  decltt
+    ( cat (punctuate comma (map (ppBinder . rdrNameOcc . unLoc . foLabel . unLoc) names))
+        <+> dcolon unicode
+        <+> ppLType unicode ltype
+    )
+    <-> rDoc mbDoc
+  where
+    -- don't use cd_fld_doc for same reason we don't use con_doc above
+    -- Where there is more than one name, they all have the same documentation
+    mbDoc = lookup (foExt $ unLoc $ head names) subdocs >>= fmap _doc . combineDocumentation . fst
+
+-- | Pretty-print a bundled pattern synonym
+ppSideBySidePat
+  :: [LocatedN DocName]
+  -- ^ pattern name(s)
+  -> LHsSigType DocNameI
+  -- ^ type of pattern(s)
+  -> DocForDecl DocName
+  -- ^ doc map
+  -> Bool
+  -- ^ unicode
+  -> LaTeX
+ppSideBySidePat lnames typ (doc, argDocs) unicode =
+  decltt decl <-> rDoc mDoc <+> nl
+    $$ fieldPart
+  where
+    hasArgDocs = not $ Map.null argDocs
+    ppOcc = hsep (punctuate comma (map (ppDocBinder . unLoc) lnames))
+
+    decl
+      | hasArgDocs = keyword "pattern" <+> ppOcc
+      | otherwise =
+          hsep
+            [ keyword "pattern"
+            , ppOcc
+            , dcolon unicode
+            , ppLSigType unicode typ
+            ]
+
+    fieldPart
+      | not hasArgDocs = empty
+      | otherwise =
+          vcat
+            [ empty <-> text "\\qquad" <+> l <+> text "\\enspace" <+> r
+            | (l, r) <- ppSubSigLike unicode (unLoc typ) argDocs [] (dcolon unicode)
+            ]
+
+    mDoc = fmap _doc $ combineDocumentation doc
+
+-- | Print the LHS of a data\/newtype declaration.
+-- Currently doesn't handle 'data instance' decls or kind signatures
+ppDataHeader :: TyClDecl DocNameI -> Bool -> LaTeX
+ppDataHeader
+  ( DataDecl
+      { tcdLName = L _ name
+      , tcdTyVars = tyvars
+      , tcdDataDefn = HsDataDefn{dd_cons = cons, dd_ctxt = ctxt}
+      }
+    )
+  unicode =
+    -- newtype or data
+    ( case cons of
+        NewTypeCon _ -> keyword "newtype"
+        DataTypeCons False _ -> keyword "data"
+        DataTypeCons True _ -> keyword "type" <+> keyword "data"
+    )
+      <+>
+      -- context
+      ppLContext ctxt unicode
+      <+>
+      -- T a b c ..., or a :+: b
+      ppAppDocNameNames False name (tyvarNames tyvars)
+ppDataHeader _ _ = error "ppDataHeader: illegal argument"
+
+--------------------------------------------------------------------------------
+
+-- * Type applications
+
+--------------------------------------------------------------------------------
+
+ppAppDocNameTyVarBndrs
+  :: RenderableBndrFlag flag
+  => Bool
+  -> DocName
+  -> [LHsTyVarBndr flag DocNameI]
+  -> LaTeX
+ppAppDocNameTyVarBndrs unicode n vs =
+  ppTypeApp n vs ppDN (ppHsTyVarBndr unicode . unLoc)
+  where
+    ppDN = ppBinder . nameOccName . getName
+
+-- | Print an application of a DocName to its list of HsTypes
+ppAppNameTypes :: DocName -> [HsType DocNameI] -> Bool -> LaTeX
+ppAppNameTypes n ts unicode = ppTypeApp n ts ppDocName (ppParendType unicode)
+
+ppAppNameTypeArgs :: DocName -> [LHsTypeArg DocNameI] -> Bool -> LaTeX
+ppAppNameTypeArgs n args@(HsValArg _ _ : HsValArg _ _ : _) unicode =
+  ppTypeApp n args ppDocName (ppLHsTypeArg unicode)
+ppAppNameTypeArgs n args unicode =
+  ppDocName n <+> hsep (map (ppLHsTypeArg unicode) args)
+
+-- | Print an application of a DocName and a list of Names
+ppAppDocNameNames :: Bool -> DocName -> [Name] -> LaTeX
+ppAppDocNameNames _summ n ns =
+  ppTypeApp n ns (ppBinder . nameOccName . getName) ppSymName
+
+-- | General printing of type applications
+ppTypeApp :: DocName -> [a] -> (DocName -> LaTeX) -> (a -> LaTeX) -> LaTeX
+ppTypeApp n (t1 : t2 : rest) ppDN ppT
+  | operator, not . null $ rest = parens opApp <+> hsep (map ppT rest)
+  | operator = opApp
+  where
+    operator = isNameSym . getName $ n
+    opApp = ppT t1 <+> ppDN n <+> ppT t2
+ppTypeApp n ts ppDN ppT = ppDN n <+> hsep (map ppT ts)
+
+-------------------------------------------------------------------------------
+
+-- * Contexts
+
+-------------------------------------------------------------------------------
+
+ppLContext :: Maybe (LHsContext DocNameI) -> Bool -> LaTeX
+ppLContext Nothing _ = empty
+ppLContext (Just ctxt) unicode = ppContext (unLoc ctxt) unicode
+
+ppLContextNoArrow :: LHsContext DocNameI -> Bool -> LaTeX
+ppLContextNoArrow ctxt unicode = ppContextNoArrow (unLoc ctxt) unicode
+
+ppContextNoLocsMaybe :: [HsType DocNameI] -> Bool -> Maybe LaTeX
+ppContextNoLocsMaybe [] _ = Nothing
+ppContextNoLocsMaybe cxt unicode = Just $ pp_hs_context cxt unicode
+
+ppContextNoArrow :: HsContext DocNameI -> Bool -> LaTeX
+ppContextNoArrow cxt unicode =
+  fromMaybe empty $
+    ppContextNoLocsMaybe (map unLoc cxt) unicode
+
+ppContextNoLocs :: [HsType DocNameI] -> Bool -> LaTeX
+ppContextNoLocs cxt unicode =
+  maybe empty (<+> darrow unicode) $
+    ppContextNoLocsMaybe cxt unicode
+
+ppContext :: HsContext DocNameI -> Bool -> LaTeX
+ppContext cxt unicode = ppContextNoLocs (map unLoc cxt) unicode
+
+pp_hs_context :: [HsType DocNameI] -> Bool -> LaTeX
+pp_hs_context [] _ = empty
+pp_hs_context [p] unicode = ppCtxType unicode p
+pp_hs_context cxt unicode = parenList (map (ppType unicode) cxt)
+
+-------------------------------------------------------------------------------
+
+-- * Types and contexts
+
+-------------------------------------------------------------------------------
+
+ppBang :: HsSrcBang -> LaTeX
+ppBang (HsSrcBang _ _ SrcStrict) = char '!'
+ppBang (HsSrcBang _ _ SrcLazy) = char '~'
+ppBang _ = empty
+
+tupleParens :: HsTupleSort -> [LaTeX] -> LaTeX
+tupleParens HsUnboxedTuple = ubxParenList
+tupleParens _ = parenList
+
+sumParens :: [LaTeX] -> LaTeX
+sumParens = ubxparens . hsep . punctuate (text " |")
+
+-------------------------------------------------------------------------------
+
+-- * Rendering of HsType
+
+--
+-- Stolen from Html and tweaked for LaTeX generation
+-------------------------------------------------------------------------------
+
+ppLType, ppLParendType, ppLFunLhType :: Bool -> LHsType DocNameI -> LaTeX
+ppLType unicode y = ppType unicode (unLoc y)
+ppLParendType unicode y = ppParendType unicode (unLoc y)
+ppLFunLhType unicode y = ppFunLhType unicode (unLoc y)
+
+ppLSigType :: Bool -> LHsSigType DocNameI -> LaTeX
+ppLSigType unicode y = ppSigType unicode (unLoc y)
+
+ppType, ppParendType, ppFunLhType, ppCtxType :: Bool -> HsType DocNameI -> LaTeX
+ppType unicode ty = ppr_mono_ty (reparenTypePrec PREC_TOP ty) unicode
+ppParendType unicode ty = ppr_mono_ty (reparenTypePrec PREC_TOP ty) unicode
+ppFunLhType unicode ty = ppr_mono_ty (reparenTypePrec PREC_FUN ty) unicode
+ppCtxType unicode ty = ppr_mono_ty (reparenTypePrec PREC_CTX ty) unicode
+
+ppSigType :: Bool -> HsSigType DocNameI -> LaTeX
+ppSigType unicode sig_ty = ppr_sig_ty (reparenSigType sig_ty) unicode
+
+ppLHsTypeArg :: Bool -> LHsTypeArg DocNameI -> LaTeX
+ppLHsTypeArg unicode (HsValArg _ ty) = ppLParendType unicode ty
+ppLHsTypeArg unicode (HsTypeArg _ ki) = atSign <> ppLParendType unicode ki
+ppLHsTypeArg _ (HsArgPar _) = text ""
+
+class RenderableBndrFlag flag where
+  ppHsTyVarBndr :: Bool -> HsTyVarBndr flag DocNameI -> LaTeX
+
+instance RenderableBndrFlag () where
+  ppHsTyVarBndr _ (UserTyVar _ _ (L _ name)) = ppDocName name
+  ppHsTyVarBndr unicode (KindedTyVar _ _ (L _ name) kind) =
+    parens (ppDocName name <+> dcolon unicode <+> ppLKind unicode kind)
+
+instance RenderableBndrFlag Specificity where
+  ppHsTyVarBndr _ (UserTyVar _ SpecifiedSpec (L _ name)) = ppDocName name
+  ppHsTyVarBndr _ (UserTyVar _ InferredSpec (L _ name)) = braces $ ppDocName name
+  ppHsTyVarBndr unicode (KindedTyVar _ SpecifiedSpec (L _ name) kind) =
+    parens (ppDocName name <+> dcolon unicode <+> ppLKind unicode kind)
+  ppHsTyVarBndr unicode (KindedTyVar _ InferredSpec (L _ name) kind) =
+    braces (ppDocName name <+> dcolon unicode <+> ppLKind unicode kind)
+
+instance RenderableBndrFlag (HsBndrVis DocNameI) where
+  ppHsTyVarBndr _ (UserTyVar _ bvis (L _ name)) =
+    ppHsBndrVis bvis $ ppDocName name
+  ppHsTyVarBndr unicode (KindedTyVar _ bvis (L _ name) kind) =
+    ppHsBndrVis bvis $
+      parens (ppDocName name <+> dcolon unicode <+> ppLKind unicode kind)
+
+ppHsBndrVis :: HsBndrVis DocNameI -> LaTeX -> LaTeX
+ppHsBndrVis (HsBndrRequired _) d = d
+ppHsBndrVis (HsBndrInvisible _) d = atSign <> d
+
+ppLKind :: Bool -> LHsKind DocNameI -> LaTeX
+ppLKind unicode y = ppKind unicode (unLoc y)
+
+ppKind :: Bool -> HsKind DocNameI -> LaTeX
+ppKind unicode ki = ppr_mono_ty (reparenTypePrec PREC_TOP ki) unicode
+
+-- Drop top-level for-all type variables in user style
+-- since they are implicit in Haskell
+
+ppr_sig_ty :: HsSigType DocNameI -> Bool -> LaTeX
+ppr_sig_ty (HsSig{sig_bndrs = outer_bndrs, sig_body = ltype}) unicode =
+  sep
+    [ ppHsOuterTyVarBndrs outer_bndrs unicode
+    , ppr_mono_lty ltype unicode
+    ]
+
+ppr_mono_lty :: LHsType DocNameI -> Bool -> LaTeX
+ppr_mono_lty ty unicode = ppr_mono_ty (unLoc ty) unicode
+
+ppr_mono_ty :: HsType DocNameI -> Bool -> LaTeX
+ppr_mono_ty (HsForAllTy _ tele ty) unicode =
+  sep
+    [ ppHsForAllTelescope tele unicode
+    , ppr_mono_lty ty unicode
+    ]
+ppr_mono_ty (HsQualTy _ ctxt ty) unicode =
+  sep
+    [ ppLContext (Just ctxt) unicode
+    , ppr_mono_lty ty unicode
+    ]
+ppr_mono_ty (HsFunTy _ mult ty1 ty2) u =
+  sep
+    [ ppr_mono_lty ty1 u
+    , arr <+> ppr_mono_lty ty2 u
+    ]
+  where
+    arr = case mult of
+      HsLinearArrow _ -> lollipop u
+      HsUnrestrictedArrow _ -> arrow u
+      HsExplicitMult _ m -> multAnnotation <> ppr_mono_lty m u <+> arrow u
+ppr_mono_ty (HsBangTy _ b ty) u = ppBang b <> ppLParendType u ty
+ppr_mono_ty (HsTyVar _ NotPromoted (L _ name)) _ = ppDocName name
+ppr_mono_ty (HsTyVar _ IsPromoted (L _ name)) _ = char '\'' <> ppDocName name
+ppr_mono_ty (HsTupleTy _ con tys) u = tupleParens con (map (ppLType u) tys)
+ppr_mono_ty (HsSumTy _ tys) u = sumParens (map (ppLType u) tys)
+ppr_mono_ty (HsKindSig _ ty kind) u = parens (ppr_mono_lty ty u <+> dcolon u <+> ppLKind u kind)
+ppr_mono_ty (HsListTy _ ty) u = brackets (ppr_mono_lty ty u)
+ppr_mono_ty (HsIParamTy _ (L _ n) ty) u = ppIPName n <+> dcolon u <+> ppr_mono_lty ty u
+ppr_mono_ty (HsSpliceTy v _) _ = dataConCantHappen v
+ppr_mono_ty (HsRecTy{}) _ = text "{..}"
+ppr_mono_ty (XHsType{}) _ = error "ppr_mono_ty HsCoreTy"
+ppr_mono_ty (HsExplicitListTy _ IsPromoted tys) u = Pretty.quote $ brackets $ hsep $ punctuate comma $ map (ppLType u) tys
+ppr_mono_ty (HsExplicitListTy _ NotPromoted tys) u = brackets $ hsep $ punctuate comma $ map (ppLType u) tys
+ppr_mono_ty (HsExplicitTupleTy _ tys) u = Pretty.quote $ parenList $ map (ppLType u) tys
+ppr_mono_ty (HsAppTy _ fun_ty arg_ty) unicode =
+  hsep [ppr_mono_lty fun_ty unicode, ppr_mono_lty arg_ty unicode]
+ppr_mono_ty (HsAppKindTy _ fun_ty arg_ki) unicode =
+  hsep [ppr_mono_lty fun_ty unicode, atSign <> ppr_mono_lty arg_ki unicode]
+ppr_mono_ty (HsOpTy _ prom ty1 op ty2) unicode =
+  ppr_mono_lty ty1 unicode <+> ppr_op_prom <+> ppr_mono_lty ty2 unicode
+  where
+    ppr_op_prom
+      | isPromoted prom =
+          char '\'' <> ppr_op
+      | otherwise =
+          ppr_op
+    ppr_op
+      | isSymOcc (getOccName op) = ppLDocName op
+      | otherwise = char '`' <> ppLDocName op <> char '`'
+ppr_mono_ty (HsParTy _ ty) unicode =
+  parens (ppr_mono_lty ty unicode)
+--  = ppr_mono_lty ty unicode
+
+ppr_mono_ty (HsDocTy _ ty _) unicode =
+  ppr_mono_lty ty unicode
+ppr_mono_ty (HsWildCardTy _) _ = char '_'
+ppr_mono_ty (HsTyLit _ t) u = ppr_tylit t u
+ppr_mono_ty (HsStarTy _ isUni) unicode = starSymbol (isUni || unicode)
+
+ppr_tylit :: HsTyLit DocNameI -> Bool -> LaTeX
+ppr_tylit (HsNumTy _ n) _ = integer n
+ppr_tylit (HsStrTy _ s) _ = text (show s)
+ppr_tylit (HsCharTy _ c) _ = text (show c)
+
+-- XXX: Ok in verbatim, but not otherwise
+-- XXX: Do something with Unicode parameter?
+
+-------------------------------------------------------------------------------
+
+-- * Names
+
+-------------------------------------------------------------------------------
+
+ppBinder :: OccName -> LaTeX
+ppBinder n
+  | isSymOcc n = parens $ ppOccName n
+  | otherwise = ppOccName n
+
+ppBinderInfix :: OccName -> LaTeX
+ppBinderInfix n
+  | isSymOcc n = ppOccName n
+  | otherwise = cat [char '`', ppOccName n, char '`']
+
+ppSymName :: Name -> LaTeX
+ppSymName name
+  | isNameSym name = parens $ ppName name
+  | otherwise = ppName name
+
+ppIPName :: HsIPName -> LaTeX
+ppIPName = text . ('?' :) . unpackFS . hsIPNameFS
+
+ppOccName :: OccName -> LaTeX
+ppOccName = text . occNameString
+
+ppDocName :: DocName -> LaTeX
+ppDocName = ppOccName . nameOccName . getName
+
+ppLDocName :: GenLocated l DocName -> LaTeX
+ppLDocName (L _ d) = ppDocName d
+
+ppDocBinder :: DocName -> LaTeX
+ppDocBinder = ppBinder . nameOccName . getName
+
+ppName :: Name -> LaTeX
+ppName = ppOccName . nameOccName
+
+latexFilter :: String -> String
+latexFilter = foldr latexMunge ""
+
+latexMonoFilter :: String -> String
+latexMonoFilter = foldr latexMonoMunge ""
+
+latexMunge :: Char -> String -> String
+latexMunge '#' s = "{\\char '43}" ++ s
+latexMunge '$' s = "{\\char '44}" ++ s
+latexMunge '%' s = "{\\char '45}" ++ s
+latexMunge '&' s = "{\\char '46}" ++ s
+latexMunge '~' s = "{\\char '176}" ++ s
+latexMunge '_' s = "{\\char '137}" ++ s
+latexMunge '^' s = "{\\char '136}" ++ s
+latexMunge '\\' s = "{\\char '134}" ++ s
+latexMunge '{' s = "{\\char '173}" ++ s
+latexMunge '}' s = "{\\char '175}" ++ s
+latexMunge '[' s = "{\\char 91}" ++ s
+latexMunge ']' s = "{\\char 93}" ++ s
+latexMunge c s = c : s
+
+latexMonoMunge :: Char -> String -> String
+latexMonoMunge ' ' (' ' : s) = "\\ \\ " ++ s
+latexMonoMunge ' ' ('\\' : ' ' : s) = "\\ \\ " ++ s
+latexMonoMunge '\n' s = '\\' : '\\' : s
+latexMonoMunge c s = latexMunge c s
+
+-------------------------------------------------------------------------------
+
+-- * Doc Markup
+
+-------------------------------------------------------------------------------
+
+latexMarkup :: HasOccName a => DocMarkup (Wrap a) (StringContext -> LaTeX -> LaTeX)
+latexMarkup =
+  Markup
+    { markupParagraph = \p v -> blockElem (p v (text "\\par"))
+    , markupEmpty = \_ -> id
+    , markupString = \s v -> inlineElem (text (fixString v s))
+    , markupAppend = \l r v -> l v . r v
+    , markupIdentifier = \i v -> inlineElem (markupId v (fmap occName i))
+    , markupIdentifierUnchecked = \i v -> inlineElem (markupId v (fmap snd i))
+    , markupModule =
+        \(ModLink m mLabel) v ->
+          case mLabel of
+            Just lbl -> inlineElem . tt $ lbl v empty
+            Nothing ->
+              inlineElem
+                ( let (mdl, _ref) = break (== '#') m
+                   in (tt (text mdl))
+                )
+    , markupWarning = \p v -> p v
+    , markupEmphasis = \p v -> inlineElem (emph (p v empty))
+    , markupBold = \p v -> inlineElem (bold (p v empty))
+    , markupMonospaced = \p v -> inlineElem (markupMonospace p v)
+    , markupUnorderedList = \p v -> blockElem (itemizedList (map (\p' -> p' v empty) p))
+    , markupPic = \p _ -> inlineElem (markupPic p)
+    , markupMathInline = \p _ -> inlineElem (markupMathInline p)
+    , markupMathDisplay = \p _ -> blockElem (markupMathDisplay p)
+    , markupOrderedList = \p v -> blockElem (enumeratedList (map (\(_, p') -> p' v empty) p))
+    , markupDefList = \l v -> blockElem (descriptionList (map (\(a, b) -> (a v empty, b v empty)) l))
+    , markupCodeBlock = \p _ -> blockElem (quote (verb (p Verb empty)))
+    , markupHyperlink = \(Hyperlink u l) v -> inlineElem (markupLink u (fmap (\x -> x v empty) l))
+    , markupAName = \_ _ -> id -- TODO
+    , markupProperty = \p _ -> blockElem (quote (verb (text p)))
+    , markupExample = \e _ -> blockElem (quote (verb (text $ unlines $ map exampleToString e)))
+    , markupHeader = \(Header l h) p -> blockElem (header l (h p empty))
+    , markupTable = \(Table h b) p -> blockElem (table h b p)
+    }
+  where
+    blockElem :: LaTeX -> LaTeX -> LaTeX
+    blockElem = ($$)
+
+    inlineElem :: LaTeX -> LaTeX -> LaTeX
+    inlineElem = (<>)
+
+    header 1 d = text "\\section*" <> braces d
+    header 2 d = text "\\subsection*" <> braces d
+    header l d
+      | l > 0 && l <= 6 = text "\\subsubsection*" <> braces d
+    header l _ = error $ "impossible header level in LaTeX generation: " ++ show l
+
+    table _ _ _ = text "{TODO: Table}"
+
+    fixString Plain s = latexFilter s
+    fixString Verb s = s
+    fixString Mono s = latexMonoFilter s
+
+    markupMonospace p Verb = p Verb empty
+    markupMonospace p _ = tt (p Mono empty)
+
+    markupLink url mLabel = case mLabel of
+      Just label -> text "\\href" <> braces (text url) <> braces label
+      Nothing -> text "\\url" <> braces (text url)
+
+    -- Is there a better way of doing this? Just a space is an arbitrary choice.
+    markupPic (Picture uri title) = parens (imageText title)
+      where
+        imageText Nothing = beg
+        imageText (Just t) = beg <> text " " <> text t
+
+        beg = text "image: " <> text uri
+
+    markupMathInline mathjax = text "\\(" <> text mathjax <> text "\\)"
+
+    markupMathDisplay mathjax = text "\\[" <> text mathjax <> text "\\]"
+
+    markupId v wrappedOcc =
+      case v of
+        Verb -> text i
+        Mono -> text "\\haddockid" <> braces (text . latexMonoFilter $ i)
+        Plain -> text "\\haddockid" <> braces (text . latexFilter $ i)
+      where
+        i = showWrapped occNameString wrappedOcc
+
+docToLaTeX :: Doc DocName -> LaTeX
+docToLaTeX doc = markup latexMarkup doc Plain empty
+
+documentationToLaTeX :: Documentation DocName -> Maybe LaTeX
+documentationToLaTeX = fmap docToLaTeX . fmap _doc . combineDocumentation
+
+rdrDocToLaTeX :: Doc RdrName -> LaTeX
+rdrDocToLaTeX doc = markup latexMarkup doc Plain empty
+
+data StringContext
+  = -- | all special characters have to be escape
+    Plain
+  | -- | on top of special characters, escape space characters
+    Mono
+  | -- | don't escape anything
+    Verb
+
+latexStripTrailingWhitespace :: Doc a -> Doc a
+latexStripTrailingWhitespace (DocString s)
+  | null s' = DocEmpty
+  | otherwise = DocString s
+  where
+    s' = reverse (dropWhile isSpace (reverse s))
+latexStripTrailingWhitespace (DocAppend l r)
+  | DocEmpty <- r' = latexStripTrailingWhitespace l
+  | otherwise = DocAppend l r'
+  where
+    r' = latexStripTrailingWhitespace r
+latexStripTrailingWhitespace (DocParagraph p) =
+  latexStripTrailingWhitespace p
+latexStripTrailingWhitespace other = other
+
+-------------------------------------------------------------------------------
+
+-- * LaTeX utils
+
+-------------------------------------------------------------------------------
+
+itemizedList :: [LaTeX] -> LaTeX
+itemizedList items =
+  text "\\vbox{\\begin{itemize}"
+    $$ vcat (map (text "\\item" $$) items)
+    $$ text "\\end{itemize}}"
+
+enumeratedList :: [LaTeX] -> LaTeX
+enumeratedList items =
+  text "\\vbox{\\begin{enumerate}"
+    $$ vcat (map (text "\\item " $$) items)
+    $$ text "\\end{enumerate}}"
+
+descriptionList :: [(LaTeX, LaTeX)] -> LaTeX
+descriptionList items =
+  text "\\vbox{\\begin{description}"
+    $$ vcat (map (\(a, b) -> text "\\item" <> brackets a <> text "\\hfill \\par" $$ b) items)
+    $$ text "\\end{description}}"
+
+tt :: LaTeX -> LaTeX
+tt ltx = text "\\haddocktt" <> braces ltx
+
+decltt :: LaTeX -> LaTeX
+decltt ltx = text "\\haddockdecltt" <> braces (text filtered)
+  where
+    filtered = latexMonoFilter (latex2String ltx)
+
+emph :: LaTeX -> LaTeX
+emph ltx = text "\\emph" <> braces ltx
+
+bold :: LaTeX -> LaTeX
+bold ltx = text "\\textbf" <> braces ltx
+
+-- TODO: @verbatim@ is too much since
+--
+--   * Haddock supports markup _inside_ of code blocks. Right now, the LaTeX
+--     representing that markup gets printed verbatim
+--   * Verbatim environments are not supported everywhere (example: not nested
+--     inside a @tabulary@ environment)
+verb :: LaTeX -> LaTeX
+verb doc = text "{\\haddockverb\\begin{verbatim}" $$ doc <> text "\\end{verbatim}}"
+
+-- NB. swallow a trailing \n in the verbatim text by appending the
+-- \end{verbatim} directly, otherwise we get spurious blank lines at the
+-- end of code blocks.
+
+quote :: LaTeX -> LaTeX
+quote doc = text "\\begin{quote}" $$ doc $$ text "\\end{quote}"
+
+dcolon, arrow, lollipop, darrow, forallSymbol, starSymbol :: Bool -> LaTeX
+dcolon unicode = text (if unicode then "∷" else "::")
+arrow unicode = text (if unicode then "→" else "->")
+lollipop unicode = text (if unicode then "⊸" else "%1 ->")
+darrow unicode = text (if unicode then "⇒" else "=>")
+forallSymbol unicode = text (if unicode then "∀" else "forall")
+starSymbol unicode = text (if unicode then "★" else "*")
+
+atSign :: LaTeX
+atSign = char '@'
+
+multAnnotation :: LaTeX
+multAnnotation = char '%'
+
+dot :: LaTeX
+dot = char '.'
+
+parenList :: [LaTeX] -> LaTeX
+parenList = parens . hsep . punctuate comma
+
+ubxParenList :: [LaTeX] -> LaTeX
+ubxParenList = ubxparens . hsep . punctuate comma
+
+ubxparens :: LaTeX -> LaTeX
+ubxparens h = text "(#" <+> h <+> text "#)"
+
+nl :: LaTeX
+nl = text "\\\\"
+
+keyword :: String -> LaTeX
+keyword = text
+
+infixr 4 <-> -- combining table cells
+(<->) :: LaTeX -> LaTeX -> LaTeX
+a <-> b = a <+> char '&' <+> b
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs
new file mode 100644
index 0000000000000000000000000000000000000000..1814e7d28e6a0aaa53b4ab7de54afadef2b7bb25
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs
@@ -0,0 +1,1173 @@
+{-# LANGUAGE BangPatterns #-}
+-----------------------------------------------------------------------------
+-----------------------------------------------------------------------------
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE NamedFieldPuns #-}
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE TypeFamilies #-}
+
+-- |
+-- Module      :  Haddock.Backends.Html
+-- Copyright   :  (c) Simon Marlow      2003-2006,
+--                    David Waern       2006-2009,
+--                    Mark Lentczner    2010,
+--                    Mateusz Kowalczyk 2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.Xhtml
+  ( ppHtml
+  , copyHtmlBits
+  , ppHtmlIndex
+  , ppHtmlContents
+  , ppJsonIndex
+  ) where
+
+import Prelude hiding (div)
+
+import Haddock.Backends.Xhtml.Decl
+import Haddock.Backends.Xhtml.DocMarkup
+import Haddock.Backends.Xhtml.Layout
+import Haddock.Backends.Xhtml.Names
+import Haddock.Backends.Xhtml.Themes
+import Haddock.Backends.Xhtml.Types
+import Haddock.Backends.Xhtml.Utils
+import Haddock.GhcUtils
+import Haddock.InterfaceFile (PackageInfo (..), PackageInterfaces (..), ppPackageInfo)
+import Haddock.ModuleTree
+import Haddock.Options (Visibility (..))
+import Haddock.Types
+import Haddock.Utils
+import Haddock.Utils.Json
+import Haddock.Version
+import Text.XHtml hiding (name, p, quote, title)
+import qualified Text.XHtml as XHtml
+
+import Control.DeepSeq (force)
+import Control.Monad (unless, when)
+import Data.Bifunctor (bimap)
+import qualified Data.ByteString.Builder as Builder
+import Data.Char (isSpace, toUpper)
+import Data.Either (partitionEithers)
+import Data.Foldable (foldl', traverse_)
+import Data.List (intersperse, isPrefixOf, sortBy)
+import Data.Map.Strict (Map)
+import qualified Data.Map.Strict as Map
+import Data.Maybe
+import Data.Ord (comparing)
+import qualified Data.Set as Set hiding (Set)
+import System.Directory
+import System.FilePath hiding ((</>))
+import qualified System.FilePath as FilePath
+import qualified System.IO as IO
+
+import GHC hiding (LexicalFixity (..), NoLink, anchor, moduleInfo)
+import GHC.Types.Name
+import GHC.Unit.State
+
+--------------------------------------------------------------------------------
+
+-- * Generating HTML documentation
+
+--------------------------------------------------------------------------------
+
+ppHtml
+  :: UnitState
+  -> String
+  -- ^ Title
+  -> Maybe String
+  -- ^ Package
+  -> [Interface]
+  -> [InstalledInterface]
+  -- ^ Reexported interfaces
+  -> FilePath
+  -- ^ Destination directory
+  -> Maybe (MDoc GHC.RdrName)
+  -- ^ Prologue text, maybe
+  -> Themes
+  -- ^ Themes
+  -> Maybe String
+  -- ^ The mathjax URL (--mathjax)
+  -> SourceURLs
+  -- ^ The source URL (--source)
+  -> WikiURLs
+  -- ^ The wiki URL (--wiki)
+  -> BaseURL
+  -- ^ The base URL (--base-url)
+  -> Maybe String
+  -- ^ The contents URL (--use-contents)
+  -> Maybe String
+  -- ^ The index URL (--use-index)
+  -> Bool
+  -- ^ Whether to use unicode in output (--use-unicode)
+  -> Maybe String
+  -- ^ Package name
+  -> PackageInfo
+  -- ^ Package info
+  -> QualOption
+  -- ^ How to qualify names
+  -> Bool
+  -- ^ Output pretty html (newlines and indenting)
+  -> Bool
+  -- ^ Also write Quickjump index
+  -> IO ()
+ppHtml
+  state
+  doctitle
+  maybe_package
+  ifaces
+  reexported_ifaces
+  odir
+  prologue
+  themes
+  maybe_mathjax_url
+  maybe_source_url
+  maybe_wiki_url
+  maybe_base_url
+  maybe_contents_url
+  maybe_index_url
+  unicode
+  pkg
+  packageInfo
+  qual
+  debug
+  withQuickjump = do
+    let
+      visible_ifaces = filter visible ifaces
+      visible i = OptHide `notElem` ifaceOptions i
+
+    when (isNothing maybe_contents_url) $
+      ppHtmlContents
+        state
+        odir
+        doctitle
+        maybe_package
+        themes
+        maybe_mathjax_url
+        maybe_index_url
+        maybe_source_url
+        maybe_wiki_url
+        withQuickjump
+        [ PackageInterfaces
+            { piPackageInfo = packageInfo
+            , piVisibility = Visible
+            , piInstalledInterfaces =
+                map toInstalledIface visible_ifaces
+                  ++ reexported_ifaces
+            }
+        ]
+        False -- we don't want to display the packages in a single-package contents
+        prologue
+        debug
+        pkg
+        (makeContentsQual qual)
+
+    when (isNothing maybe_index_url) $ do
+      ppHtmlIndex
+        odir
+        doctitle
+        maybe_package
+        themes
+        maybe_mathjax_url
+        maybe_contents_url
+        maybe_source_url
+        maybe_wiki_url
+        withQuickjump
+        (map toInstalledIface visible_ifaces ++ reexported_ifaces)
+        debug
+
+    when withQuickjump $
+      ppJsonIndex
+        odir
+        maybe_source_url
+        maybe_wiki_url
+        unicode
+        pkg
+        qual
+        visible_ifaces
+        []
+
+    mapM_
+      ( ppHtmlModule
+          odir
+          doctitle
+          themes
+          maybe_mathjax_url
+          maybe_source_url
+          maybe_wiki_url
+          maybe_base_url
+          maybe_contents_url
+          maybe_index_url
+          withQuickjump
+          unicode
+          pkg
+          qual
+          debug
+      )
+      visible_ifaces
+
+copyHtmlBits :: FilePath -> FilePath -> Themes -> Bool -> IO ()
+copyHtmlBits odir libdir themes withQuickjump = do
+  let
+    libhtmldir = joinPath [libdir, "html"]
+    copyCssFile f = copyFile f (combine odir (takeFileName f))
+    copyLibFile f = copyFile (joinPath [libhtmldir, f]) (joinPath [odir, f])
+  mapM_ copyCssFile (cssFiles themes)
+  copyLibFile haddockJsFile
+  copyCssFile (joinPath [libhtmldir, quickJumpCssFile])
+  when withQuickjump (copyLibFile jsQuickJumpFile)
+  return ()
+
+headHtml :: String -> Themes -> Maybe String -> Maybe String -> Html
+headHtml docTitle themes mathjax_url base_url =
+  header
+    ! (maybe [] (\url -> [identifier "head", strAttr "data-base-url" url]) base_url)
+    << [ meta ! [httpequiv "Content-Type", content "text/html; charset=UTF-8"]
+       , meta ! [XHtml.name "viewport", content "width=device-width, initial-scale=1"]
+       , thetitle << docTitle
+       , styleSheet base_url themes
+       , thelink
+          ! [ rel "stylesheet"
+            , thetype "text/css"
+            , href (withBaseURL base_url quickJumpCssFile)
+            ]
+          << noHtml
+       , thelink ! [rel "stylesheet", thetype "text/css", href fontUrl] << noHtml
+       , script
+          ! [ src (withBaseURL base_url haddockJsFile)
+            , emptyAttr "async"
+            , thetype "text/javascript"
+            ]
+          << noHtml
+       , script ! [thetype "text/x-mathjax-config"] << primHtml mjConf
+       , script ! [src mjUrl, thetype "text/javascript"] << noHtml
+       ]
+  where
+    fontUrl = "https://fonts.googleapis.com/css?family=PT+Sans:400,400i,700"
+    mjUrl = fromMaybe "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" mathjax_url
+    mjConf =
+      unwords
+        [ "MathJax.Hub.Config({"
+        , "tex2jax: {"
+        , "processClass: \"mathjax\","
+        , "ignoreClass: \".*\""
+        , "}"
+        , "});"
+        ]
+
+quickJumpButtonLi
+  :: Bool
+  -- ^ With Quick Jump?
+  -> Maybe Html
+-- The TypeScript should replace this <li> element, given its id. However, in
+-- case it does not, the element is given content here too.
+quickJumpButtonLi True =
+  Just $
+    li
+      ! [identifier "quick-jump-button"]
+      << anchor
+      ! [href "#"]
+      << "Quick Jump"
+quickJumpButtonLi False = Nothing
+
+srcButton :: SourceURLs -> Maybe Interface -> Maybe Html
+srcButton (Just src_base_url, _, _, _) Nothing =
+  Just (anchor ! [href src_base_url] << "Source")
+srcButton (_, Just src_module_url, _, _) (Just iface) =
+  let url = spliceURL (Just $ ifaceMod iface) Nothing Nothing src_module_url
+   in Just (anchor ! [href url] << "Source")
+srcButton _ _ =
+  Nothing
+
+wikiButton :: WikiURLs -> Maybe Module -> Maybe Html
+wikiButton (Just wiki_base_url, _, _) Nothing =
+  Just (anchor ! [href wiki_base_url] << "User Comments")
+wikiButton (_, Just wiki_module_url, _) (Just mdl) =
+  let url = spliceURL (Just mdl) Nothing Nothing wiki_module_url
+   in Just (anchor ! [href url] << "User Comments")
+wikiButton _ _ =
+  Nothing
+
+contentsButton :: Maybe String -> Maybe Html
+contentsButton maybe_contents_url =
+  Just (anchor ! [href url] << "Contents")
+  where
+    url = fromMaybe contentsHtmlFile maybe_contents_url
+
+indexButton :: Maybe String -> Maybe Html
+indexButton maybe_index_url =
+  Just (anchor ! [href url] << "Index")
+  where
+    url = fromMaybe indexHtmlFile maybe_index_url
+
+bodyHtml
+  :: String
+  -> Maybe Interface
+  -> SourceURLs
+  -> WikiURLs
+  -> Maybe String
+  -> Maybe String
+  -> Bool
+  -- ^ With Quick Jump?
+  -> Html
+  -> Html
+bodyHtml
+  doctitle
+  iface
+  maybe_source_url
+  maybe_wiki_url
+  maybe_contents_url
+  maybe_index_url
+  withQuickjump
+  pageContent =
+    body
+      << [ divPackageHeader
+            << [ nonEmptySectionName << doctitle
+               , ulist
+                  ! [theclass "links", identifier "page-menu"]
+                  << catMaybes (quickJumpButtonLi withQuickjump : otherButtonLis)
+               ]
+         , divContent << pageContent
+         , divFooter
+            << paragraph
+            << ( "Produced by "
+                  +++ (anchor ! [href projectUrl] << toHtml projectName)
+                  +++ (" version " ++ projectVersion)
+               )
+         ]
+    where
+      otherButtonLis =
+        (fmap . fmap)
+          (li <<)
+          [ srcButton maybe_source_url iface
+          , wikiButton maybe_wiki_url (ifaceMod <$> iface)
+          , contentsButton maybe_contents_url
+          , indexButton maybe_index_url
+          ]
+
+moduleInfo :: Interface -> Html
+moduleInfo iface =
+  let
+    info = ifaceInfo iface
+
+    doOneEntry :: (String, HaddockModInfo GHC.Name -> Maybe String) -> Maybe HtmlTable
+    doOneEntry (fldNm, fld) =
+      fld info >>= \a -> return (th << fldNm <-> td << a)
+
+    entries :: [HtmlTable]
+    entries =
+      maybeToList copyrightsTable
+        ++ mapMaybe
+          doOneEntry
+          [ ("License", hmi_license)
+          , ("Maintainer", hmi_maintainer)
+          , ("Stability", hmi_stability)
+          , ("Portability", hmi_portability)
+          , ("Safe Haskell", hmi_safety)
+          , ("Language", lg)
+          ]
+        ++ extsForm
+      where
+        lg inf = fmap show (hmi_language inf)
+
+        multilineRow :: String -> [String] -> HtmlTable
+        multilineRow title xs = (th ! [valign "top"]) << title <-> td << (toLines xs)
+          where
+            toLines = mconcat . intersperse br . map toHtml
+
+        copyrightsTable :: Maybe HtmlTable
+        copyrightsTable = fmap (multilineRow "Copyright" . split) (hmi_copyright info)
+          where
+            split = map (trim . filter (/= ',')) . lines
+
+        extsForm
+          | OptShowExtensions `elem` ifaceOptions iface =
+              let fs = map (dropOpt . show) (hmi_extensions info)
+               in case map stringToHtml fs of
+                    [] -> []
+                    [x] -> extField x -- don't use a list for a single extension
+                    xs -> extField $ unordList xs ! [theclass "extension-list"]
+          | otherwise = []
+          where
+            extField x = return $ th << "Extensions" <-> td << x
+            dropOpt x = if "Opt_" `isPrefixOf` x then drop 4 x else x
+   in
+    case entries of
+      [] -> noHtml
+      _ -> table ! [theclass "info"] << aboves entries
+
+--------------------------------------------------------------------------------
+
+-- * Generate the module contents
+
+--------------------------------------------------------------------------------
+
+ppHtmlContents
+  :: UnitState
+  -> FilePath
+  -> String
+  -> Maybe String
+  -> Themes
+  -> Maybe String
+  -> Maybe String
+  -> SourceURLs
+  -> WikiURLs
+  -> Bool
+  -- ^ With Quick Jump?
+  -> [PackageInterfaces]
+  -> Bool
+  -> Maybe (MDoc GHC.RdrName)
+  -> Bool
+  -> Maybe Package
+  -- ^ Current package
+  -> Qualification
+  -- ^ How to qualify names
+  -> IO ()
+ppHtmlContents
+  state
+  odir
+  doctitle
+  _maybe_package
+  themes
+  mathjax_url
+  maybe_index_url
+  maybe_source_url
+  maybe_wiki_url
+  withQuickjump
+  packages
+  showPkgs
+  prologue
+  debug
+  pkg
+  qual = do
+    let trees =
+          [ ( piPackageInfo pinfo
+            , mkModuleTree
+                state
+                showPkgs
+                [ (instMod iface, toInstalledDescription iface)
+                | iface <- piInstalledInterfaces pinfo
+                , not (instIsSig iface)
+                ]
+            )
+          | pinfo <- packages
+          ]
+        sig_trees =
+          [ ( piPackageInfo pinfo
+            , mkModuleTree
+                state
+                showPkgs
+                [ (instMod iface, toInstalledDescription iface)
+                | iface <- piInstalledInterfaces pinfo
+                , instIsSig iface
+                ]
+            )
+          | pinfo <- packages
+          ]
+        html =
+          headHtml doctitle themes mathjax_url Nothing
+            +++ bodyHtml
+              doctitle
+              Nothing
+              maybe_source_url
+              maybe_wiki_url
+              Nothing
+              maybe_index_url
+              withQuickjump
+            << [ ppPrologue pkg qual doctitle prologue
+               , ppSignatureTrees pkg qual sig_trees
+               , ppModuleTrees pkg qual trees
+               ]
+    createDirectoryIfMissing True odir
+    writeUtf8File (joinPath [odir, contentsHtmlFile]) (renderToString debug html)
+    where
+      -- Extract a module's short description.
+      toInstalledDescription :: InstalledInterface -> Maybe (MDoc Name)
+      toInstalledDescription = fmap mkMeta . hmi_description . instInfo
+
+ppPrologue :: Maybe Package -> Qualification -> String -> Maybe (MDoc GHC.RdrName) -> Html
+ppPrologue _ _ _ Nothing = noHtml
+ppPrologue pkg qual title (Just doc) =
+  divDescription << (h1 << title +++ docElement thediv (rdrDocToHtml pkg qual doc))
+
+ppSignatureTrees :: Maybe Package -> Qualification -> [(PackageInfo, [ModuleTree])] -> Html
+ppSignatureTrees _ _ tss | all (null . snd) tss = mempty
+ppSignatureTrees pkg qual [(info, ts)] =
+  divPackageList << (sectionName << "Signatures" +++ ppSignatureTree pkg qual "n" info ts)
+ppSignatureTrees pkg qual tss =
+  divModuleList
+    << ( sectionName
+          << "Signatures"
+          +++ concatHtml
+            [ ppSignatureTree pkg qual ("n." ++ show i ++ ".") info ts
+            | (i, (info, ts)) <- zip [(1 :: Int) ..] tss
+            ]
+       )
+
+ppSignatureTree :: Maybe Package -> Qualification -> String -> PackageInfo -> [ModuleTree] -> Html
+ppSignatureTree _ _ _ _ [] = mempty
+ppSignatureTree pkg qual p info ts =
+  divModuleList << (sectionName << ppPackageInfo info +++ mkNodeList pkg qual [] p ts)
+
+ppModuleTrees :: Maybe Package -> Qualification -> [(PackageInfo, [ModuleTree])] -> Html
+ppModuleTrees _ _ tss | all (null . snd) tss = mempty
+ppModuleTrees pkg qual [(info, ts)] =
+  divModuleList << (sectionName << "Modules" +++ ppModuleTree pkg qual "n" info ts)
+ppModuleTrees pkg qual tss =
+  divPackageList
+    << ( sectionName
+          << "Packages"
+          +++ concatHtml
+            [ ppModuleTree pkg qual ("n." ++ show i ++ ".") info ts
+            | (i, (info, ts)) <- zip [(1 :: Int) ..] tss
+            ]
+       )
+
+ppModuleTree :: Maybe Package -> Qualification -> String -> PackageInfo -> [ModuleTree] -> Html
+ppModuleTree _ _ _ _ [] = mempty
+ppModuleTree pkg qual p info ts =
+  divModuleList << (sectionName << ppPackageInfo info +++ mkNodeList pkg qual [] p ts)
+
+mkNodeList :: Maybe Package -> Qualification -> [String] -> String -> [ModuleTree] -> Html
+mkNodeList pkg qual ss p ts = case ts of
+  [] -> noHtml
+  _ -> unordList (zipWith (mkNode pkg qual ss) ps ts)
+  where
+    ps = [p ++ '.' : show i | i <- [(1 :: Int) ..]]
+
+mkNode :: Maybe Package -> Qualification -> [String] -> String -> ModuleTree -> Html
+mkNode pkg qual ss p (Node s leaf _pkg srcPkg short ts) =
+  htmlModule <+> shortDescr +++ htmlPkg +++ subtree
+  where
+    modAttrs = case (ts, leaf) of
+      (_ : _, Nothing) -> collapseControl p "module"
+      (_, _) -> [theclass "module"]
+
+    cBtn = case (ts, leaf) of
+      (_ : _, Just _) -> thespan ! collapseControl p "" << spaceHtml
+      ([], Just _) -> thespan ! [theclass "noexpander"] << spaceHtml
+      (_, _) -> noHtml
+    -- We only need an explicit collapser button when the module name
+    -- is also a leaf, and so is a link to a module page. Indeed, the
+    -- spaceHtml is a minor hack and does upset the layout a fraction.
+
+    htmlModule =
+      thespan
+        ! modAttrs
+        << ( cBtn
+              +++ case leaf of
+                Just m -> ppModule m
+                Nothing -> toHtml s
+           )
+
+    shortDescr = maybe noHtml (origDocToHtml pkg qual) short
+    htmlPkg = maybe noHtml (thespan ! [theclass "package"] <<) srcPkg
+
+    subtree =
+      if null ts
+        then noHtml
+        else
+          collapseDetails
+            p
+            DetailsOpen
+            ( thesummary
+                ! [theclass "hide-when-js-enabled"]
+                << "Submodules"
+                +++ mkNodeList pkg qual (s : ss) p ts
+            )
+
+--------------------------------------------------------------------------------
+
+-- * Generate the index
+
+--------------------------------------------------------------------------------
+
+data JsonIndexEntry = JsonIndexEntry
+  { jieHtmlFragment :: String
+  , jieName :: String
+  , jieModule :: String
+  , jieLink :: String
+  }
+  deriving (Show)
+
+instance ToJSON JsonIndexEntry where
+  toJSON
+    JsonIndexEntry
+      { jieHtmlFragment
+      , jieName
+      , jieModule
+      , jieLink
+      } =
+      Object
+        [ "display_html" .= String jieHtmlFragment
+        , "name" .= String jieName
+        , "module" .= String jieModule
+        , "link" .= String jieLink
+        ]
+
+instance FromJSON JsonIndexEntry where
+  parseJSON = withObject "JsonIndexEntry" $ \v ->
+    JsonIndexEntry
+      <$> v .: "display_html"
+      <*> v .: "name"
+      <*> v .: "module"
+      <*> v .: "link"
+
+ppJsonIndex
+  :: FilePath
+  -> SourceURLs
+  -- ^ The source URL (--source)
+  -> WikiURLs
+  -- ^ The wiki URL (--wiki)
+  -> Bool
+  -> Maybe Package
+  -> QualOption
+  -> [Interface]
+  -> [FilePath]
+  -- ^ file paths to interface files
+  -- (--read-interface)
+  -> IO ()
+ppJsonIndex odir maybe_source_url maybe_wiki_url unicode pkg qual_opt ifaces installedIfacesPaths = do
+  createDirectoryIfMissing True odir
+  (errors, installedIndexes) <-
+    partitionEithers
+      <$> traverse
+        ( \ifaceFile -> do
+            let indexFile =
+                  takeDirectory ifaceFile
+                    FilePath.</> "doc-index.json"
+            a <- doesFileExist indexFile
+            if a
+              then
+                bimap (indexFile,) (map (fixLink ifaceFile))
+                  <$> eitherDecodeFile @[JsonIndexEntry] indexFile
+              else return (Right [])
+        )
+        installedIfacesPaths
+  traverse_
+    (\(indexFile, err) -> putStrLn $ "haddock: Coudn't parse " ++ indexFile ++ ": " ++ err)
+    errors
+  IO.withBinaryFile (joinPath [odir, indexJsonFile]) IO.WriteMode $ \h ->
+    Builder.hPutBuilder
+      h
+      (encodeToBuilder (encodeIndexes (concat installedIndexes)))
+  where
+    encodeIndexes :: [JsonIndexEntry] -> Value
+    encodeIndexes installedIndexes =
+      toJSON
+        ( concatMap fromInterface ifaces
+            ++ installedIndexes
+        )
+
+    fromInterface :: Interface -> [JsonIndexEntry]
+    fromInterface iface =
+      mkIndex mdl qual `mapMaybe` ifaceRnExportItems iface
+      where
+        qual = makeModuleQual qual_opt mdl
+        mdl = ifaceMod iface
+
+    mkIndex :: Module -> Qualification -> ExportItem DocNameI -> Maybe JsonIndexEntry
+    mkIndex mdl qual item
+      | Just item_html <- processExport True links_info unicode pkg qual item =
+          Just
+            JsonIndexEntry
+              { jieHtmlFragment = showHtmlFragment item_html
+              , jieName = unwords (map getOccString names)
+              , jieModule = moduleString mdl
+              , jieLink = fromMaybe "" (listToMaybe (map (nameLink mdl) names))
+              }
+      | otherwise = Nothing
+      where
+        names = exportName item ++ exportSubs item
+
+    exportSubs :: ExportItem DocNameI -> [IdP DocNameI]
+    exportSubs (ExportDecl (RnExportD{rnExpDExpD = ExportD{expDSubDocs}})) = map fst expDSubDocs
+    exportSubs _ = []
+
+    exportName :: ExportItem DocNameI -> [IdP DocNameI]
+    exportName (ExportDecl (RnExportD{rnExpDExpD = ExportD{expDDecl}})) = getMainDeclBinderI (unLoc expDDecl)
+    exportName ExportNoDecl{expItemName} = [expItemName]
+    exportName _ = []
+
+    nameLink :: NamedThing name => Module -> name -> String
+    nameLink mdl = moduleNameUrl' (moduleName mdl) . nameOccName . getName
+
+    links_info = (maybe_source_url, maybe_wiki_url)
+
+    -- update link using relative path to output directory
+    fixLink
+      :: FilePath
+      -> JsonIndexEntry
+      -> JsonIndexEntry
+    fixLink ifaceFile jie =
+      jie
+        { jieLink =
+            makeRelative odir (takeDirectory ifaceFile)
+              FilePath.</> jieLink jie
+        }
+
+ppHtmlIndex
+  :: FilePath
+  -> String
+  -> Maybe String
+  -> Themes
+  -> Maybe String
+  -> Maybe String
+  -> SourceURLs
+  -> WikiURLs
+  -> Bool
+  -- ^ With Quick Jump?
+  -> [InstalledInterface]
+  -> Bool
+  -> IO ()
+ppHtmlIndex
+  odir
+  doctitle
+  _maybe_package
+  themes
+  maybe_mathjax_url
+  maybe_contents_url
+  maybe_source_url
+  maybe_wiki_url
+  withQuickjump
+  ifaces
+  debug = do
+    let html =
+          indexPage
+            split_indices
+            Nothing
+            (if split_indices then [] else index)
+
+    createDirectoryIfMissing True odir
+
+    when split_indices $ do
+      mapM_ (do_sub_index index) initialChars
+      -- Let's add a single large index as well for those who don't know exactly what they're looking for:
+      let mergedhtml = indexPage False Nothing index
+      writeUtf8File (joinPath [odir, subIndexHtmlFile merged_name]) (renderToString debug mergedhtml)
+
+    writeUtf8File (joinPath [odir, indexHtmlFile]) (renderToString debug html)
+    where
+      indexPage showLetters ch items =
+        headHtml (doctitle ++ " (" ++ indexName ch ++ ")") themes maybe_mathjax_url Nothing
+          +++ bodyHtml
+            doctitle
+            Nothing
+            maybe_source_url
+            maybe_wiki_url
+            maybe_contents_url
+            Nothing
+            withQuickjump
+          << [ if showLetters then indexInitialLetterLinks else noHtml
+             , if null items
+                then noHtml
+                else divIndex << [sectionName << indexName ch, buildIndex items]
+             ]
+
+      indexName ch = "Index" ++ maybe "" (\c -> " - " ++ [c]) ch
+      merged_name = "All"
+
+      buildIndex items = table << aboves (map indexElt items)
+
+      -- an arbitrary heuristic:
+      -- too large, and a single-page will be slow to load
+      -- too small, and we'll have lots of letter-indexes with only one
+      --   or two members in them, which seems inefficient or
+      --   unnecessarily hard to use.
+      split_indices = length index > 150
+
+      indexInitialLetterLinks =
+        divAlphabet
+          << unordList
+            ( map (\str -> anchor ! [href (subIndexHtmlFile str)] << str) $
+                [ [c] | c <- initialChars, any ((== c) . toUpper . head . fst) index
+                ]
+                  ++ [merged_name]
+            )
+
+      -- todo: what about names/operators that start with Unicode
+      -- characters?
+      -- Exports beginning with '_' can be listed near the end,
+      -- presumably they're not as important... but would be listed
+      -- with non-split index!
+      initialChars = ['A' .. 'Z'] ++ ":!#$%&*+./<=>?@\\^|-~" ++ "_"
+
+      do_sub_index this_ix c =
+        unless (null index_part) $
+          writeUtf8File (joinPath [odir, subIndexHtmlFile [c]]) (renderToString debug html)
+        where
+          html = indexPage True (Just c) index_part
+          index_part = [(n, stuff) | (n, stuff) <- this_ix, toUpper (head n) == c]
+
+      index :: [(String, Map GHC.Name [(Module, Bool)])]
+      index = sortBy cmp (Map.toAscList full_index)
+        where
+          cmp (n1, _) (n2, _) = comparing (map toUpper) n1 n2
+
+      -- for each name (a plain string), we have a number of original HsNames that
+      -- it can refer to, and for each of those we have a list of modules
+      -- that export that entity.  Each of the modules exports the entity
+      -- in a visible or invisible way (hence the Bool).
+      full_index :: Map String (Map GHC.Name [(Module, Bool)])
+      full_index = foldl' f Map.empty ifaces
+        where
+          f
+            :: Map String (Map Name [(Module, Bool)])
+            -> InstalledInterface
+            -> Map String (Map Name [(Module, Bool)])
+          f !idx iface =
+            Map.unionWith
+              (Map.unionWith (\a b -> let !x = force $ a ++ b in x))
+              idx
+              (getIfaceIndex iface)
+
+      getIfaceIndex :: InstalledInterface -> Map String (Map Name [(Module, Bool)])
+      getIfaceIndex iface =
+        foldl' f Map.empty (instExports iface)
+        where
+          f
+            :: Map String (Map Name [(Module, Bool)])
+            -> Name
+            -> Map String (Map Name [(Module, Bool)])
+          f !idx name =
+            let !vis = name `Set.member` visible
+             in Map.insertWith
+                  (Map.unionWith (++))
+                  (getOccString name)
+                  (Map.singleton name [(mdl, vis)])
+                  idx
+
+          mdl = instMod iface
+          visible = Set.fromList (instVisibleExports iface)
+
+      indexElt :: (String, Map GHC.Name [(Module, Bool)]) -> HtmlTable
+      indexElt (str, entities) =
+        case Map.toAscList entities of
+          [(nm, entries)] ->
+            td
+              ! [theclass "src"]
+              << toHtml str
+              <-> indexLinks nm entries
+          many_entities ->
+            td
+              ! [theclass "src"]
+              << toHtml str
+              <-> td
+              << spaceHtml
+              </> aboves (zipWith (curry doAnnotatedEntity) [1 ..] many_entities)
+
+      doAnnotatedEntity :: (Integer, (Name, [(Module, Bool)])) -> HtmlTable
+      doAnnotatedEntity (j, (nm, entries)) =
+        td
+          ! [theclass "alt"]
+          << toHtml (show j)
+          <+> parens (ppAnnot (nameOccName nm))
+          <-> indexLinks nm entries
+
+      ppAnnot n
+        | not (isValOcc n) = toHtml "Type/Class"
+        | isDataOcc n = toHtml "Data Constructor"
+        | otherwise = toHtml "Function"
+
+      indexLinks nm entries =
+        td
+          ! [theclass "module"]
+          << hsep
+            ( punctuate
+                comma
+                [ if visible
+                  then linkId mdl (Just nm) << toHtml (moduleString mdl)
+                  else toHtml (moduleString mdl)
+                | (mdl, visible) <- entries
+                ]
+            )
+
+--------------------------------------------------------------------------------
+
+-- * Generate the HTML page for a module
+
+--------------------------------------------------------------------------------
+
+ppHtmlModule
+  :: FilePath
+  -> String
+  -> Themes
+  -> Maybe String
+  -> SourceURLs
+  -> WikiURLs
+  -> BaseURL
+  -> Maybe String
+  -> Maybe String
+  -> Bool
+  -- ^ With Quick Jump?
+  -> Bool
+  -> Maybe Package
+  -> QualOption
+  -> Bool
+  -> Interface
+  -> IO ()
+ppHtmlModule
+  odir
+  doctitle
+  themes
+  maybe_mathjax_url
+  maybe_source_url
+  maybe_wiki_url
+  maybe_base_url
+  maybe_contents_url
+  maybe_index_url
+  withQuickjump
+  unicode
+  pkg
+  qual
+  debug
+  iface = do
+    let
+      mdl = ifaceMod iface
+      mdl_str = moduleString mdl
+      mdl_str_annot =
+        mdl_str
+          ++ if ifaceIsSig iface
+            then " (signature)"
+            else ""
+      mdl_str_linked
+        | ifaceIsSig iface =
+            mdl_str
+              +++ " (signature"
+              +++ sup
+              << ("[" +++ anchor ! [href signatureDocURL] << "?" +++ "]")
+              +++ ")"
+        | otherwise =
+            toHtml mdl_str
+      real_qual = makeModuleQual qual mdl
+      html =
+        headHtml mdl_str_annot themes maybe_mathjax_url maybe_base_url
+          +++ bodyHtml
+            doctitle
+            (Just iface)
+            maybe_source_url
+            maybe_wiki_url
+            maybe_contents_url
+            maybe_index_url
+            withQuickjump
+          << [ divModuleHeader << (moduleInfo iface +++ (sectionName << mdl_str_linked))
+             , ifaceToHtml maybe_source_url maybe_wiki_url iface unicode pkg real_qual
+             ]
+
+    createDirectoryIfMissing True odir
+    writeUtf8File (joinPath [odir, moduleHtmlFile mdl]) (renderToString debug html)
+
+signatureDocURL :: String
+signatureDocURL = "https://wiki.haskell.org/Module_signature"
+
+ifaceToHtml :: SourceURLs -> WikiURLs -> Interface -> Bool -> Maybe Package -> Qualification -> Html
+ifaceToHtml maybe_source_url maybe_wiki_url iface unicode pkg qual =
+  ppModuleContents pkg qual exports (not . null $ ifaceRnOrphanInstances iface)
+    +++ description
+    +++ synopsis
+    +++ divInterface (maybe_doc_hdr +++ bdy +++ orphans)
+  where
+    exports = numberSectionHeadings (ifaceRnExportItems iface)
+
+    -- todo: if something has only sub-docs, or fn-args-docs, should
+    -- it be measured here and thus prevent omitting the synopsis?
+    has_doc
+      ( ExportDecl
+          ( RnExportD
+              { rnExpDExpD =
+                ExportD
+                  { expDMbDoc =
+                    (Documentation mDoc mWarn, _)
+                  }
+              }
+            )
+        ) = isJust mDoc || isJust mWarn
+    has_doc (ExportNoDecl _ _) = False
+    has_doc (ExportModule _) = False
+    has_doc _ = True
+
+    no_doc_at_all = not (any has_doc exports)
+
+    description
+      | isNoHtml doc = doc
+      | otherwise = divDescription $ sectionName << "Description" +++ doc
+      where
+        doc = docSection Nothing pkg qual (ifaceRnDoc iface)
+
+    -- omit the synopsis if there are no documentation annotations at all
+    synopsis
+      | no_doc_at_all = noHtml
+      | otherwise =
+          divSynopsis $
+            collapseDetails
+              "syn"
+              DetailsClosed
+              ( thesummary
+                  << "Synopsis"
+                  +++ shortDeclList
+                    ( mapMaybe (processExport True linksInfo unicode pkg qual) exports
+                    )
+                  ! collapseToggle "syn" ""
+              )
+
+    -- if the documentation doesn't begin with a section header, then
+    -- add one ("Documentation").
+    maybe_doc_hdr =
+      case exports of
+        [] -> noHtml
+        ExportGroup{} : _ -> noHtml
+        _ -> h1 << "Documentation"
+
+    bdy =
+      foldr (+++) noHtml $
+        mapMaybe (processExport False linksInfo unicode pkg qual) exports
+
+    orphans =
+      ppOrphanInstances linksInfo (ifaceRnOrphanInstances iface) False unicode pkg qual
+
+    linksInfo = (maybe_source_url, maybe_wiki_url)
+
+ppModuleContents
+  :: Maybe Package
+  -- ^ This package
+  -> Qualification
+  -> [ExportItem DocNameI]
+  -> Bool
+  -- ^ Orphans sections
+  -> Html
+ppModuleContents pkg qual exports orphan
+  | null sections && not orphan = noHtml
+  | otherwise = contentsDiv
+  where
+    contentsDiv =
+      divTableOfContents
+        << ( divContentsList
+              << ( (sectionName << "Contents")
+                    ! [strAttr "onclick" "window.scrollTo(0,0)"]
+                    +++ unordList (sections ++ orphanSection)
+                 )
+           )
+
+    (sections, _leftovers {-should be []-}) = process 0 exports
+    orphanSection
+      | orphan = [linkedAnchor "section.orphans" << "Orphan instances"]
+      | otherwise = []
+
+    process :: Int -> [ExportItem DocNameI] -> ([Html], [ExportItem DocNameI])
+    process _ [] = ([], [])
+    process n items@(ExportGroup lev id0 doc : rest)
+      | lev <= n = ([], items)
+      | otherwise = (html : secs, rest2)
+      where
+        html =
+          linkedAnchor (groupId id0)
+            << docToHtmlNoAnchors (Just id0) pkg qual (mkMeta doc)
+            +++ mk_subsections ssecs
+        (ssecs, rest1) = process lev rest
+        (secs, rest2) = process n rest1
+    process n (_ : rest) = process n rest
+
+    mk_subsections [] = noHtml
+    mk_subsections ss = unordList ss
+
+-- we need to assign a unique id to each section heading so we can hyperlink
+-- them from the contents:
+numberSectionHeadings :: [ExportItem DocNameI] -> [ExportItem DocNameI]
+numberSectionHeadings = go 1
+  where
+    go :: Int -> [ExportItem DocNameI] -> [ExportItem DocNameI]
+    go _ [] = []
+    go n (ExportGroup lev _ doc : es) =
+      case collectAnchors doc of
+        [] -> ExportGroup lev (show n) doc : go (n + 1) es
+        (a : _) -> ExportGroup lev a doc : go (n + 1) es
+    go n (other : es) =
+      other : go n es
+
+    collectAnchors :: DocH (Wrap (ModuleName, OccName)) (Wrap DocName) -> [String]
+    collectAnchors (DocAppend a b) = collectAnchors a ++ collectAnchors b
+    collectAnchors (DocAName a) = [a]
+    collectAnchors _ = []
+
+processExport
+  :: Bool
+  -> LinksInfo
+  -> Bool
+  -> Maybe Package
+  -> Qualification
+  -> ExportItem DocNameI
+  -> Maybe Html
+processExport
+  _
+  _
+  _
+  _
+  _
+  ( ExportDecl
+      ( RnExportD
+          { rnExpDExpD =
+            ExportD
+              { expDDecl = L _ (InstD{})
+              }
+          }
+        )
+    ) =
+    Nothing -- Hide empty instances
+processExport
+  summary
+  links
+  unicode
+  pkg
+  qual
+  ( ExportDecl
+      ( RnExportD
+          { rnExpDExpD =
+            ExportD decl pats doc subdocs insts fixities splice
+          }
+        )
+    ) =
+    processDecl summary $ ppDecl summary links decl pats doc insts fixities subdocs splice unicode pkg qual
+processExport summary _ _ pkg qual (ExportGroup lev id0 doc) =
+  nothingIf summary $ groupHeading lev id0 << docToHtmlNoAnchors (Just id0) pkg qual (mkMeta doc)
+processExport summary _ _ _ qual (ExportNoDecl y []) =
+  processDeclOneLiner summary $ ppDocName qual Prefix True y
+processExport summary _ _ _ qual (ExportNoDecl y subs) =
+  processDeclOneLiner summary $
+    ppDocName qual Prefix True y
+      +++ parenList (map (ppDocName qual Prefix True) subs)
+processExport summary _ _ pkg qual (ExportDoc doc) =
+  nothingIf summary $ docSection_ Nothing pkg qual doc
+processExport summary _ _ _ _ (ExportModule mdl) =
+  processDeclOneLiner summary $ toHtml "module" <+> ppModule mdl
+
+nothingIf :: Bool -> a -> Maybe a
+nothingIf True _ = Nothing
+nothingIf False a = Just a
+
+processDecl :: Bool -> Html -> Maybe Html
+processDecl True = Just
+processDecl False = Just . divTopDecl
+
+trim :: String -> String
+trim = f . f
+  where
+    f = reverse . dropWhile isSpace
+
+processDeclOneLiner :: Bool -> Html -> Maybe Html
+processDeclOneLiner True = Just
+processDeclOneLiner False = Just . divTopDecl . declElem
+
+groupHeading :: Int -> String -> Html -> Html
+groupHeading lev id0 = linkedAnchor grpId . groupTag lev ! [identifier grpId]
+  where
+    grpId = groupId id0
+
+groupTag :: Int -> Html -> Html
+groupTag lev
+  | lev == 1 = h1
+  | lev == 2 = h2
+  | lev == 3 = h3
+  | otherwise = h4
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
new file mode 100644
index 0000000000000000000000000000000000000000..81f9f1e587e595476ba3953e736d4729b3304691
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
@@ -0,0 +1,1858 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE Rank2Types #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE TransformListComp #-}
+{-# LANGUAGE TypeFamilies #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.Html.Decl
+-- Copyright   :  (c) Simon Marlow   2003-2006,
+--                    David Waern    2006-2009,
+--                    Mark Lentczner 2010
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.Xhtml.Decl
+  ( ppDecl
+  , ppOrphanInstances
+  ) where
+
+import Haddock.Backends.Xhtml.DocMarkup
+import Haddock.Backends.Xhtml.Layout
+import Haddock.Backends.Xhtml.Names
+import Haddock.Backends.Xhtml.Types
+import Haddock.Backends.Xhtml.Utils
+import Haddock.Doc (combineDocumentation)
+import Haddock.GhcUtils
+import Haddock.Types
+
+import Data.Foldable (toList)
+import Data.List (intersperse, sort)
+import Data.List.NonEmpty (NonEmpty (..))
+import qualified Data.Map as Map
+import Data.Maybe
+import Text.XHtml hiding (name, p, quote, title)
+
+import GHC hiding (LexicalFixity (..), fromMaybeContext)
+import GHC.Core.Type (Specificity (..))
+import GHC.Data.BooleanFormula
+import GHC.Exts hiding (toList)
+import GHC.Types.Name
+import GHC.Types.Name.Reader (rdrNameOcc)
+
+-- | Pretty print a declaration
+ppDecl
+  :: Bool
+  -- ^ print summary info only
+  -> LinksInfo
+  -- ^ link information
+  -> LHsDecl DocNameI
+  -- ^ declaration to print
+  -> [(HsDecl DocNameI, DocForDecl DocName)]
+  -- ^ relevant pattern synonyms
+  -> DocForDecl DocName
+  -- ^ documentation for this decl
+  -> [DocInstance DocNameI]
+  -- ^ relevant instances
+  -> [(DocName, Fixity)]
+  -- ^ relevant fixities
+  -> [(DocName, DocForDecl DocName)]
+  -- ^ documentation for all decls
+  -> Splice
+  -> Unicode
+  -- ^ unicode output
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppDecl summ links (L loc decl) pats (mbDoc, fnArgsDoc) instances fixities subdocs splice unicode pkg qual = case decl of
+  TyClD _ (FamDecl _ d) -> ppFamDecl summ False links instances fixities (locA loc) mbDoc d splice unicode pkg qual
+  TyClD _ d@(DataDecl{}) -> ppDataDecl summ links instances fixities subdocs (locA loc) mbDoc d pats splice unicode pkg qual
+  TyClD _ d@(SynDecl{}) -> ppTySyn summ links fixities (locA loc) (mbDoc, fnArgsDoc) d splice unicode pkg qual
+  TyClD _ d@(ClassDecl{}) -> ppClassDecl summ links instances fixities (locA loc) mbDoc subdocs d splice unicode pkg qual
+  SigD _ (TypeSig _ lnames lty) ->
+    ppLFunSig
+      summ
+      links
+      (locA loc)
+      (mbDoc, fnArgsDoc)
+      lnames
+      (dropWildCards lty)
+      fixities
+      splice
+      unicode
+      pkg
+      qual
+  SigD _ (PatSynSig _ lnames lty) ->
+    ppLPatSig
+      summ
+      links
+      (locA loc)
+      (mbDoc, fnArgsDoc)
+      lnames
+      lty
+      fixities
+      splice
+      unicode
+      pkg
+      qual
+  ForD _ d -> ppFor summ links (locA loc) (mbDoc, fnArgsDoc) d fixities splice unicode pkg qual
+  InstD _ _ -> noHtml
+  DerivD _ _ -> noHtml
+  _ -> error "declaration not supported by ppDecl"
+
+ppLFunSig
+  :: Bool
+  -> LinksInfo
+  -> SrcSpan
+  -> DocForDecl DocName
+  -> [LocatedN DocName]
+  -> LHsSigType DocNameI
+  -> [(DocName, Fixity)]
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppLFunSig summary links loc doc lnames lty fixities splice unicode pkg qual =
+  ppFunSig
+    summary
+    links
+    loc
+    noHtml
+    doc
+    (map unLoc lnames)
+    lty
+    fixities
+    splice
+    unicode
+    pkg
+    qual
+
+ppFunSig
+  :: Bool
+  -> LinksInfo
+  -> SrcSpan
+  -> Html
+  -> DocForDecl DocName
+  -> [DocName]
+  -> LHsSigType DocNameI
+  -> [(DocName, Fixity)]
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppFunSig summary links loc leader doc docnames typ fixities splice unicode pkg qual =
+  ppSigLike
+    summary
+    links
+    loc
+    leader
+    doc
+    docnames
+    fixities
+    (unLoc typ, pp_typ)
+    splice
+    unicode
+    pkg
+    qual
+    HideEmptyContexts
+  where
+    pp_typ = ppLSigType unicode qual HideEmptyContexts typ
+
+-- | Pretty print a pattern synonym
+ppLPatSig
+  :: Bool
+  -> LinksInfo
+  -> SrcSpan
+  -> DocForDecl DocName
+  -> [LocatedN DocName]
+  -- ^ names of patterns in declaration
+  -> LHsSigType DocNameI
+  -- ^ type of patterns in declaration
+  -> [(DocName, Fixity)]
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppLPatSig summary links loc doc lnames typ fixities splice unicode pkg qual =
+  ppSigLike
+    summary
+    links
+    loc
+    (keyword "pattern")
+    doc
+    (map unLoc lnames)
+    fixities
+    (unLoc typ, pp_typ)
+    splice
+    unicode
+    pkg
+    qual
+    (patSigContext typ)
+  where
+    pp_typ = ppPatSigType unicode qual typ
+
+ppSigLike
+  :: Bool
+  -> LinksInfo
+  -> SrcSpan
+  -> Html
+  -> DocForDecl DocName
+  -> [DocName]
+  -> [(DocName, Fixity)]
+  -> (HsSigType DocNameI, Html)
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> HideEmptyContexts
+  -> Html
+ppSigLike
+  summary
+  links
+  loc
+  leader
+  doc
+  docnames
+  fixities
+  (typ, pp_typ)
+  splice
+  unicode
+  pkg
+  qual
+  emptyCtxts =
+    ppTypeOrFunSig
+      summary
+      links
+      loc
+      docnames
+      typ
+      doc
+      ( addFixities $ leader <+> ppTypeSig summary occnames pp_typ unicode
+      , (leader <+>) . addFixities . concatHtml . punctuate comma $ map (ppBinder False) occnames
+      , dcolon unicode
+      )
+      splice
+      unicode
+      pkg
+      qual
+      emptyCtxts
+    where
+      occnames = map (nameOccName . getName) docnames
+      addFixities html
+        | summary = html
+        | otherwise = html <+> ppFixities fixities qual
+
+ppTypeOrFunSig
+  :: Bool
+  -> LinksInfo
+  -> SrcSpan
+  -> [DocName]
+  -> HsSigType DocNameI
+  -> DocForDecl DocName
+  -> (Html, Html, Html)
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> HideEmptyContexts
+  -> Html
+ppTypeOrFunSig
+  summary
+  links
+  loc
+  docnames
+  typ
+  (doc, argDocs)
+  (pref1, pref2, sep)
+  splice
+  unicode
+  pkg
+  qual
+  emptyCtxts
+    | summary = pref1
+    | Map.null argDocs = topDeclElem links loc splice docnames pref1 +++ docSection curname pkg qual doc
+    | otherwise =
+        topDeclElem links loc splice docnames pref2
+          +++ subArguments pkg qual (ppSubSigLike unicode qual typ argDocs [] sep emptyCtxts)
+          +++ docSection curname pkg qual doc
+    where
+      curname = getName <$> listToMaybe docnames
+
+-- | This splits up a type signature along @->@ and adds docs (when they exist)
+-- to the arguments.
+--
+-- If one passes in a list of the available subdocs, any top-level `HsRecTy`
+-- found will be expanded out into their fields.
+ppSubSigLike
+  :: Unicode
+  -> Qualification
+  -> HsSigType DocNameI
+  -- ^ type signature
+  -> FnArgsDoc DocName
+  -- ^ docs to add
+  -> [(DocName, DocForDecl DocName)]
+  -- ^ all subdocs (useful when
+  -- we expand an `HsRecTy`)
+  -> Html
+  -> HideEmptyContexts
+  -> [SubDecl]
+ppSubSigLike unicode qual typ argDocs subdocs sep emptyCtxts = do_sig_args 0 sep typ
+  where
+    do_sig_args :: Int -> Html -> HsSigType DocNameI -> [SubDecl]
+    do_sig_args n leader (HsSig{sig_bndrs = outer_bndrs, sig_body = ltype}) =
+      case outer_bndrs of
+        HsOuterExplicit{hso_bndrs = bndrs} -> do_largs n (leader' bndrs) ltype
+        HsOuterImplicit{} -> do_largs n leader ltype
+      where
+        leader' bndrs = leader <+> ppForAllPart unicode qual (mkHsForAllInvisTeleI bndrs)
+
+    argDoc n = Map.lookup n argDocs
+
+    do_largs :: Int -> Html -> LHsType DocNameI -> [SubDecl]
+    do_largs n leader (L _ t) = do_args n leader t
+
+    do_args :: Int -> Html -> HsType DocNameI -> [SubDecl]
+    do_args n leader (HsForAllTy _ tele ltype) =
+      do_largs n leader' ltype
+      where
+        leader' = leader <+> ppForAllPart unicode qual tele
+    do_args n leader (HsQualTy _ lctxt ltype)
+      | null (unLoc lctxt) =
+          do_largs n leader ltype
+      | otherwise =
+          (leader <+> ppLContextNoArrow lctxt unicode qual emptyCtxts, Nothing, [])
+            : do_largs n (darrow unicode) ltype
+    do_args n leader (HsFunTy _ _w (L _ (HsRecTy _ fields)) r) =
+      [ (ldr <+> html, mdoc, subs)
+      | (L _ field, ldr) <- zip fields (leader <+> gadtOpen : repeat gadtComma)
+      , let (html, mdoc, subs) = ppSideBySideField subdocs unicode qual field
+      ]
+        ++ do_largs (n + 1) (gadtEnd <+> arrow unicode) r
+    do_args n leader (HsFunTy _ _w lt r) =
+      (leader <+> ppLFunLhType unicode qual emptyCtxts lt, argDoc n, [])
+        : do_largs (n + 1) (arrow unicode) r
+    do_args n leader t =
+      [(leader <+> ppType unicode qual emptyCtxts t, argDoc n, [])]
+
+    -- FIXME: this should be done more elegantly
+    --
+    -- We need 'gadtComma' and 'gadtEnd' to line up with the `{` from
+    -- 'gadtOpen', so we add 3 spaces to cover for `-> `/`:: ` (3 in unicode
+    -- mode since `->` and `::` are rendered as single characters.
+    gadtComma = concatHtml (replicate (if unicode then 2 else 3) spaceHtml) <> toHtml ","
+    gadtEnd = concatHtml (replicate (if unicode then 2 else 3) spaceHtml) <> toHtml "}"
+    gadtOpen = toHtml "{"
+
+ppFixities :: [(DocName, Fixity)] -> Qualification -> Html
+ppFixities [] _ = noHtml
+ppFixities fs qual = foldr1 (+++) (map ppFix uniq_fs) +++ rightEdge
+  where
+    ppFix (ns, p, d) =
+      thespan
+        ! [theclass "fixity"]
+        << (toHtml d <+> toHtml (show p) <+> ppNames ns)
+
+    ppDir InfixR = "infixr"
+    ppDir InfixL = "infixl"
+    ppDir InfixN = "infix"
+
+    ppNames = case fs of
+      _ : [] -> const noHtml -- Don't display names for fixities on single names
+      _ -> concatHtml . intersperse (stringToHtml ", ") . map (ppDocName qual Infix False)
+
+    uniq_fs =
+      [ (n, the p, the d')
+      | (n, Fixity _ p d) <- fs
+      , let d' = ppDir d
+      , then group by
+          Down (p, d')
+        using
+          groupWith
+      ]
+
+    rightEdge = thespan ! [theclass "rightedge"] << noHtml
+
+-- | Pretty-print type variables.
+ppTyVars
+  :: RenderableBndrFlag flag
+  => Unicode
+  -> Qualification
+  -> [LHsTyVarBndr flag DocNameI]
+  -> [Html]
+ppTyVars unicode qual tvs = map (ppHsTyVarBndr unicode qual . unLoc) tvs
+
+ppFor
+  :: Bool
+  -> LinksInfo
+  -> SrcSpan
+  -> DocForDecl DocName
+  -> ForeignDecl DocNameI
+  -> [(DocName, Fixity)]
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppFor
+  summary
+  links
+  loc
+  doc
+  (ForeignImport _ (L _ name) typ _)
+  fixities
+  splice
+  unicode
+  pkg
+  qual =
+    ppFunSig summary links loc noHtml doc [name] typ fixities splice unicode pkg qual
+ppFor _ _ _ _ _ _ _ _ _ _ = error "ppFor"
+
+-- we skip type patterns for now
+ppTySyn
+  :: Bool
+  -> LinksInfo
+  -> [(DocName, Fixity)]
+  -> SrcSpan
+  -> DocForDecl DocName
+  -> TyClDecl DocNameI
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppTySyn
+  summary
+  links
+  fixities
+  loc
+  doc
+  ( SynDecl
+      { tcdLName = L _ name
+      , tcdTyVars = ltyvars
+      , tcdRhs = ltype
+      }
+    )
+  splice
+  unicode
+  pkg
+  qual =
+    ppTypeOrFunSig
+      summary
+      links
+      loc
+      [name]
+      sig_type
+      doc
+      (full <+> fixs, hdr <+> fixs, spaceHtml +++ equals)
+      splice
+      unicode
+      pkg
+      qual
+      ShowEmptyToplevelContexts
+    where
+      sig_type = mkHsImplicitSigTypeI ltype
+      hdr =
+        hsep
+          ( [keyword "type", ppBinder summary occ]
+              ++ ppTyVars unicode qual (hsQTvExplicit ltyvars)
+          )
+      full = hdr <+> equals <+> ppPatSigType unicode qual (noLocA sig_type)
+      occ = nameOccName . getName $ name
+      fixs
+        | summary = noHtml
+        | otherwise = ppFixities fixities qual
+ppTySyn _ _ _ _ _ _ _ _ _ _ = error "declaration not supported by ppTySyn"
+
+ppTypeSig :: Bool -> [OccName] -> Html -> Unicode -> Html
+ppTypeSig summary nms pp_ty unicode =
+  concatHtml htmlNames <+> dcolon unicode <+> pp_ty
+  where
+    htmlNames = intersperse (stringToHtml ", ") $ map (ppBinder summary) nms
+
+ppSimpleSig
+  :: LinksInfo
+  -> Splice
+  -> Unicode
+  -> Qualification
+  -> HideEmptyContexts
+  -> SrcSpan
+  -> [DocName]
+  -> HsSigType DocNameI
+  -> Html
+ppSimpleSig links splice unicode qual emptyCtxts loc names typ =
+  topDeclElem' names $ ppTypeSig True occNames ppTyp unicode
+  where
+    topDeclElem' = topDeclElem links loc splice
+    ppTyp = ppSigType unicode qual emptyCtxts typ
+    occNames = map getOccName names
+
+--------------------------------------------------------------------------------
+
+-- * Type families
+
+--------------------------------------------------------------------------------
+
+-- | Print a data\/type family declaration
+ppFamDecl
+  :: Bool
+  -- ^ is a summary
+  -> Bool
+  -- ^ is an associated type
+  -> LinksInfo
+  -> [DocInstance DocNameI]
+  -- ^ relevant instances
+  -> [(DocName, Fixity)]
+  -- ^ relevant fixities
+  -> SrcSpan
+  -> Documentation DocName
+  -- ^ this decl's documentation
+  -> FamilyDecl DocNameI
+  -- ^ this decl
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppFamDecl summary associated links instances fixities loc doc decl splice unicode pkg qual
+  | summary = ppFamHeader True associated decl unicode qual
+  | otherwise = header_ +++ docSection curname pkg qual doc +++ instancesBit
+  where
+    docname = unLoc $ fdLName decl
+    curname = Just $ getName docname
+
+    header_ =
+      topDeclElem links loc splice [docname] $
+        ppFamHeader summary associated decl unicode qual <+> ppFixities fixities qual
+
+    instancesBit
+      | FamilyDecl{fdInfo = ClosedTypeFamily mb_eqns} <- decl
+      , not summary =
+          subEquations pkg qual $ map (ppFamDeclEqn . unLoc) $ fromMaybe [] mb_eqns
+      | otherwise =
+          ppInstances links (OriginFamily docname) instances splice unicode pkg qual
+
+    -- Individual equation of a closed type family
+    ppFamDeclEqn :: TyFamInstEqn DocNameI -> SubDecl
+    ppFamDeclEqn
+      ( FamEqn
+          { feqn_tycon = L _ n
+          , feqn_rhs = rhs
+          , feqn_pats = ts
+          }
+        ) =
+        ( ppAppNameTypeArgs n ts unicode qual
+            <+> equals
+            <+> ppType unicode qual HideEmptyContexts (unLoc rhs)
+        , Nothing
+        , []
+        )
+
+-- | Print the LHS of a type\/data family declaration
+ppFamHeader
+  :: Bool
+  -- ^ is a summary
+  -> Bool
+  -- ^ is an associated type
+  -> FamilyDecl DocNameI
+  -- ^ family declaration
+  -> Unicode
+  -> Qualification
+  -> Html
+ppFamHeader
+  summary
+  associated
+  ( FamilyDecl
+      { fdInfo = info
+      , fdResultSig = L _ result
+      , fdInjectivityAnn = injectivity
+      , fdLName = L _ name
+      , fdTyVars = tvs
+      }
+    )
+  unicode
+  qual =
+    hsep
+      [ ppFamilyLeader associated info
+      , ppAppDocNameTyVarBndrs summary unicode qual name (hsq_explicit tvs)
+      , ppResultSig result unicode qual
+      , injAnn
+      , whereBit
+      ]
+    where
+      whereBit = case info of
+        ClosedTypeFamily _ -> keyword "where ..."
+        _ -> noHtml
+
+      injAnn = case injectivity of
+        Nothing -> noHtml
+        Just (L _ (InjectivityAnn _ lhs rhs)) ->
+          hsep
+            ( keyword "|"
+                : ppLDocName qual Raw lhs
+                : arrow unicode
+                : map (ppLDocName qual Raw) rhs
+            )
+        Just _ -> error "ppFamHeader:XInjectivityAnn"
+
+-- | Print the keywords that begin the family declaration
+ppFamilyLeader :: Bool -> FamilyInfo DocNameI -> Html
+ppFamilyLeader assoc info = keyword (typ ++ if assoc then "" else " family")
+  where
+    typ = case info of
+      OpenTypeFamily -> "type"
+      ClosedTypeFamily _ -> "type"
+      DataFamily -> "data"
+
+-- | Print the signature attached to a family
+ppResultSig :: FamilyResultSig DocNameI -> Unicode -> Qualification -> Html
+ppResultSig result unicode qual = case result of
+  NoSig _ -> noHtml
+  KindSig _ kind -> dcolon unicode <+> ppLKind unicode qual kind
+  TyVarSig _ (L _ bndr) -> equals <+> ppHsTyVarBndr unicode qual bndr
+
+--------------------------------------------------------------------------------
+
+-- * Associated Types
+
+--------------------------------------------------------------------------------
+
+ppAssocType
+  :: Bool
+  -> LinksInfo
+  -> DocForDecl DocName
+  -> LFamilyDecl DocNameI
+  -> [(DocName, Fixity)]
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppAssocType summ links doc (L loc decl) fixities splice unicode pkg qual =
+  ppFamDecl summ True links [] fixities loc (fst doc) decl splice unicode pkg qual
+
+--------------------------------------------------------------------------------
+
+-- * Type applications
+
+--------------------------------------------------------------------------------
+
+ppAppDocNameTyVarBndrs
+  :: RenderableBndrFlag flag
+  => Bool
+  -> Unicode
+  -> Qualification
+  -> DocName
+  -> [LHsTyVarBndr flag DocNameI]
+  -> Html
+ppAppDocNameTyVarBndrs summ unicode qual n vs =
+  ppTypeApp n vs ppDN (ppHsTyVarBndr unicode qual . unLoc)
+  where
+    ppDN notation = ppBinderFixity notation summ . nameOccName . getName
+    ppBinderFixity Infix = ppBinderInfix
+    ppBinderFixity _ = ppBinder
+
+-- | Print an application of a 'DocName' to its list of 'HsType's
+ppAppNameTypes :: DocName -> [HsType DocNameI] -> Unicode -> Qualification -> Html
+ppAppNameTypes n ts unicode qual =
+  ppTypeApp n ts (\p -> ppDocName qual p True) (ppParendType unicode qual HideEmptyContexts)
+
+ppAppNameTypeArgs :: DocName -> [LHsTypeArg DocNameI] -> Unicode -> Qualification -> Html
+ppAppNameTypeArgs n args@(HsValArg _ _ : HsValArg _ _ : _) u q =
+  ppTypeApp n args (\p -> ppDocName q p True) (ppLHsTypeArg u q HideEmptyContexts)
+ppAppNameTypeArgs n args u q =
+  (ppDocName q Prefix True n) <+> hsep (map (ppLHsTypeArg u q HideEmptyContexts) args)
+
+-- | General printing of type applications
+ppTypeApp :: DocName -> [a] -> (Notation -> DocName -> Html) -> (a -> Html) -> Html
+ppTypeApp n (t1 : t2 : rest) ppDN ppT
+  | operator, not . null $ rest = parens opApp <+> hsep (map ppT rest)
+  | operator = opApp
+  where
+    operator = isNameSym . getName $ n
+    opApp = ppT t1 <+> ppDN Infix n <+> ppT t2
+ppTypeApp n ts ppDN ppT = ppDN Prefix n <+> hsep (map ppT ts)
+
+-------------------------------------------------------------------------------
+
+-- * Contexts
+
+-------------------------------------------------------------------------------
+
+ppLContext
+  :: Maybe (LHsContext DocNameI)
+  -> Unicode
+  -> Qualification
+  -> HideEmptyContexts
+  -> Html
+ppLContext Nothing u q h = ppContext [] u q h
+ppLContext (Just c) u q h = ppContext (unLoc c) u q h
+
+ppLContextNoArrow
+  :: LHsContext DocNameI
+  -> Unicode
+  -> Qualification
+  -> HideEmptyContexts
+  -> Html
+ppLContextNoArrow c u q h = ppContextNoArrow (unLoc c) u q h
+
+ppContextNoArrow :: HsContext DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html
+ppContextNoArrow cxt unicode qual emptyCtxts =
+  fromMaybe noHtml $
+    ppContextNoLocsMaybe (map unLoc cxt) unicode qual emptyCtxts
+
+ppContextNoLocs :: [HsType DocNameI] -> Unicode -> Qualification -> HideEmptyContexts -> Html
+ppContextNoLocs cxt unicode qual emptyCtxts =
+  maybe noHtml (<+> darrow unicode) $
+    ppContextNoLocsMaybe cxt unicode qual emptyCtxts
+
+ppContextNoLocsMaybe :: [HsType DocNameI] -> Unicode -> Qualification -> HideEmptyContexts -> Maybe Html
+ppContextNoLocsMaybe [] _ _ emptyCtxts =
+  case emptyCtxts of
+    HideEmptyContexts -> Nothing
+    ShowEmptyToplevelContexts -> Just (toHtml "()")
+ppContextNoLocsMaybe cxt unicode qual _ = Just $ ppHsContext cxt unicode qual
+
+ppContext :: HsContext DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html
+ppContext cxt unicode qual emptyCtxts = ppContextNoLocs (map unLoc cxt) unicode qual emptyCtxts
+
+ppHsContext :: [HsType DocNameI] -> Unicode -> Qualification -> Html
+ppHsContext [] _ _ = noHtml
+ppHsContext [p] unicode qual = ppCtxType unicode qual p
+ppHsContext cxt unicode qual = parenList (map (ppType unicode qual HideEmptyContexts) cxt)
+
+-------------------------------------------------------------------------------
+
+-- * Class declarations
+
+-------------------------------------------------------------------------------
+
+ppClassHdr
+  :: Bool
+  -> Maybe (LocatedC [LHsType DocNameI])
+  -> DocName
+  -> LHsQTyVars DocNameI
+  -> [LHsFunDep DocNameI]
+  -> Unicode
+  -> Qualification
+  -> Html
+ppClassHdr summ lctxt n tvs fds unicode qual =
+  keyword "class"
+    <+> (if not (null $ fromMaybeContext lctxt) then ppLContext lctxt unicode qual HideEmptyContexts else noHtml)
+    <+> ppAppDocNameTyVarBndrs summ unicode qual n (hsQTvExplicit tvs)
+    <+> ppFds fds unicode qual
+
+ppFds :: [LHsFunDep DocNameI] -> Unicode -> Qualification -> Html
+ppFds fds unicode qual =
+  if null fds
+    then noHtml
+    else char '|' <+> hsep (punctuate comma (map (fundep . unLoc) fds))
+  where
+    fundep (FunDep _ vars1 vars2) = ppVars vars1 <+> arrow unicode <+> ppVars vars2
+    fundep (XFunDep _) = error "ppFds"
+    ppVars = hsep . map ((ppDocName qual Prefix True) . unLoc)
+
+ppShortClassDecl
+  :: Bool
+  -> LinksInfo
+  -> TyClDecl DocNameI
+  -> SrcSpan
+  -> [(DocName, DocForDecl DocName)]
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppShortClassDecl
+  summary
+  links
+  ( ClassDecl
+      { tcdCtxt = lctxt
+      , tcdLName = lname
+      , tcdTyVars = tvs
+      , tcdFDs = fds
+      , tcdSigs = sigs
+      , tcdATs = ats
+      }
+    )
+  loc
+  subdocs
+  splice
+  unicode
+  pkg
+  qual =
+    if not (any isUserLSig sigs) && null ats
+      then (if summary then id else topDeclElem links loc splice [nm]) hdr
+      else
+        (if summary then id else topDeclElem links loc splice [nm]) (hdr <+> keyword "where")
+          +++ shortSubDecls
+            False
+            ( [ ppAssocType summary links doc at [] splice unicode pkg qual | at <- ats, let doc = lookupAnySubdoc (unL $ fdLName $ unL at) subdocs
+              ]
+                ++
+                -- ToDo: add associated type defaults
+
+                [ ppFunSig
+                  summary
+                  links
+                  loc
+                  noHtml
+                  doc
+                  names
+                  typ
+                  []
+                  splice
+                  unicode
+                  pkg
+                  qual
+                | L _ (ClassOpSig _ False lnames typ) <- sigs
+                , let doc = lookupAnySubdoc (head names) subdocs
+                      names = map unLoc lnames
+                ]
+                -- FIXME: is taking just the first name ok? Is it possible that
+                -- there are different subdocs for different names in a single
+                -- type signature?
+            )
+    where
+      hdr = ppClassHdr summary lctxt (unLoc lname) tvs fds unicode qual
+      nm = unLoc lname
+ppShortClassDecl _ _ _ _ _ _ _ _ _ = error "declaration type not supported by ppShortClassDecl"
+
+ppClassDecl
+  :: Bool
+  -> LinksInfo
+  -> [DocInstance DocNameI]
+  -> [(DocName, Fixity)]
+  -> SrcSpan
+  -> Documentation DocName
+  -> [(DocName, DocForDecl DocName)]
+  -> TyClDecl DocNameI
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppClassDecl
+  summary
+  links
+  instances
+  fixities
+  loc
+  d
+  subdocs
+  decl@( ClassDecl
+          { tcdCtxt = lctxt
+          , tcdLName = lname
+          , tcdTyVars = ltyvars
+          , tcdFDs = lfds
+          , tcdSigs = lsigs
+          , tcdATs = ats
+          , tcdATDefs = atsDefs
+          }
+        )
+  splice
+  unicode
+  pkg
+  qual
+    | summary = ppShortClassDecl summary links decl loc subdocs splice unicode pkg qual
+    | otherwise =
+        classheader
+          +++ docSection curname pkg qual d
+          +++ minimalBit
+          +++ atBit
+          +++ methodBit
+          +++ instancesBit
+    where
+      curname = Just $ getName nm
+
+      sigs = map unLoc lsigs
+
+      classheader
+        | any isUserLSig lsigs = topDeclElem links loc splice [nm] (hdr unicode qual <+> keyword "where" <+> fixs)
+        | otherwise = topDeclElem links loc splice [nm] (hdr unicode qual <+> fixs)
+
+      -- Only the fixity relevant to the class header
+      fixs = ppFixities [f | f@(n, _) <- fixities, n == unLoc lname] qual
+
+      nm = tcdNameI decl
+
+      hdr = ppClassHdr summary lctxt (unLoc lname) ltyvars lfds
+
+      -- Associated types
+      atBit =
+        subAssociatedTypes
+          [ ppAssocType summary links doc at subfixs splice unicode pkg qual
+            <+> subDefaults (maybeToList defTys)
+          | at <- ats
+          , let name = unLoc . fdLName $ unLoc at
+                doc = lookupAnySubdoc name subdocs
+                subfixs = filter ((== name) . fst) fixities
+                defTys = (declElem . ppDefaultAssocTy name) <$> lookupDAT name
+          ]
+
+      -- Default associated types
+      ppDefaultAssocTy n (vs, rhs) =
+        hsep
+          [ keyword "type"
+          , ppAppNameTypeArgs n vs unicode qual
+          , equals
+          , ppType unicode qual HideEmptyContexts (unLoc rhs)
+          ]
+
+      lookupDAT name = Map.lookup (getName name) defaultAssocTys
+      defaultAssocTys =
+        Map.fromList
+          [ (getName name, (vs, typ))
+          | L
+              _
+              ( TyFamInstDecl
+                  _
+                  ( FamEqn
+                      { feqn_rhs = typ
+                      , feqn_tycon = L _ name
+                      , feqn_pats = vs
+                      }
+                    )
+                ) <-
+              atsDefs
+          ]
+
+      -- Methods
+      methodBit =
+        subMethods
+          [ ppFunSig
+            summary
+            links
+            loc
+            noHtml
+            doc
+            [name]
+            typ
+            subfixs
+            splice
+            unicode
+            pkg
+            qual
+            <+> subDefaults (maybeToList defSigs)
+          | ClassOpSig _ False lnames typ <- sigs
+          , name <- map unLoc lnames
+          , let doc = lookupAnySubdoc name subdocs
+                subfixs = filter ((== name) . fst) fixities
+                defSigs = ppDefaultFunSig name <$> lookupDM name
+          ]
+      -- N.B. taking just the first name is ok. Signatures with multiple names
+      -- are expanded so that each name gets its own signature.
+
+      -- Default methods
+      ppDefaultFunSig n (t, d') =
+        ppFunSig
+          summary
+          links
+          loc
+          (keyword "default")
+          d'
+          [n]
+          t
+          []
+          splice
+          unicode
+          pkg
+          qual
+
+      lookupDM name = Map.lookup (occNameString $ mkDefaultMethodOcc $ getOccName name) defaultMethods
+      defaultMethods =
+        Map.fromList
+          [ (nameStr, (typ, doc))
+          | ClassOpSig _ True lnames typ <- sigs
+          , name <- map unLoc lnames
+          , let doc = lookupAnySubdoc name subdocs
+                nameStr = getOccString name
+          ]
+
+      -- Minimal complete definition
+      minimalBit = case [s | MinimalSig _ (L _ s) <- sigs] of
+        -- Miminal complete definition = every shown method
+        And xs : _
+          | sort [getName n | L _ (Var (L _ n)) <- xs]
+              == sort [getName n | ClassOpSig _ _ ns _ <- sigs, L _ n <- ns] ->
+              noHtml
+        -- Minimal complete definition = the only shown method
+        Var (L _ n) : _
+          | [getName n]
+              == [getName n' | ClassOpSig _ _ ns _ <- sigs, L _ n' <- ns] ->
+              noHtml
+        -- Minimal complete definition = nothing
+        And [] : _ -> subMinimal $ toHtml "Nothing"
+        m : _ -> subMinimal $ ppMinimal False m
+        _ -> noHtml
+
+      ppMinimal _ (Var (L _ n)) = ppDocName qual Prefix True n
+      ppMinimal _ (And fs) = foldr1 (\a b -> a +++ ", " +++ b) $ map (ppMinimal True . unLoc) fs
+      ppMinimal p (Or fs) = wrap $ foldr1 (\a b -> a +++ " | " +++ b) $ map (ppMinimal False . unLoc) fs
+        where
+          wrap | p = parens | otherwise = id
+      ppMinimal p (Parens x) = ppMinimal p (unLoc x)
+
+      -- Instances
+      instancesBit =
+        ppInstances
+          links
+          (OriginClass nm)
+          instances
+          splice
+          unicode
+          pkg
+          qual
+ppClassDecl _ _ _ _ _ _ _ _ _ _ _ _ = error "declaration type not supported by ppShortClassDecl"
+
+ppInstances
+  :: LinksInfo
+  -> InstOrigin DocName
+  -> [DocInstance DocNameI]
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppInstances links origin instances splice unicode pkg qual =
+  subInstances pkg qual instName links True (zipWith instDecl [1 ..] instances)
+  where
+    -- force Splice = True to use line URLs
+
+    instName = getOccString origin
+    instDecl :: Int -> DocInstance DocNameI -> (SubDecl, Maybe Module, Located DocName)
+    instDecl no (inst, mdoc, loc, mdl) =
+      ((ppInstHead links splice unicode qual mdoc origin False no inst mdl), mdl, loc)
+
+ppOrphanInstances
+  :: LinksInfo
+  -> [DocInstance DocNameI]
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppOrphanInstances links instances splice unicode pkg qual =
+  subOrphanInstances pkg qual links True (zipWith instDecl [1 ..] instances)
+  where
+    instOrigin :: InstHead name -> InstOrigin (IdP name)
+    instOrigin inst = OriginClass (ihdClsName inst)
+
+    instDecl :: Int -> DocInstance DocNameI -> (SubDecl, Maybe Module, Located DocName)
+    instDecl no (inst, mdoc, loc, mdl) =
+      ((ppInstHead links splice unicode qual mdoc (instOrigin inst) True no inst Nothing), mdl, loc)
+
+ppInstHead
+  :: LinksInfo
+  -> Splice
+  -> Unicode
+  -> Qualification
+  -> Maybe (MDoc DocName)
+  -> InstOrigin DocName
+  -> Bool
+  -- ^ Is instance orphan
+  -> Int
+  -- ^ Normal
+  -> InstHead DocNameI
+  -> Maybe Module
+  -> SubDecl
+ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead{..}) mdl =
+  case ihdInstType of
+    ClassInst{..} ->
+      ( subInstHead iid $ ppContextNoLocs clsiCtx unicode qual HideEmptyContexts <+> typ
+      , mdoc
+      , [subInstDetails iid ats sigs mname]
+      )
+      where
+        sigs = ppInstanceSigs links splice unicode qual clsiSigs
+        ats = ppInstanceAssocTys links splice unicode qual orphan clsiAssocTys
+    TypeInst rhs ->
+      ( subInstHead iid ptype
+      , mdoc
+      , [subFamInstDetails iid prhs mname]
+      )
+      where
+        ptype = keyword "type" <+> typ
+        prhs =
+          ptype
+            <+> maybe
+              noHtml
+              (\t -> equals <+> ppType unicode qual HideEmptyContexts t)
+              rhs
+    DataInst dd ->
+      ( subInstHead iid pdata
+      , mdoc
+      , [subFamInstDetails iid pdecl mname]
+      )
+      where
+        cons = dd_cons (tcdDataDefn dd)
+        pref = case cons of NewTypeCon _ -> keyword "newtype"; DataTypeCons _ _ -> keyword "data"
+        pdata = pref <+> typ
+        pdecl = pdata <+> ppShortDataDecl False True dd [] unicode qual
+  where
+    mname = maybe noHtml (\m -> toHtml "Defined in" <+> ppModule m) mdl
+    iid = instanceId origin no orphan ihd
+    typ = ppAppNameTypes ihdClsName ihdTypes unicode qual
+
+ppInstanceAssocTys
+  :: LinksInfo
+  -> Splice
+  -> Unicode
+  -> Qualification
+  -> Bool
+  -> [DocInstance DocNameI]
+  -> [Html]
+ppInstanceAssocTys links splice unicode qual orphan insts =
+  maybeToList $
+    subTableSrc Nothing qual links True $
+      zipWith
+        mkInstHead
+        insts
+        [1 ..]
+  where
+    mkInstHead (inst, doc, name, mdl) no =
+      ( ppInstHead links splice unicode qual doc (OriginFamily (unLoc name)) orphan no inst mdl
+      , mdl
+      , name
+      )
+
+ppInstanceSigs
+  :: LinksInfo
+  -> Splice
+  -> Unicode
+  -> Qualification
+  -> [Sig DocNameI]
+  -> [Html]
+ppInstanceSigs links splice unicode qual sigs = do
+  TypeSig _ lnames typ <- sigs
+  let names = map unLoc lnames
+      L _ rtyp = dropWildCards typ
+  -- Instance methods signatures are synified and thus don't have a useful
+  -- SrcSpan value. Use the methods name location instead.
+  return $ ppSimpleSig links splice unicode qual HideEmptyContexts (getLocA $ head lnames) names rtyp
+
+lookupAnySubdoc :: Eq id1 => id1 -> [(id1, DocForDecl id2)] -> DocForDecl id2
+lookupAnySubdoc n = fromMaybe noDocForDecl . lookup n
+
+instanceId :: InstOrigin DocName -> Int -> Bool -> InstHead DocNameI -> String
+instanceId origin no orphan ihd =
+  concat $
+    ["o:" | orphan]
+      ++ [ qual origin
+         , ":" ++ getOccString origin
+         , ":" ++ getOccString (ihdClsName ihd)
+         , ":" ++ show no
+         ]
+  where
+    qual (OriginClass _) = "ic"
+    qual (OriginData _) = "id"
+    qual (OriginFamily _) = "if"
+
+-------------------------------------------------------------------------------
+
+-- * Data & newtype declarations
+
+-------------------------------------------------------------------------------
+
+-- TODO: print contexts
+ppShortDataDecl
+  :: Bool
+  -> Bool
+  -> TyClDecl DocNameI
+  -> [(HsDecl DocNameI, DocForDecl DocName)]
+  -> Unicode
+  -> Qualification
+  -> Html
+ppShortDataDecl summary dataInst dataDecl pats unicode qual
+  | [] <- toList cons
+  , [] <- pats =
+      dataHeader
+  | [lcon] <- toList cons
+  , [] <- pats
+  , isH98
+  , (cHead, cBody, cFoot) <- ppShortConstrParts summary dataInst (unLoc lcon) unicode qual =
+      (dataHeader <+> equals <+> cHead) +++ cBody +++ cFoot
+  | [] <- pats
+  , isH98 =
+      dataHeader
+        +++ shortSubDecls dataInst (zipWith doConstr ('=' : repeat '|') (toList cons) ++ pats1)
+  | otherwise =
+      (dataHeader <+> keyword "where")
+        +++ shortSubDecls dataInst (map doGADTConstr (toList cons) ++ pats1)
+  where
+    dataHeader
+      | dataInst = noHtml
+      | otherwise = ppDataHeader summary dataDecl unicode qual
+    doConstr c con = toHtml [c] <+> ppShortConstr summary (unLoc con) unicode qual
+    doGADTConstr con = ppShortConstr summary (unLoc con) unicode qual
+
+    cons = dd_cons (tcdDataDefn dataDecl)
+    isH98 = flip any (unLoc <$> cons) $ \case
+      ConDeclH98{} -> True
+      ConDeclGADT{} -> False
+
+    pats1 =
+      [ hsep
+        [ keyword "pattern"
+        , hsep $ punctuate comma $ map (ppBinder summary . getOccName) lnames
+        , dcolon unicode
+        , ppPatSigType unicode qual typ
+        ]
+      | (SigD _ (PatSynSig _ lnames typ), _) <- pats
+      ]
+
+-- | Pretty-print a data declaration
+ppDataDecl
+  :: Bool
+  -> LinksInfo
+  -> [DocInstance DocNameI]
+  -- ^ relevant instances
+  -> [(DocName, Fixity)]
+  -- ^ relevant fixities
+  -> [(DocName, DocForDecl DocName)]
+  -- ^ all decl documentation
+  -> SrcSpan
+  -> Documentation DocName
+  -- ^ this decl's documentation
+  -> TyClDecl DocNameI
+  -- ^ this decl
+  -> [(HsDecl DocNameI, DocForDecl DocName)]
+  -- ^ relevant patterns
+  -> Splice
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> Html
+ppDataDecl
+  summary
+  links
+  instances
+  fixities
+  subdocs
+  loc
+  doc
+  dataDecl
+  pats
+  splice
+  unicode
+  pkg
+  qual
+    | summary = ppShortDataDecl summary False dataDecl pats unicode qual
+    | otherwise = header_ +++ docSection curname pkg qual doc +++ constrBit +++ patternBit +++ instancesBit
+    where
+      docname = tcdNameI dataDecl
+      curname = Just $ getName docname
+      cons = dd_cons (tcdDataDefn dataDecl)
+      isH98 = flip any (unLoc <$> cons) $ \case
+        ConDeclH98{} -> True
+        ConDeclGADT{} -> False
+
+      header_ =
+        topDeclElem links loc splice [docname] $
+          ppDataHeader summary dataDecl unicode qual <+> whereBit <+> fix
+
+      fix = ppFixities (filter (\(n, _) -> n == docname) fixities) qual
+
+      whereBit
+        | null cons
+        , null pats =
+            noHtml
+        | isH98 = noHtml
+        | otherwise = keyword "where"
+
+      constrBit =
+        subConstructors
+          pkg
+          qual
+          [ ppSideBySideConstr subdocs subfixs unicode pkg qual c
+          | c <- toList cons
+          , let subfixs =
+                  filter
+                    ( \(n, _) ->
+                        any
+                          (\cn -> cn == n)
+                          (unL <$> getConNamesI (unLoc c))
+                    )
+                    fixities
+          ]
+
+      patternBit =
+        subPatterns
+          pkg
+          qual
+          [ ppSideBySidePat subfixs unicode qual lnames typ d
+          | (SigD _ (PatSynSig _ lnames typ), d) <- pats
+          , let subfixs =
+                  filter
+                    ( \(n, _) ->
+                        any
+                          (\cn -> cn == n)
+                          (map unLoc lnames)
+                    )
+                    fixities
+          ]
+
+      instancesBit =
+        ppInstances
+          links
+          (OriginData docname)
+          instances
+          splice
+          unicode
+          pkg
+          qual
+
+ppShortConstr :: Bool -> ConDecl DocNameI -> Unicode -> Qualification -> Html
+ppShortConstr summary con unicode qual = cHead <+> cBody <+> cFoot
+  where
+    (cHead, cBody, cFoot) = ppShortConstrParts summary False con unicode qual
+
+-- returns three pieces: header, body, footer so that header & footer can be
+-- incorporated into the declaration
+ppShortConstrParts :: Bool -> Bool -> ConDecl DocNameI -> Unicode -> Qualification -> (Html, Html, Html)
+ppShortConstrParts summary dataInst con unicode qual =
+  case con of
+    ConDeclH98
+      { con_args = det
+      , con_ex_tvs = tyVars
+      , con_forall = forall_
+      , con_mb_cxt = cxt
+      } ->
+        let context = fromMaybeContext cxt
+            header_ = ppConstrHdr forall_ tyVars context unicode qual
+         in case det of
+              -- Prefix constructor, e.g. 'Just a'
+              PrefixCon _ args ->
+                ( header_ <+> hsep (ppOcc : map (ppLParendType unicode qual HideEmptyContexts . hsScaledThing) args)
+                , noHtml
+                , noHtml
+                )
+              -- Record constructor, e.g. 'Identity { runIdentity :: a }'
+              RecCon (L _ fields) ->
+                ( header_ +++ ppOcc <+> char '{'
+                , shortSubDecls
+                    dataInst
+                    [ ppShortField summary unicode qual field
+                    | L _ field <- fields
+                    ]
+                , char '}'
+                )
+              -- Infix constructor, e.g. 'a :| [a]'
+              InfixCon arg1 arg2 ->
+                ( header_
+                    <+> hsep
+                      [ ppLParendType unicode qual HideEmptyContexts (hsScaledThing arg1)
+                      , ppOccInfix
+                      , ppLParendType unicode qual HideEmptyContexts (hsScaledThing arg2)
+                      ]
+                , noHtml
+                , noHtml
+                )
+    -- GADT constructor, e.g. 'Foo :: Int -> Foo'
+    ConDeclGADT{} ->
+      ( hsep [ppOcc, dcolon unicode, ppLSigType unicode qual HideEmptyContexts (getGADTConType con)]
+      , noHtml
+      , noHtml
+      )
+  where
+    occ = toList $ nameOccName . getName . unL <$> getConNamesI con
+    ppOcc = hsep (punctuate comma (map (ppBinder summary) occ))
+    ppOccInfix = hsep (punctuate comma (map (ppBinderInfix summary) occ))
+
+-- | Pretty print an expanded constructor
+ppSideBySideConstr
+  :: [(DocName, DocForDecl DocName)]
+  -> [(DocName, Fixity)]
+  -> Unicode
+  -> Maybe Package
+  -> Qualification
+  -> LConDecl DocNameI
+  -- ^ constructor declaration to print
+  -> SubDecl
+ppSideBySideConstr subdocs fixities unicode pkg qual (L _ con) =
+  ( decl -- Constructor header (name, fixity)
+  , mbDoc -- Docs on the whole constructor
+  , fieldPart -- Information on the fields (or arguments, if they have docs)
+  )
+  where
+    -- Find the name of a constructors in the decl (`getConName` always returns a non-empty list)
+    L _ aConName :| _ = getConNamesI con
+
+    fixity = ppFixities fixities qual
+    occ = toList $ nameOccName . getName . unL <$> getConNamesI con
+
+    ppOcc = hsep (punctuate comma (map (ppBinder False) occ))
+    ppOccInfix = hsep (punctuate comma (map (ppBinderInfix False) occ))
+
+    -- Extract out the map of of docs corresponding to the constructors arguments
+    argDocs = maybe Map.empty snd (lookup aConName subdocs)
+    hasArgDocs = not $ Map.null argDocs
+
+    decl = case con of
+      ConDeclH98
+        { con_args = det
+        , con_ex_tvs = tyVars
+        , con_forall = forall_
+        , con_mb_cxt = cxt
+        } ->
+          let context = fromMaybeContext cxt
+              header_ = ppConstrHdr forall_ tyVars context unicode qual
+           in case det of
+                -- Prefix constructor, e.g. 'Just a'
+                PrefixCon _ args
+                  | hasArgDocs -> header_ <+> ppOcc <+> fixity
+                  | otherwise ->
+                      hsep
+                        [ header_ <+> ppOcc
+                        , hsep (map (ppLParendType unicode qual HideEmptyContexts . hsScaledThing) args)
+                        , fixity
+                        ]
+                -- Record constructor, e.g. 'Identity { runIdentity :: a }'
+                RecCon _ -> header_ <+> ppOcc <+> fixity
+                -- Infix constructor, e.g. 'a :| [a]'
+                InfixCon arg1 arg2
+                  | hasArgDocs -> header_ <+> ppOcc <+> fixity
+                  | otherwise ->
+                      hsep
+                        [ header_ <+> ppLParendType unicode qual HideEmptyContexts (hsScaledThing arg1)
+                        , ppOccInfix
+                        , ppLParendType unicode qual HideEmptyContexts (hsScaledThing arg2)
+                        , fixity
+                        ]
+      -- GADT constructor, e.g. 'Foo :: Int -> Foo'
+      ConDeclGADT{}
+        | hasArgDocs || not (null fieldPart) -> ppOcc <+> fixity
+        | otherwise ->
+            hsep
+              [ ppOcc
+              , dcolon unicode
+              , -- ++AZ++ make this prepend "{..}" when it is a record style GADT
+                ppLSigType unicode qual HideEmptyContexts (getGADTConType con)
+              , fixity
+              ]
+
+    fieldPart = case con of
+      ConDeclGADT{con_g_args = con_args'} -> case con_args' of
+        -- GADT record declarations
+        RecConGADT _ _ -> [doConstrArgsWithDocs []]
+        -- GADT prefix data constructors
+        PrefixConGADT _ args | hasArgDocs -> [doConstrArgsWithDocs args]
+        _ -> []
+      ConDeclH98{con_args = con_args'} -> case con_args' of
+        -- H98 record declarations
+        RecCon (L _ fields) -> [doRecordFields fields]
+        -- H98 prefix data constructors
+        PrefixCon _ args | hasArgDocs -> [doConstrArgsWithDocs args]
+        -- H98 infix data constructor
+        InfixCon arg1 arg2 | hasArgDocs -> [doConstrArgsWithDocs [arg1, arg2]]
+        _ -> []
+
+    doRecordFields fields =
+      subFields
+        pkg
+        qual
+        (map (ppSideBySideField subdocs unicode qual) (map unLoc fields))
+
+    doConstrArgsWithDocs args = subFields pkg qual $ case con of
+      ConDeclH98{} ->
+        [ (ppLParendType unicode qual HideEmptyContexts arg, mdoc, [])
+        | (i, arg) <- zip [0 ..] (map hsScaledThing args)
+        , let mdoc = Map.lookup i argDocs
+        ]
+      ConDeclGADT{} ->
+        ppSubSigLike
+          unicode
+          qual
+          (unLoc (getGADTConType con))
+          argDocs
+          subdocs
+          (dcolon unicode)
+          HideEmptyContexts
+
+    -- don't use "con_doc con", in case it's reconstructed from a .hi file,
+    -- or also because we want Haddock to do the doc-parsing, not GHC.
+    mbDoc =
+      lookup aConName subdocs
+        >>= combineDocumentation . fst
+
+-- ppConstrHdr is for (non-GADT) existentials constructors' syntax
+ppConstrHdr
+  :: Bool
+  -- ^ print explicit foralls
+  -> [LHsTyVarBndr Specificity DocNameI]
+  -- ^ type variables
+  -> HsContext DocNameI
+  -- ^ context
+  -> Unicode
+  -> Qualification
+  -> Html
+ppConstrHdr forall_ tvs ctxt unicode qual = ppForall +++ ppCtxt
+  where
+    ppForall
+      | null tvs || not forall_ = noHtml
+      | otherwise = ppForAllPart unicode qual (HsForAllInvis noExtField tvs)
+
+    ppCtxt
+      | null ctxt = noHtml
+      | otherwise =
+          ppContextNoArrow ctxt unicode qual HideEmptyContexts
+            <+> darrow unicode
+            +++ toHtml " "
+
+-- | Pretty-print a record field
+ppSideBySideField
+  :: [(DocName, DocForDecl DocName)]
+  -> Unicode
+  -> Qualification
+  -> ConDeclField DocNameI
+  -> SubDecl
+ppSideBySideField subdocs unicode qual (ConDeclField _ names ltype _) =
+  ( hsep
+      ( punctuate
+          comma
+          [ ppBinder False (rdrNameOcc field)
+          | L _ name <- names
+          , let field = (unLoc . foLabel) name
+          ]
+      )
+      <+> dcolon unicode
+      <+> ppLType unicode qual HideEmptyContexts ltype
+  , mbDoc
+  , []
+  )
+  where
+    -- don't use cd_fld_doc for same reason we don't use con_doc above
+    -- Where there is more than one name, they all have the same documentation
+    mbDoc = lookup (foExt $ unLoc $ head names) subdocs >>= combineDocumentation . fst
+
+ppShortField :: Bool -> Unicode -> Qualification -> ConDeclField DocNameI -> Html
+ppShortField summary unicode qual (ConDeclField _ names ltype _) =
+  hsep (punctuate comma (map ((ppBinder summary) . rdrNameOcc . unLoc . foLabel . unLoc) names))
+    <+> dcolon unicode
+    <+> ppLType unicode qual HideEmptyContexts ltype
+
+-- | Pretty print an expanded pattern (for bundled patterns)
+ppSideBySidePat
+  :: [(DocName, Fixity)]
+  -> Unicode
+  -> Qualification
+  -> [LocatedN DocName]
+  -- ^ pattern name(s)
+  -> LHsSigType DocNameI
+  -- ^ type of pattern(s)
+  -> DocForDecl DocName
+  -- ^ doc map
+  -> SubDecl
+ppSideBySidePat fixities unicode qual lnames typ (doc, argDocs) =
+  ( decl
+  , combineDocumentation doc
+  , fieldPart
+  )
+  where
+    hasArgDocs = not $ Map.null argDocs
+    fixity = ppFixities fixities qual
+    ppOcc = hsep (punctuate comma (map (ppBinder False . getOccName) lnames))
+
+    decl
+      | hasArgDocs = keyword "pattern" <+> ppOcc <+> fixity
+      | otherwise =
+          hsep
+            [ keyword "pattern"
+            , ppOcc
+            , dcolon unicode
+            , ppPatSigType unicode qual typ
+            , fixity
+            ]
+
+    fieldPart
+      | not hasArgDocs = []
+      | otherwise =
+          [ subFields
+              Nothing
+              qual
+              ( ppSubSigLike
+                  unicode
+                  qual
+                  (unLoc typ)
+                  argDocs
+                  []
+                  (dcolon unicode)
+                  emptyCtxt
+              )
+          ]
+
+    emptyCtxt = patSigContext typ
+
+-- | Print the LHS of a data\/newtype declaration.
+-- Currently doesn't handle 'data instance' decls or kind signatures
+ppDataHeader :: Bool -> TyClDecl DocNameI -> Unicode -> Qualification -> Html
+ppDataHeader
+  summary
+  ( DataDecl
+      { tcdDataDefn =
+        HsDataDefn
+          { dd_cons = cons
+          , dd_ctxt = ctxt
+          , dd_kindSig = ks
+          }
+      , tcdLName = L _ name
+      , tcdTyVars = tvs
+      }
+    )
+  unicode
+  qual =
+    -- newtype or data
+    ( case cons of
+        NewTypeCon _ -> keyword "newtype"
+        DataTypeCons False _ -> keyword "data"
+        DataTypeCons True _ -> keyword "type" <+> keyword "data"
+    )
+      <+>
+      -- context
+      ppLContext ctxt unicode qual HideEmptyContexts
+      <+>
+      -- T a b c ..., or a :+: b
+      ppAppDocNameTyVarBndrs summary unicode qual name (hsQTvExplicit tvs)
+      <+> case ks of
+        Nothing -> mempty
+        Just (L _ x) -> dcolon unicode <+> ppKind unicode qual x
+ppDataHeader _ _ _ _ = error "ppDataHeader: illegal argument"
+
+--------------------------------------------------------------------------------
+
+-- * Types and contexts
+
+--------------------------------------------------------------------------------
+
+ppBang :: HsSrcBang -> Html
+ppBang (HsSrcBang _ _ SrcStrict) = toHtml "!"
+ppBang (HsSrcBang _ _ SrcLazy) = toHtml "~"
+ppBang _ = noHtml
+
+tupleParens :: HsTupleSort -> [Html] -> Html
+tupleParens HsUnboxedTuple = ubxParenList
+tupleParens _ = parenList
+
+sumParens :: [Html] -> Html
+sumParens = ubxSumList
+
+--------------------------------------------------------------------------------
+
+-- * Rendering of HsType
+
+--------------------------------------------------------------------------------
+
+ppLType, ppLParendType, ppLFunLhType :: Unicode -> Qualification -> HideEmptyContexts -> LHsType DocNameI -> Html
+ppLType unicode qual emptyCtxts y = ppType unicode qual emptyCtxts (unLoc y)
+ppLParendType unicode qual emptyCtxts y = ppParendType unicode qual emptyCtxts (unLoc y)
+ppLFunLhType unicode qual emptyCtxts y = ppFunLhType unicode qual emptyCtxts (unLoc y)
+
+ppLSigType :: Unicode -> Qualification -> HideEmptyContexts -> LHsSigType DocNameI -> Html
+ppLSigType unicode qual emptyCtxts y = ppSigType unicode qual emptyCtxts (unLoc y)
+
+ppCtxType :: Unicode -> Qualification -> HsType DocNameI -> Html
+ppCtxType unicode qual ty = ppr_mono_ty (reparenTypePrec PREC_CTX ty) unicode qual HideEmptyContexts
+
+ppType, ppParendType, ppFunLhType :: Unicode -> Qualification -> HideEmptyContexts -> HsType DocNameI -> Html
+ppType unicode qual emptyCtxts ty = ppr_mono_ty (reparenTypePrec PREC_TOP ty) unicode qual emptyCtxts
+ppParendType unicode qual emptyCtxts ty = ppr_mono_ty (reparenTypePrec PREC_CON ty) unicode qual emptyCtxts
+ppFunLhType unicode qual emptyCtxts ty = ppr_mono_ty (reparenTypePrec PREC_FUN ty) unicode qual emptyCtxts
+
+ppSigType :: Unicode -> Qualification -> HideEmptyContexts -> HsSigType DocNameI -> Html
+ppSigType unicode qual emptyCtxts sig_ty = ppr_sig_ty (reparenSigType sig_ty) unicode qual emptyCtxts
+
+ppLHsTypeArg :: Unicode -> Qualification -> HideEmptyContexts -> LHsTypeArg DocNameI -> Html
+ppLHsTypeArg unicode qual emptyCtxts (HsValArg _ ty) = ppLParendType unicode qual emptyCtxts ty
+ppLHsTypeArg unicode qual emptyCtxts (HsTypeArg _ ki) = atSign <> ppLParendType unicode qual emptyCtxts ki
+ppLHsTypeArg _ _ _ (HsArgPar _) = toHtml ""
+
+class RenderableBndrFlag flag where
+  ppHsTyVarBndr :: Unicode -> Qualification -> HsTyVarBndr flag DocNameI -> Html
+
+instance RenderableBndrFlag () where
+  ppHsTyVarBndr _ qual (UserTyVar _ _ (L _ name)) =
+    ppDocName qual Raw False name
+  ppHsTyVarBndr unicode qual (KindedTyVar _ _ name kind) =
+    parens
+      ( ppDocName qual Raw False (unL name)
+          <+> dcolon unicode
+          <+> ppLKind unicode qual kind
+      )
+
+instance RenderableBndrFlag Specificity where
+  ppHsTyVarBndr _ qual (UserTyVar _ SpecifiedSpec (L _ name)) =
+    ppDocName qual Raw False name
+  ppHsTyVarBndr _ qual (UserTyVar _ InferredSpec (L _ name)) =
+    braces $ ppDocName qual Raw False name
+  ppHsTyVarBndr unicode qual (KindedTyVar _ SpecifiedSpec name kind) =
+    parens
+      ( ppDocName qual Raw False (unL name)
+          <+> dcolon unicode
+          <+> ppLKind unicode qual kind
+      )
+  ppHsTyVarBndr unicode qual (KindedTyVar _ InferredSpec name kind) =
+    braces
+      ( ppDocName qual Raw False (unL name)
+          <+> dcolon unicode
+          <+> ppLKind unicode qual kind
+      )
+
+instance RenderableBndrFlag (HsBndrVis DocNameI) where
+  ppHsTyVarBndr _ qual (UserTyVar _ bvis (L _ name)) =
+    ppHsBndrVis bvis $
+      ppDocName qual Raw False name
+  ppHsTyVarBndr unicode qual (KindedTyVar _ bvis name kind) =
+    ppHsBndrVis bvis $
+      parens
+        ( ppDocName qual Raw False (unL name)
+            <+> dcolon unicode
+            <+> ppLKind unicode qual kind
+        )
+
+ppHsBndrVis :: HsBndrVis DocNameI -> Html -> Html
+ppHsBndrVis (HsBndrRequired _) d = d
+ppHsBndrVis (HsBndrInvisible _) d = atSign <> d
+
+ppLKind :: Unicode -> Qualification -> LHsKind DocNameI -> Html
+ppLKind unicode qual y = ppKind unicode qual (unLoc y)
+
+ppKind :: Unicode -> Qualification -> HsKind DocNameI -> Html
+ppKind unicode qual ki = ppr_mono_ty (reparenTypePrec PREC_TOP ki) unicode qual HideEmptyContexts
+
+patSigContext :: LHsSigType DocNameI -> HideEmptyContexts
+patSigContext sig_typ
+  | hasNonEmptyContext typ && isFirstContextEmpty typ = ShowEmptyToplevelContexts
+  | otherwise = HideEmptyContexts
+  where
+    typ = sig_body (unLoc sig_typ)
+
+    hasNonEmptyContext t =
+      case unLoc t of
+        HsForAllTy _ _ s -> hasNonEmptyContext s
+        HsQualTy _ cxt s -> if null (unLoc cxt) then hasNonEmptyContext s else True
+        HsFunTy _ _ _ s -> hasNonEmptyContext s
+        _ -> False
+    isFirstContextEmpty t =
+      case unLoc t of
+        HsForAllTy _ _ s -> isFirstContextEmpty s
+        HsQualTy _ cxt _ -> null (unLoc cxt)
+        HsFunTy _ _ _ s -> isFirstContextEmpty s
+        _ -> False
+
+-- | Pretty-print a pattern signature (all this does over 'ppLType' is slot in
+-- the right 'HideEmptyContext' value)
+ppPatSigType :: Unicode -> Qualification -> LHsSigType DocNameI -> Html
+ppPatSigType unicode qual typ =
+  let emptyCtxts = patSigContext typ in ppLSigType unicode qual emptyCtxts typ
+
+ppHsOuterTyVarBndrs
+  :: RenderableBndrFlag flag
+  => Unicode
+  -> Qualification
+  -> HsOuterTyVarBndrs flag DocNameI
+  -> Html
+ppHsOuterTyVarBndrs unicode qual outer_bndrs = case outer_bndrs of
+  HsOuterImplicit{} -> noHtml
+  HsOuterExplicit{hso_bndrs = bndrs} ->
+    hsep (forallSymbol unicode : ppTyVars unicode qual bndrs) +++ dot
+
+ppForAllPart :: Unicode -> Qualification -> HsForAllTelescope DocNameI -> Html
+ppForAllPart unicode qual tele = case tele of
+  HsForAllVis{hsf_vis_bndrs = bndrs} ->
+    hsep (forallSymbol unicode : ppTyVars unicode qual bndrs)
+      +++ spaceHtml
+      +++ arrow unicode
+  HsForAllInvis{hsf_invis_bndrs = bndrs} ->
+    hsep (forallSymbol unicode : ppTyVars unicode qual bndrs) +++ dot
+
+ppr_sig_ty :: HsSigType DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html
+ppr_sig_ty (HsSig{sig_bndrs = outer_bndrs, sig_body = ltype}) unicode qual emptyCtxts =
+  ppHsOuterTyVarBndrs unicode qual outer_bndrs <+> ppr_mono_lty ltype unicode qual emptyCtxts
+
+ppr_mono_lty :: LHsType DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html
+ppr_mono_lty ty = ppr_mono_ty (unLoc ty)
+
+ppr_mono_ty :: HsType DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html
+ppr_mono_ty (HsForAllTy _ tele ty) unicode qual emptyCtxts =
+  ppForAllPart unicode qual tele <+> ppr_mono_lty ty unicode qual emptyCtxts
+ppr_mono_ty (HsQualTy _ ctxt ty) unicode qual emptyCtxts =
+  ppLContext (Just ctxt) unicode qual emptyCtxts <+> ppr_mono_lty ty unicode qual emptyCtxts
+-- UnicodeSyntax alternatives
+ppr_mono_ty (HsTyVar _ _ (L _ name)) True _ _
+  | getOccString (getName name) == "(->)" = toHtml "(→)"
+ppr_mono_ty (HsBangTy _ b ty) u q _ =
+  ppBang b +++ ppLParendType u q HideEmptyContexts ty
+ppr_mono_ty (HsTyVar _ prom (L _ name)) _ q _
+  | isPromoted prom = promoQuote (ppDocName q Prefix True name)
+  | otherwise = ppDocName q Prefix True name
+ppr_mono_ty (HsStarTy _ isUni) u _ _ =
+  toHtml (if u || isUni then "★" else "*")
+ppr_mono_ty (HsFunTy _ mult ty1 ty2) u q e =
+  hsep
+    [ ppr_mono_lty ty1 u q HideEmptyContexts
+    , arr <+> ppr_mono_lty ty2 u q e
+    ]
+  where
+    arr = case mult of
+      HsLinearArrow _ -> lollipop u
+      HsUnrestrictedArrow _ -> arrow u
+      HsExplicitMult _ m -> multAnnotation <> ppr_mono_lty m u q e <+> arrow u
+ppr_mono_ty (HsTupleTy _ con tys) u q _ =
+  tupleParens con (map (ppLType u q HideEmptyContexts) tys)
+ppr_mono_ty (HsSumTy _ tys) u q _ =
+  sumParens (map (ppLType u q HideEmptyContexts) tys)
+ppr_mono_ty (HsKindSig _ ty kind) u q e =
+  ppr_mono_lty ty u q e <+> dcolon u <+> ppLKind u q kind
+ppr_mono_ty (HsListTy _ ty) u q _ = brackets (ppr_mono_lty ty u q HideEmptyContexts)
+ppr_mono_ty (HsIParamTy _ (L _ n) ty) u q _ =
+  ppIPName n <+> dcolon u <+> ppr_mono_lty ty u q HideEmptyContexts
+ppr_mono_ty (HsSpliceTy v _) _ _ _ = dataConCantHappen v
+ppr_mono_ty (HsRecTy{}) _ _ _ = toHtml "{..}"
+-- Can now legally occur in ConDeclGADT, the output here is to provide a
+-- placeholder in the signature, which is followed by the field
+-- declarations.
+ppr_mono_ty (XHsType{}) _ _ _ = error "ppr_mono_ty HsCoreTy"
+ppr_mono_ty (HsExplicitListTy _ IsPromoted tys) u q _ = promoQuote $ brackets $ hsep $ punctuate comma $ map (ppLType u q HideEmptyContexts) tys
+ppr_mono_ty (HsExplicitListTy _ NotPromoted tys) u q _ = brackets $ hsep $ punctuate comma $ map (ppLType u q HideEmptyContexts) tys
+ppr_mono_ty (HsExplicitTupleTy _ tys) u q _ = promoQuote $ parenList $ map (ppLType u q HideEmptyContexts) tys
+ppr_mono_ty (HsAppTy _ fun_ty arg_ty) unicode qual _ =
+  hsep
+    [ ppr_mono_lty fun_ty unicode qual HideEmptyContexts
+    , ppr_mono_lty arg_ty unicode qual HideEmptyContexts
+    ]
+ppr_mono_ty (HsAppKindTy _ fun_ty arg_ki) unicode qual _ =
+  hsep
+    [ ppr_mono_lty fun_ty unicode qual HideEmptyContexts
+    , atSign <> ppr_mono_lty arg_ki unicode qual HideEmptyContexts
+    ]
+ppr_mono_ty (HsOpTy _ prom ty1 op ty2) unicode qual _ =
+  ppr_mono_lty ty1 unicode qual HideEmptyContexts <+> ppr_op_prom <+> ppr_mono_lty ty2 unicode qual HideEmptyContexts
+  where
+    ppr_op_prom
+      | isPromoted prom =
+          promoQuote ppr_op
+      | otherwise =
+          ppr_op
+    ppr_op = ppLDocName qual Infix op
+ppr_mono_ty (HsParTy _ ty) unicode qual emptyCtxts =
+  parens (ppr_mono_lty ty unicode qual emptyCtxts)
+--  = parens (ppr_mono_lty ctxt_prec ty unicode qual emptyCtxts)
+
+ppr_mono_ty (HsDocTy _ ty _) unicode qual emptyCtxts =
+  ppr_mono_lty ty unicode qual emptyCtxts
+ppr_mono_ty (HsWildCardTy _) _ _ _ = char '_'
+ppr_mono_ty (HsTyLit _ n) _ _ _ = ppr_tylit n
+
+ppr_tylit :: HsTyLit DocNameI -> Html
+ppr_tylit (HsNumTy _ n) = toHtml (show n)
+ppr_tylit (HsStrTy _ s) = toHtml (show s)
+ppr_tylit (HsCharTy _ c) = toHtml (show c)
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
new file mode 100644
index 0000000000000000000000000000000000000000..1445d09dca4ef007310119f31c58356082954959
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
@@ -0,0 +1,329 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.Html.DocMarkup
+-- Copyright   :  (c) Simon Marlow   2003-2006,
+--                    David Waern    2006-2009,
+--                    Mark Lentczner 2010
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.Xhtml.DocMarkup
+  ( docToHtml
+  , rdrDocToHtml
+  , origDocToHtml
+  , docToHtmlNoAnchors
+  , docElement
+  , docSection
+  , docSection_
+  ) where
+
+import Data.List (intersperse)
+import Documentation.Haddock.Markup
+import Haddock.Backends.Xhtml.Names
+import Haddock.Backends.Xhtml.Utils
+import Haddock.Doc
+  ( combineDocumentation
+  , emptyMetaDoc
+  , metaConcat
+  , metaDocAppend
+  )
+import Haddock.Types
+import Haddock.Utils
+
+import Data.Maybe (fromMaybe)
+import Text.XHtml hiding (name, p, quote)
+
+import GHC hiding (anchor)
+import GHC.Types.Name
+
+parHtmlMarkup
+  :: Qualification
+  -> Bool
+  -> (Bool -> a -> Html)
+  -> DocMarkup a Html
+parHtmlMarkup qual insertAnchors ppId =
+  Markup
+    { markupEmpty = noHtml
+    , markupString = toHtml
+    , markupParagraph = paragraph
+    , markupAppend = (+++)
+    , markupIdentifier = thecode . ppId insertAnchors
+    , markupIdentifierUnchecked = thecode . ppUncheckedLink qual
+    , markupModule = \(ModLink m lbl) ->
+        let (mdl, ref) = break (== '#') m
+            -- Accommodate for old style
+            -- foo\#bar anchors
+            mdl' = case reverse mdl of
+              '\\' : _ -> init mdl
+              _ -> mdl
+         in ppModuleRef lbl (mkModuleName mdl') ref
+    , markupWarning = thediv ! [theclass "warning"]
+    , markupEmphasis = emphasize
+    , markupBold = strong
+    , markupMonospaced = thecode
+    , markupUnorderedList = unordList
+    , markupOrderedList = makeOrdList
+    , markupDefList = defList
+    , markupCodeBlock = pre
+    , markupHyperlink = \(Hyperlink url mLabel) ->
+        if insertAnchors
+          then
+            anchor
+              ! [href url]
+              << fromMaybe (toHtml url) mLabel
+          else fromMaybe (toHtml url) mLabel
+    , markupAName = \aname ->
+        if insertAnchors
+          then namedAnchor aname << ""
+          else noHtml
+    , markupPic = \(Picture uri t) -> image ! ([src uri] ++ fromMaybe [] (return . title <$> t))
+    , markupMathInline = \mathjax -> thespan ! [theclass "mathjax"] << toHtml ("\\(" ++ mathjax ++ "\\)")
+    , markupMathDisplay = \mathjax -> thespan ! [theclass "mathjax"] << toHtml ("\\[" ++ mathjax ++ "\\]")
+    , markupProperty = pre . toHtml
+    , markupExample = examplesToHtml
+    , markupHeader = \(Header l t) -> makeHeader l t
+    , markupTable = \(Table h r) -> makeTable h r
+    }
+  where
+    makeHeader :: Int -> Html -> Html
+    makeHeader 1 mkup = h1 mkup
+    makeHeader 2 mkup = h2 mkup
+    makeHeader 3 mkup = h3 mkup
+    makeHeader 4 mkup = h4 mkup
+    makeHeader 5 mkup = h5 mkup
+    makeHeader 6 mkup = h6 mkup
+    makeHeader l _ = error $ "Somehow got a header level `" ++ show l ++ "' in DocMarkup!"
+
+    makeTable :: [TableRow Html] -> [TableRow Html] -> Html
+    makeTable hs bs = table (concatHtml (hs' ++ bs'))
+      where
+        hs'
+          | null hs = []
+          | otherwise = [thead (concatHtml (map (makeTableRow th) hs))]
+
+        bs' = [tbody (concatHtml (map (makeTableRow td) bs))]
+
+    makeTableRow :: (Html -> Html) -> TableRow Html -> Html
+    makeTableRow thr (TableRow cs) = tr (concatHtml (map (makeTableCell thr) cs))
+
+    makeTableCell :: (Html -> Html) -> TableCell Html -> Html
+    makeTableCell thr (TableCell i j c) = thr c ! (i' ++ j')
+      where
+        i' = if i == 1 then [] else [colspan i]
+        j' = if j == 1 then [] else [rowspan j]
+
+    examplesToHtml l = pre (concatHtml $ map exampleToHtml l) ! [theclass "screen"]
+
+    exampleToHtml (Example expression result) = htmlExample
+      where
+        htmlExample = htmlPrompt +++ htmlExpression +++ toHtml (unlines result)
+        htmlPrompt = (thecode . toHtml $ ">>> ") ! [theclass "prompt"]
+        htmlExpression = (strong . thecode . toHtml $ expression ++ "\n") ! [theclass "userinput"]
+
+    makeOrdList :: HTML a => [(Int, a)] -> Html
+    makeOrdList items = olist << map (\(index, a) -> li ! [intAttr "value" index] << a) items
+
+-- | We use this intermediate type to transform the input 'Doc' tree
+-- in an arbitrary way before rendering, such as grouping some
+-- elements. This is effectively a hack to prevent the 'Doc' type
+-- from changing if it is possible to recover the layout information
+-- we won't need after the fact.
+data Hack a id
+  = UntouchedDoc (MetaDoc a id)
+  | CollapsingHeader (Header (DocH a id)) (MetaDoc a id) Int (Maybe String)
+  | HackAppend (Hack a id) (Hack a id)
+  deriving (Eq)
+
+-- | Group things under bold 'DocHeader's together.
+toHack
+  :: Int
+  -- ^ Counter for header IDs which serves to assign
+  -- unique identifiers within the comment scope
+  -> Maybe String
+  -- ^ It is not enough to have unique identifier within the
+  -- scope of the comment: if two different comments have the
+  -- same ID for headers, the collapse/expand behaviour will act
+  -- on them both. This serves to make each header a little bit
+  -- more unique. As we can't export things with the same names,
+  -- this should work more or less fine: it is in fact the
+  -- implicit assumption the collapse/expand mechanism makes for
+  -- things like ‘Instances’ boxes.
+  -> [MetaDoc a id]
+  -> Hack a id
+toHack _ _ [] = UntouchedDoc emptyMetaDoc
+toHack _ _ [x] = UntouchedDoc x
+toHack n nm (MetaDoc{_doc = DocHeader (Header l (DocBold x))} : xs) =
+  let
+    -- Header with dropped bold
+    h = Header l x
+    -- Predicate for takeWhile, grab everything including ‘smaller’
+    -- headers
+    p (MetaDoc{_doc = DocHeader (Header l' _)}) = l' > l
+    p _ = True
+    -- Stuff ‘under’ this header
+    r = takeWhile p xs
+    -- Everything else that didn't make it under
+    r' = drop (length r) xs
+    app y [] = y
+    app y ys = HackAppend y (toHack (n + 1) nm ys)
+   in
+    case r of
+      -- No content under this header
+      [] -> CollapsingHeader h emptyMetaDoc n nm `app` r'
+      -- We got something out, stitch it back together into one chunk
+      y : ys -> CollapsingHeader h (foldl metaDocAppend y ys) n nm `app` r'
+toHack n nm (x : xs) = HackAppend (UntouchedDoc x) (toHack n nm xs)
+
+-- | Remove ‘top-level’ 'DocAppend's turning them into a flat list.
+-- This lends itself much better to processing things in order user
+-- might look at them, such as in 'toHack'.
+flatten :: MetaDoc a id -> [MetaDoc a id]
+flatten MetaDoc{_meta = m, _doc = DocAppend x y} =
+  let f z = MetaDoc{_meta = m, _doc = z}
+   in flatten (f x) ++ flatten (f y)
+flatten x = [x]
+
+-- | Generate the markup needed for collapse to happen. For
+-- 'UntouchedDoc' and 'HackAppend' we do nothing more but
+-- extract/append the underlying 'Doc' and convert it to 'Html'. For
+-- 'CollapsingHeader', we attach extra info to the generated 'Html'
+-- that allows us to expand/collapse the content.
+hackMarkup :: DocMarkup id Html -> Maybe Package -> Hack (Wrap (ModuleName, OccName)) id -> Html
+hackMarkup fmt' currPkg h' =
+  let (html, ms) = hackMarkup' fmt' h'
+   in html +++ renderMeta fmt' currPkg (metaConcat ms)
+  where
+    hackMarkup'
+      :: DocMarkup id Html
+      -> Hack (Wrap (ModuleName, OccName)) id
+      -> (Html, [Meta])
+    hackMarkup' fmt h = case h of
+      UntouchedDoc d -> (markup fmt $ _doc d, [_meta d])
+      CollapsingHeader (Header lvl titl) par n nm ->
+        let id_ = makeAnchorId $ "ch:" ++ fromMaybe "noid:" nm ++ show n
+            col' = collapseControl id_ "subheading"
+            summary = thesummary ! [theclass "hide-when-js-enabled"] << "Expand"
+            instTable contents = collapseDetails id_ DetailsClosed (summary +++ contents)
+            lvs = zip [1 ..] [h1, h2, h3, h4, h5, h6]
+            getHeader = fromMaybe caption (lookup lvl lvs)
+            subCaption = getHeader ! col' << markup fmt titl
+         in ((subCaption +++) . instTable $ markup fmt (_doc par), [_meta par])
+      HackAppend d d' ->
+        let (x, m) = hackMarkup' fmt d
+            (y, m') = hackMarkup' fmt d'
+         in (markupAppend fmt x y, m ++ m')
+
+renderMeta :: DocMarkup id Html -> Maybe Package -> Meta -> Html
+renderMeta fmt currPkg m =
+  maybe noHtml (renderMetaSince fmt currPkg) (_metaSince m)
+
+renderMetaSince :: DocMarkup id Html -> Maybe Package -> MetaSince -> Html
+renderMetaSince fmt currPkg (MetaSince{sincePackage = pkg, sinceVersion = ver}) =
+  markupParagraph fmt . markupEmphasis fmt . toHtml $
+    "Since: " ++ formatPkgMaybe pkg ++ formatVersion ver
+  where
+    formatVersion v = concat . intersperse "." $ map show v
+    formatPkgMaybe (Just p) | Just p /= currPkg = p ++ "-"
+    formatPkgMaybe _ = ""
+
+-- | Goes through 'hackMarkup' to generate the 'Html' rather than
+-- skipping straight to 'markup': this allows us to employ XHtml
+-- specific hacks to the tree first.
+markupHacked
+  :: DocMarkup (Wrap id) Html
+  -> Maybe Package -- this package
+  -> Maybe String
+  -> MDoc id
+  -> Html
+markupHacked fmt currPkg n = hackMarkup fmt currPkg . toHack 0 n . flatten
+
+-- If the doc is a single paragraph, don't surround it with <P> (this causes
+-- ugly extra whitespace with some browsers).  FIXME: Does this still apply?
+docToHtml
+  :: Maybe String
+  -- ^ Name of the thing this doc is for. See
+  -- comments on 'toHack' for details.
+  -> Maybe Package
+  -- ^ Current package
+  -> Qualification
+  -> MDoc DocName
+  -> Html
+docToHtml n pkg qual = markupHacked fmt pkg n . cleanup
+  where
+    fmt = parHtmlMarkup qual True (ppWrappedDocName qual Raw)
+
+-- | Same as 'docToHtml' but it doesn't insert the 'anchor' element
+-- in links. This is used to generate the Contents box elements.
+docToHtmlNoAnchors
+  :: Maybe String
+  -- ^ See 'toHack'
+  -> Maybe Package
+  -- ^ Current package
+  -> Qualification
+  -> MDoc DocName
+  -> Html
+docToHtmlNoAnchors n pkg qual = markupHacked fmt pkg n . cleanup
+  where
+    fmt = parHtmlMarkup qual False (ppWrappedDocName qual Raw)
+
+origDocToHtml :: Maybe Package -> Qualification -> MDoc Name -> Html
+origDocToHtml pkg qual = markupHacked fmt pkg Nothing . cleanup
+  where
+    fmt = parHtmlMarkup qual True (const (ppWrappedName Raw))
+
+rdrDocToHtml :: Maybe Package -> Qualification -> MDoc RdrName -> Html
+rdrDocToHtml pkg qual = markupHacked fmt pkg Nothing . cleanup
+  where
+    fmt = parHtmlMarkup qual True (const (ppRdrName . unwrap))
+
+docElement :: (Html -> Html) -> Html -> Html
+docElement el content_ =
+  if isNoHtml content_
+    then el ! [theclass "doc empty"] << spaceHtml
+    else el ! [theclass "doc"] << content_
+
+docSection
+  :: Maybe Name
+  -- ^ Name of the thing this doc is for
+  -> Maybe Package
+  -- ^ Current package
+  -> Qualification
+  -> Documentation DocName
+  -> Html
+docSection n pkg qual =
+  maybe noHtml (docSection_ n pkg qual) . combineDocumentation
+
+docSection_
+  :: Maybe Name
+  -- ^ Name of the thing this doc is for
+  -> Maybe Package
+  -- ^ Current package
+  -> Qualification
+  -> MDoc DocName
+  -> Html
+docSection_ n pkg qual =
+  (docElement thediv <<) . docToHtml (getOccString <$> n) pkg qual
+
+cleanup :: MDoc a -> MDoc a
+cleanup = overDoc (markup fmtUnParagraphLists)
+  where
+    -- If there is a single paragraph, then surrounding it with <P>..</P>
+    -- can add too much whitespace in some browsers (eg. IE).  However if
+    -- we have multiple paragraphs, then we want the extra whitespace to
+    -- separate them.  So we catch the single paragraph case and transform it
+    -- here. We don't do this in code blocks as it eliminates line breaks.
+    unParagraph :: Doc a -> Doc a
+    unParagraph (DocParagraph d) = d
+    unParagraph doc = doc
+
+    fmtUnParagraphLists :: DocMarkup (Wrap a) (Doc a)
+    fmtUnParagraphLists =
+      idMarkup
+        { markupUnorderedList = DocUnorderedList . map unParagraph
+        , markupOrderedList = DocOrderedList . map (\(index, a) -> (index, unParagraph a))
+        }
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c141584a9910478b37a24f5647ba914cc6d267dc
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
@@ -0,0 +1,356 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.Html.Layout
+-- Copyright   :  (c) Simon Marlow   2003-2006,
+--                    David Waern    2006-2009,
+--                    Mark Lentczner 2010
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.Xhtml.Layout
+  ( miniBody
+  , divPackageHeader
+  , divContent
+  , divModuleHeader
+  , divFooter
+  , divTableOfContents
+  , divDescription
+  , divSynopsis
+  , divInterface
+  , divIndex
+  , divAlphabet
+  , divPackageList
+  , divModuleList
+  , divContentsList
+  , sectionName
+  , nonEmptySectionName
+  , shortDeclList
+  , shortSubDecls
+  , divTopDecl
+  , SubDecl
+  , subArguments
+  , subAssociatedTypes
+  , subConstructors
+  , subPatterns
+  , subEquations
+  , subFields
+  , subInstances
+  , subOrphanInstances
+  , subInstHead
+  , subInstDetails
+  , subFamInstDetails
+  , subMethods
+  , subDefaults
+  , subMinimal
+  , subTableSrc
+  , topDeclElem
+  , declElem
+  ) where
+
+import qualified Data.Map as Map
+import Data.Maybe (fromMaybe)
+import Haddock.Backends.Xhtml.DocMarkup
+import Haddock.Backends.Xhtml.Types
+import Haddock.Backends.Xhtml.Utils
+import Haddock.Types
+import Haddock.Utils (makeAnchorId, nameAnchorId)
+import Text.XHtml hiding (name, quote, title)
+
+import GHC hiding (anchor)
+import GHC.Types.Name (nameOccName)
+
+--------------------------------------------------------------------------------
+
+-- * Sections of the document
+
+--------------------------------------------------------------------------------
+
+miniBody :: Html -> Html
+miniBody = body ! [identifier "mini"]
+
+sectionDiv :: String -> Html -> Html
+sectionDiv i = thediv ! [identifier i]
+
+sectionName :: Html -> Html
+sectionName = paragraph ! [theclass "caption"]
+
+-- | Make an element that always has at least something (a non-breaking space).
+-- If it would have otherwise been empty, then give it the class ".empty".
+nonEmptySectionName :: Html -> Html
+nonEmptySectionName c
+  | isNoHtml c = thespan ! [theclass "caption empty"] $ spaceHtml
+  | otherwise = thespan ! [theclass "caption"] $ c
+
+divPackageHeader
+  , divContent
+  , divModuleHeader
+  , divFooter
+  , divTableOfContents
+  , divDescription
+  , divSynopsis
+  , divInterface
+  , divIndex
+  , divAlphabet
+  , divPackageList
+  , divModuleList
+  , divContentsList
+    :: Html -> Html
+divPackageHeader = sectionDiv "package-header"
+divContent = sectionDiv "content"
+divModuleHeader = sectionDiv "module-header"
+divFooter = sectionDiv "footer"
+divTableOfContents = sectionDiv "table-of-contents"
+divContentsList = sectionDiv "contents-list"
+divDescription = sectionDiv "description"
+divSynopsis = sectionDiv "synopsis"
+divInterface = sectionDiv "interface"
+divIndex = sectionDiv "index"
+divAlphabet = sectionDiv "alphabet"
+divModuleList = sectionDiv "module-list"
+divPackageList = sectionDiv "module-list"
+
+--------------------------------------------------------------------------------
+
+-- * Declaration containers
+
+--------------------------------------------------------------------------------
+
+shortDeclList :: [Html] -> Html
+shortDeclList items = ulist << map (li ! [theclass "src short"] <<) items
+
+shortSubDecls :: Bool -> [Html] -> Html
+shortSubDecls inst items = ulist ! [theclass c] << map (i <<) items
+  where
+    i
+      | inst = li ! [theclass "inst"]
+      | otherwise = li
+    c
+      | inst = "inst"
+      | otherwise = "subs"
+
+divTopDecl :: Html -> Html
+divTopDecl = thediv ! [theclass "top"]
+
+type SubDecl = (Html, Maybe (MDoc DocName), [Html])
+
+divSubDecls :: HTML a => String -> a -> Maybe Html -> Html
+divSubDecls cssClass captionName = maybe noHtml wrap
+  where
+    wrap = (subSection <<) . (subCaption +++)
+    subSection = thediv ! [theclass $ unwords ["subs", cssClass]]
+    subCaption = paragraph ! [theclass "caption"] << captionName
+
+subDlist :: Maybe Package -> Qualification -> [SubDecl] -> Maybe Html
+subDlist _ _ [] = Nothing
+subDlist pkg qual decls = Just $ ulist << map subEntry decls
+  where
+    subEntry (decl, mdoc, subs) =
+      li
+        << ( define
+              ! [theclass "src"]
+              << decl
+              +++ docElement thediv
+              << (fmap (docToHtml Nothing pkg qual) mdoc +++ subs)
+           )
+
+subTable :: Maybe Package -> Qualification -> [SubDecl] -> Maybe Html
+subTable _ _ [] = Nothing
+subTable pkg qual decls = Just $ table << aboves (concatMap subRow decls)
+  where
+    subRow (decl, mdoc, subs) =
+      ( td
+          ! [theclass "src"]
+          << decl
+          <-> docElement td
+          << fmap (docToHtml Nothing pkg qual) mdoc
+      )
+        : map (cell . (td <<)) subs
+
+-- | Sub table with source information (optional).
+subTableSrc
+  :: Maybe Package
+  -> Qualification
+  -> LinksInfo
+  -> Bool
+  -> [(SubDecl, Maybe Module, Located DocName)]
+  -> Maybe Html
+subTableSrc _ _ _ _ [] = Nothing
+subTableSrc pkg qual lnks splice decls = Just $ table << aboves (concatMap subRow decls)
+  where
+    subRow ((decl, mdoc, subs), mdl, L loc dn) =
+      ( td
+          ! [theclass "src clearfix"]
+          << (thespan ! [theclass "inst-left"] << decl)
+          <+> linkHtml loc mdl dn
+          <-> docElement td
+          << fmap (docToHtml Nothing pkg qual) mdoc
+      )
+        : map (cell . (td <<)) subs
+
+    linkHtml :: SrcSpan -> Maybe Module -> DocName -> Html
+    linkHtml loc@(RealSrcSpan _ _) mdl dn = links lnks loc splice mdl dn
+    linkHtml _ _ _ = noHtml
+
+subBlock :: [Html] -> Maybe Html
+subBlock [] = Nothing
+subBlock hs = Just $ toHtml hs
+
+subArguments :: Maybe Package -> Qualification -> [SubDecl] -> Html
+subArguments pkg qual = divSubDecls "arguments" "Arguments" . subTable pkg qual
+
+subAssociatedTypes :: [Html] -> Html
+subAssociatedTypes = divSubDecls "associated-types" "Associated Types" . subBlock
+
+subConstructors :: Maybe Package -> Qualification -> [SubDecl] -> Html
+subConstructors pkg qual = divSubDecls "constructors" "Constructors" . subTable pkg qual
+
+subPatterns :: Maybe Package -> Qualification -> [SubDecl] -> Html
+subPatterns pkg qual = divSubDecls "bundled-patterns" "Bundled Patterns" . subTable pkg qual
+
+subFields :: Maybe Package -> Qualification -> [SubDecl] -> Html
+subFields pkg qual = divSubDecls "fields" "Fields" . subDlist pkg qual
+
+subEquations :: Maybe Package -> Qualification -> [SubDecl] -> Html
+subEquations pkg qual = divSubDecls "equations" "Equations" . subTable pkg qual
+
+-- | Generate collapsible sub table for instance declarations, with source
+subInstances
+  :: Maybe Package
+  -> Qualification
+  -> String
+  -- ^ Class name, used for anchor generation
+  -> LinksInfo
+  -> Bool
+  -> [(SubDecl, Maybe Module, Located DocName)]
+  -> Html
+subInstances pkg qual nm lnks splice = maybe noHtml wrap . instTable
+  where
+    wrap contents = subSection (hdr +++ collapseDetails id_ DetailsOpen (summary +++ contents))
+    instTable = subTableSrc pkg qual lnks splice
+    subSection = thediv ! [theclass "subs instances"]
+    hdr = h4 ! collapseControl id_ "instances" << "Instances"
+    summary = thesummary ! [theclass "hide-when-js-enabled"] << "Instances details"
+    id_ = makeAnchorId $ "i:" ++ nm
+
+subOrphanInstances
+  :: Maybe Package
+  -> Qualification
+  -> LinksInfo
+  -> Bool
+  -> [(SubDecl, Maybe Module, Located DocName)]
+  -> Html
+subOrphanInstances pkg qual lnks splice = maybe noHtml wrap . instTable
+  where
+    wrap = ((h1 << "Orphan instances") +++)
+    instTable = fmap (thediv ! [identifier ("section." ++ id_)] <<) . subTableSrc pkg qual lnks splice
+    id_ = makeAnchorId "orphans"
+
+subInstHead
+  :: String
+  -- ^ Instance unique id (for anchor generation)
+  -> Html
+  -- ^ Header content (instance name and type)
+  -> Html
+subInstHead iid hdr =
+  expander noHtml <+> hdr
+  where
+    expander = thespan ! collapseControl (instAnchorId iid) "instance"
+
+subInstDetails
+  :: String
+  -- ^ Instance unique id (for anchor generation)
+  -> [Html]
+  -- ^ Associated type contents
+  -> [Html]
+  -- ^ Method contents (pretty-printed signatures)
+  -> Html
+  -- ^ Source module
+  -> Html
+subInstDetails iid ats mets mdl =
+  subInstSection iid << (p mdl <+> subAssociatedTypes ats <+> subMethods mets)
+
+subFamInstDetails
+  :: String
+  -- ^ Instance unique id (for anchor generation)
+  -> Html
+  -- ^ Type or data family instance
+  -> Html
+  -- ^ Source module TODO: use this
+  -> Html
+subFamInstDetails iid fi mdl =
+  subInstSection iid << (p mdl <+> (thediv ! [theclass "src"] << fi))
+
+subInstSection
+  :: String
+  -- ^ Instance unique id (for anchor generation)
+  -> Html
+  -> Html
+subInstSection iid contents = collapseDetails (instAnchorId iid) DetailsClosed (summary +++ contents)
+  where
+    summary = thesummary ! [theclass "hide-when-js-enabled"] << "Instance details"
+
+instAnchorId :: String -> String
+instAnchorId iid = makeAnchorId $ "i:" ++ iid
+
+subMethods :: [Html] -> Html
+subMethods = divSubDecls "methods" "Methods" . subBlock
+
+subDefaults :: [Html] -> Html
+subDefaults = divSubDecls "default" "" . subBlock
+
+subMinimal :: Html -> Html
+subMinimal = divSubDecls "minimal" "Minimal complete definition" . Just . declElem
+
+-- a box for displaying code
+declElem :: Html -> Html
+declElem = paragraph ! [theclass "src"]
+
+-- a box for top level documented names
+-- it adds a source and wiki link at the right hand side of the box
+topDeclElem :: LinksInfo -> SrcSpan -> Bool -> [DocName] -> Html -> Html
+topDeclElem lnks loc splice names html =
+  declElem << (html <+> (links lnks loc splice Nothing $ head names))
+
+-- FIXME: is it ok to simply take the first name?
+
+-- | Adds a source and wiki link at the right hand side of the box.
+-- Name must be documented, otherwise we wouldn't get here.
+links :: LinksInfo -> SrcSpan -> Bool -> Maybe Module -> DocName -> Html
+links ((_, _, sourceMap, lineMap), (_, _, maybe_wiki_url)) loc splice mdl' docName@(Documented n mdl) =
+  srcLink <+> wikiLink <+> (selfLink ! [theclass "selflink"] << "#")
+  where
+    selfLink = linkedAnchor (nameAnchorId (nameOccName (getName docName)))
+
+    srcLink =
+      let nameUrl = Map.lookup origPkg sourceMap
+          lineUrl = Map.lookup origPkg lineMap
+          mUrl
+            | splice = lineUrl
+            -- Use the lineUrl as a backup
+            | otherwise = maybe lineUrl Just nameUrl
+       in case mUrl of
+            Nothing -> noHtml
+            Just url ->
+              let url' = spliceURL (Just origMod) (Just n) (Just loc) url
+               in anchor ! [href url', theclass "link"] << "Source"
+
+    wikiLink =
+      case maybe_wiki_url of
+        Nothing -> noHtml
+        Just url ->
+          let url' = spliceURL (Just mdl) (Just n) (Just loc) url
+           in anchor ! [href url', theclass "link"] << "Comments"
+
+    -- For source links, we want to point to the original module,
+    -- because only that will have the source.
+    --
+    -- 'mdl'' is a way of "overriding" the module. Without it, instances
+    -- will point to the module defining the class/family, which is wrong.
+    origMod = fromMaybe (nameModule n) mdl'
+    origPkg = moduleUnit origMod
+links _ _ _ _ _ = noHtml
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Meta.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Meta.hs
new file mode 100644
index 0000000000000000000000000000000000000000..548feb1b2bc6a5a47894c418be647bf9f498d061
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Meta.hs
@@ -0,0 +1,31 @@
+module Haddock.Backends.Xhtml.Meta where
+
+import Haddock.Utils.Json
+import Haddock.Version
+
+import Data.ByteString.Builder (hPutBuilder)
+import System.FilePath ((</>))
+import System.IO (IOMode (WriteMode), withFile)
+
+-- | Everytime breaking changes to the Quckjump api
+-- happen this needs to be modified.
+quickjumpVersion :: Int
+quickjumpVersion = 1
+
+-- | Writes a json encoded file containing additional
+-- information about the generated documentation. This
+-- is useful for external tools (e.g., Hackage).
+writeHaddockMeta :: FilePath -> Bool -> IO ()
+writeHaddockMeta odir withQuickjump = do
+  let
+    meta_json :: Value
+    meta_json =
+      object
+        ( concat
+            [ ["haddock_version" .= String projectVersion]
+            , ["quickjump_version" .= quickjumpVersion | withQuickjump]
+            ]
+        )
+
+  withFile (odir </> "meta.json") WriteMode $ \h ->
+    hPutBuilder h (encodeToBuilder meta_json)
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Names.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Names.hs
new file mode 100644
index 0000000000000000000000000000000000000000..093be648f1a1a41dd0fd1eacd6d6e9bda39272ce
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Names.hs
@@ -0,0 +1,206 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.Html.Names
+-- Copyright   :  (c) Simon Marlow   2003-2006,
+--                    David Waern    2006-2009,
+--                    Mark Lentczner 2010
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.Xhtml.Names
+  ( ppName
+  , ppDocName
+  , ppLDocName
+  , ppRdrName
+  , ppUncheckedLink
+  , ppBinder
+  , ppBinderInfix
+  , ppBinder'
+  , ppModule
+  , ppModuleRef
+  , ppIPName
+  , linkId
+  , Notation (..)
+  , ppWrappedDocName
+  , ppWrappedName
+  ) where
+
+import Haddock.Backends.Xhtml.Utils
+import Haddock.GhcUtils
+import Haddock.Types
+import Haddock.Utils
+
+import Data.List (stripPrefix)
+import Text.XHtml hiding (name, p, quote)
+
+import GHC hiding (LexicalFixity (..), anchor)
+import GHC.Data.FastString (unpackFS)
+import GHC.Types.Name
+import GHC.Types.Name.Reader
+
+-- | Indicator of how to render a 'DocName' into 'Html'
+data Notation
+  = -- | Render as-is.
+    Raw
+  | -- | Render using infix notation.
+    Infix
+  | -- | Render using prefix notation.
+    Prefix
+  deriving (Eq, Show)
+
+ppOccName :: OccName -> Html
+ppOccName = toHtml . occNameString
+
+ppRdrName :: RdrName -> Html
+ppRdrName = ppOccName . rdrNameOcc
+
+ppIPName :: HsIPName -> Html
+ppIPName = toHtml . ('?' :) . unpackFS . hsIPNameFS
+
+ppUncheckedLink :: Qualification -> Wrap (ModuleName, OccName) -> Html
+ppUncheckedLink _ x = linkIdOcc' mdl (Just occ) << occHtml
+  where
+    (mdl, occ) = unwrap x
+    occHtml = toHtml (showWrapped (occNameString . snd) x) -- TODO: apply ppQualifyName
+
+-- The Bool indicates if it is to be rendered in infix notation
+ppLDocName :: Qualification -> Notation -> GenLocated l DocName -> Html
+ppLDocName qual notation (L _ d) = ppDocName qual notation True d
+
+ppDocName :: Qualification -> Notation -> Bool -> DocName -> Html
+ppDocName qual notation insertAnchors docName =
+  case docName of
+    Documented name mdl ->
+      linkIdOcc mdl (Just (nameOccName name)) insertAnchors
+        << ppQualifyName qual notation name mdl
+    Undocumented name
+      | isExternalName name || isWiredInName name ->
+          ppQualifyName qual notation name (nameModule name)
+      | otherwise -> ppName notation name
+
+ppWrappedDocName :: Qualification -> Notation -> Bool -> Wrap DocName -> Html
+ppWrappedDocName qual notation insertAnchors docName = case docName of
+  Unadorned n -> ppDocName qual notation insertAnchors n
+  Parenthesized n -> ppDocName qual Prefix insertAnchors n
+  Backticked n -> ppDocName qual Infix insertAnchors n
+
+ppWrappedName :: Notation -> Wrap Name -> Html
+ppWrappedName notation docName = case docName of
+  Unadorned n -> ppName notation n
+  Parenthesized n -> ppName Prefix n
+  Backticked n -> ppName Infix n
+
+-- | Render a name depending on the selected qualification mode
+ppQualifyName :: Qualification -> Notation -> Name -> Module -> Html
+ppQualifyName qual notation name mdl =
+  case qual of
+    NoQual -> ppName notation name
+    FullQual -> ppFullQualName notation mdl name
+    LocalQual localmdl ->
+      if moduleString mdl == moduleString localmdl
+        then ppName notation name
+        else ppFullQualName notation mdl name
+    RelativeQual localmdl ->
+      case stripPrefix (moduleString localmdl) (moduleString mdl) of
+        -- local, A.x -> x
+        Just [] -> ppName notation name
+        -- sub-module, A.B.x -> B.x
+        Just ('.' : m) -> toHtml $ m ++ '.' : getOccString name
+        -- some module with same prefix, ABC.x -> ABC.x
+        Just _ -> ppFullQualName notation mdl name
+        -- some other module, D.x -> D.x
+        Nothing -> ppFullQualName notation mdl name
+
+ppFullQualName :: Notation -> Module -> Name -> Html
+ppFullQualName notation mdl name = wrapInfix notation (getOccName name) qname
+  where
+    qname = toHtml $ moduleString mdl ++ '.' : getOccString name
+
+ppName :: Notation -> Name -> Html
+ppName notation name =
+  case m_pun of
+    Just str -> toHtml (unpackFS str) -- use the punned form
+    Nothing ->
+      wrapInfix notation (getOccName name) $
+        toHtml (getOccString name) -- use the original identifier
+  where
+    m_pun = case notation of
+      Raw -> namePun_maybe name
+      Prefix -> namePun_maybe name
+      Infix -> Nothing
+
+ppBinder :: Bool -> OccName -> Html
+ppBinder = ppBinderWith Prefix
+
+ppBinderInfix :: Bool -> OccName -> Html
+ppBinderInfix = ppBinderWith Infix
+
+ppBinderWith :: Notation -> Bool -> OccName -> Html
+-- 'isRef' indicates whether this is merely a reference from another part of
+-- the documentation or is the actual definition; in the latter case, we also
+-- set the 'id' and 'class' attributes.
+ppBinderWith notation isRef n =
+  makeAnchor << ppBinder' notation n
+  where
+    name = nameAnchorId n
+    makeAnchor
+      | isRef = linkedAnchor name
+      | otherwise = namedAnchor name ! [theclass "def"]
+
+ppBinder' :: Notation -> OccName -> Html
+ppBinder' notation n = wrapInfix notation n $ ppOccName n
+
+wrapInfix :: Notation -> OccName -> Html -> Html
+wrapInfix notation n = case notation of
+  Infix | not is_sym -> quote
+  Prefix | is_sym -> parens
+  _ -> id
+  where
+    is_sym = isSymOcc n
+
+linkId :: Module -> Maybe Name -> Html -> Html
+linkId mdl mbName = linkIdOcc mdl (fmap nameOccName mbName) True
+
+linkIdOcc :: Module -> Maybe OccName -> Bool -> Html -> Html
+linkIdOcc mdl mbName insertAnchors =
+  if insertAnchors
+    then anchor ! [href url, title ttl]
+    else id
+  where
+    ttl = moduleNameString (moduleName mdl)
+    url = case mbName of
+      Nothing -> moduleUrl mdl
+      Just name -> moduleNameUrl mdl name
+
+linkIdOcc' :: ModuleName -> Maybe OccName -> Html -> Html
+linkIdOcc' mdl mbName = anchor ! [href url, title ttl]
+  where
+    ttl = moduleNameString mdl
+    url = case mbName of
+      Nothing -> moduleHtmlFile' mdl
+      Just name -> moduleNameUrl' mdl name
+
+ppModule :: Module -> Html
+ppModule mdl =
+  anchor
+    ! [href (moduleUrl mdl)]
+    << toHtml (moduleString mdl)
+
+ppModuleRef :: Maybe Html -> ModuleName -> String -> Html
+ppModuleRef Nothing mdl ref =
+  anchor
+    ! [href (moduleHtmlFile' mdl ++ ref)]
+    << toHtml (moduleNameString mdl)
+ppModuleRef (Just lbl) mdl ref =
+  anchor
+    ! [href (moduleHtmlFile' mdl ++ ref)]
+    << lbl
+
+-- NB: The ref parameter already includes the '#'.
+-- This function is only called from markupModule expanding a
+-- DocModule, which doesn't seem to be ever be used.
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Themes.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Themes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..604af00c5494c2ee6627053b864d54ca6d804dea
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Themes.hs
@@ -0,0 +1,213 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.Html.Themes
+-- Copyright   :  (c) Mark Lentczner 2010
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.Xhtml.Themes
+  ( Themes
+  , getThemes
+  , cssFiles
+  , styleSheet
+  )
+where
+
+import Haddock.Backends.Xhtml.Types (BaseURL, withBaseURL)
+import Haddock.Options
+
+import Control.Monad (liftM)
+import Data.Char (toLower)
+import Data.Either (lefts, rights)
+import Data.List (nub)
+import Data.Maybe (isJust, listToMaybe)
+
+import System.Directory
+import System.FilePath
+import Text.XHtml hiding (name, p, quote, title, (</>))
+import qualified Text.XHtml as XHtml
+
+--------------------------------------------------------------------------------
+
+-- * CSS Themes
+
+--------------------------------------------------------------------------------
+
+data Theme = Theme
+  { themeName :: String
+  , themeHref :: String
+  , themeFiles :: [FilePath]
+  }
+
+type Themes = [Theme]
+
+type PossibleTheme = Either String Theme
+type PossibleThemes = Either String Themes
+
+-- | Find a theme by name (case insensitive match)
+findTheme :: String -> Themes -> Maybe Theme
+findTheme s = listToMaybe . filter ((== ls) . lower . themeName)
+  where
+    lower = map toLower
+    ls = lower s
+
+-- | Standard theme used by default
+standardTheme :: FilePath -> IO PossibleThemes
+standardTheme libDir = liftM (liftEither (take 1)) (defaultThemes libDir)
+
+-- | Default themes that are part of Haddock; added with @--built-in-themes@
+-- The first theme in this list is considered the standard theme.
+-- Themes are "discovered" by scanning the html sub-dir of the libDir,
+-- and looking for directories with the extension .theme or .std-theme.
+-- The later is, obviously, the standard theme.
+defaultThemes :: FilePath -> IO PossibleThemes
+defaultThemes libDir = do
+  themeDirs <- getDirectoryItems (libDir </> "html")
+  themes <- mapM directoryTheme $ discoverThemes themeDirs
+  return $ sequenceEither themes
+  where
+    discoverThemes paths =
+      filterExt ".std-theme" paths ++ filterExt ".theme" paths
+    filterExt ext = filter ((== ext) . takeExtension)
+
+-- | Build a theme from a single .css file
+singleFileTheme :: FilePath -> IO PossibleTheme
+singleFileTheme path =
+  if isCssFilePath path
+    then retRight $ Theme name file [path]
+    else errMessage "File extension isn't .css" path
+  where
+    name = takeBaseName path
+    file = takeFileName path
+
+-- | Build a theme from a directory
+directoryTheme :: FilePath -> IO PossibleTheme
+directoryTheme path = do
+  items <- getDirectoryItems path
+  case filter isCssFilePath items of
+    [cf] -> retRight $ Theme (takeBaseName path) (takeFileName cf) items
+    [] -> errMessage "No .css file in theme directory" path
+    _ -> errMessage "More than one .css file in theme directory" path
+
+-- | Check if we have a built in theme
+doesBuiltInExist :: IO PossibleThemes -> String -> IO Bool
+doesBuiltInExist pts s = fmap (either (const False) test) pts
+  where
+    test = isJust . findTheme s
+
+-- | Find a built in theme
+builtInTheme :: IO PossibleThemes -> String -> IO PossibleTheme
+builtInTheme pts s = either Left fetch <$> pts
+  where
+    fetch = maybe (Left ("Unknown theme: " ++ s)) Right . findTheme s
+
+--------------------------------------------------------------------------------
+
+-- * CSS Theme Arguments
+
+--------------------------------------------------------------------------------
+
+-- | Process input flags for CSS Theme arguments
+getThemes :: FilePath -> [Flag] -> IO PossibleThemes
+getThemes libDir flags =
+  liftM concatEither (mapM themeFlag flags) >>= someTheme
+  where
+    themeFlag :: Flag -> IO (Either String Themes)
+    themeFlag (Flag_CSS path) = (liftM . liftEither) (: []) (theme path)
+    themeFlag (Flag_BuiltInThemes) = builtIns
+    themeFlag _ = retRight []
+
+    theme :: FilePath -> IO PossibleTheme
+    theme path =
+      pick
+        path
+        [ (doesFileExist, singleFileTheme)
+        , (doesDirectoryExist, directoryTheme)
+        , (doesBuiltInExist builtIns, builtInTheme builtIns)
+        ]
+        "Theme not found"
+
+    pick
+      :: FilePath
+      -> [(FilePath -> IO Bool, FilePath -> IO PossibleTheme)]
+      -> String
+      -> IO PossibleTheme
+    pick path [] msg = errMessage msg path
+    pick path ((test, build) : opts) msg = do
+      pass <- test path
+      if pass then build path else pick path opts msg
+
+    someTheme :: Either String Themes -> IO (Either String Themes)
+    someTheme (Right []) = standardTheme libDir
+    someTheme est = return est
+
+    builtIns = defaultThemes libDir
+
+errMessage :: String -> FilePath -> IO (Either String a)
+errMessage msg path = return (Left msg')
+  where
+    msg' = "Error: " ++ msg ++ ": \"" ++ path ++ "\"\n"
+
+retRight :: a -> IO (Either String a)
+retRight = return . Right
+
+--------------------------------------------------------------------------------
+
+-- * File Utilities
+
+--------------------------------------------------------------------------------
+
+getDirectoryItems :: FilePath -> IO [FilePath]
+getDirectoryItems path =
+  map (combine path) . filter notDot <$> getDirectoryContents path
+  where
+    notDot s = s /= "." && s /= ".."
+
+isCssFilePath :: FilePath -> Bool
+isCssFilePath path = takeExtension path == ".css"
+
+--------------------------------------------------------------------------------
+
+-- * Style Sheet Utilities
+
+--------------------------------------------------------------------------------
+
+cssFiles :: Themes -> [String]
+cssFiles ts = nub $ concatMap themeFiles ts
+
+styleSheet :: BaseURL -> Themes -> Html
+styleSheet base_url ts = toHtml $ zipWith mkLink rels ts
+  where
+    rels = "stylesheet" : repeat "alternate stylesheet"
+    mkLink aRel t =
+      thelink
+        ! [ href (withBaseURL base_url (themeHref t))
+          , rel aRel
+          , thetype "text/css"
+          , XHtml.title (themeName t)
+          ]
+        << noHtml
+
+--------------------------------------------------------------------------------
+
+-- * Either Utilities
+
+--------------------------------------------------------------------------------
+
+-- These three routines are here because Haddock does not have access to the
+-- Control.Monad.Error module which supplies the Functor and Monad instances
+-- for Either String.
+
+sequenceEither :: [Either a b] -> Either a [b]
+sequenceEither es = maybe (Right $ rights es) Left (listToMaybe (lefts es))
+
+liftEither :: (b -> c) -> Either a b -> Either a c
+liftEither f = either Left (Right . f)
+
+concatEither :: [Either a [b]] -> Either a [b]
+concatEither = liftEither concat . sequenceEither
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Types.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Types.hs
new file mode 100644
index 0000000000000000000000000000000000000000..25bbcff4594bad613b6a8718749248e1d3c17c5d
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Types.hs
@@ -0,0 +1,48 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.Html.Types
+-- Copyright   :  (c) Simon Marlow   2003-2006,
+--                    David Waern    2006-2009,
+--                    Mark Lentczner 2010
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.Xhtml.Types
+  ( SourceURLs
+  , WikiURLs
+  , BaseURL
+  , withBaseURL
+  , LinksInfo
+  , Splice
+  , Unicode
+  ) where
+
+import Data.Map
+import GHC
+import qualified System.FilePath as FilePath
+
+-- the base, module and entity URLs for the source code and wiki links.
+type SourceURLs = (Maybe FilePath, Maybe FilePath, Map Unit FilePath, Map Unit FilePath)
+type WikiURLs = (Maybe FilePath, Maybe FilePath, Maybe FilePath)
+
+-- | base url for loading js, json, css resources.  The default is "."
+type BaseURL = Maybe String
+
+-- TODO: we shouldn't use 'FilePath.</>'
+withBaseURL :: BaseURL -> String -> String
+withBaseURL Nothing uri = uri
+withBaseURL (Just baseUrl) uri = baseUrl FilePath.</> uri
+
+-- The URL for source and wiki links
+type LinksInfo = (SourceURLs, WikiURLs)
+
+-- Whether something is a splice or not
+type Splice = Bool
+
+-- Whether unicode syntax is to be used
+type Unicode = Bool
diff --git a/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
new file mode 100644
index 0000000000000000000000000000000000000000..53c3d37315b8a156baf40334dce9fabadc0d4fee
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
@@ -0,0 +1,244 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Backends.Html.Util
+-- Copyright   :  (c) Simon Marlow   2003-2006,
+--                    David Waern    2006-2009,
+--                    Mark Lentczner 2010
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Backends.Xhtml.Utils
+  ( renderToString
+  , namedAnchor
+  , linkedAnchor
+  , spliceURL
+  , spliceURL'
+  , groupId
+  , (<+>)
+  , (<=>)
+  , char
+  , keyword
+  , punctuate
+  , braces
+  , brackets
+  , pabrackets
+  , parens
+  , parenList
+  , ubxParenList
+  , ubxSumList
+  , arrow
+  , lollipop
+  , comma
+  , dcolon
+  , dot
+  , darrow
+  , equals
+  , forallSymbol
+  , quote
+  , promoQuote
+  , multAnnotation
+  , atSign
+  , hsep
+  , vcat
+  , DetailsState (..)
+  , collapseDetails
+  , thesummary
+  , collapseToggle
+  , collapseControl
+  ) where
+
+import Haddock.Utils
+
+import Text.XHtml hiding (name, p, quote, title)
+import qualified Text.XHtml as XHtml
+
+import GHC (Name, SrcSpan (..), srcSpanStartLine)
+import GHC.Types.Name (getOccString, isValOcc, nameOccName)
+import GHC.Unit.Module (Module, ModuleName, moduleName, moduleNameString)
+
+-- | Replace placeholder string elements with provided values.
+--
+-- Used to generate URL for customized external paths, usually provided with
+-- @--source-module@, @--source-entity@ and related command-line arguments.
+--
+-- >>> spliceURL mmod mname Nothing "output/%{MODULE}.hs#%{NAME}"
+-- "output/Foo.hs#foo"
+spliceURL
+  :: Maybe Module
+  -> Maybe GHC.Name
+  -> Maybe SrcSpan
+  -> String
+  -> String
+spliceURL mmod = spliceURL' (moduleName <$> mmod)
+
+-- | Same as 'spliceURL' but takes 'ModuleName' instead of 'Module'.
+spliceURL'
+  :: Maybe ModuleName
+  -> Maybe GHC.Name
+  -> Maybe SrcSpan
+  -> String
+  -> String
+spliceURL' maybe_mod maybe_name maybe_loc = run
+  where
+    mdl = case maybe_mod of
+      Nothing -> ""
+      Just m -> moduleNameString m
+
+    (name, kind) =
+      case maybe_name of
+        Nothing -> ("", "")
+        Just n
+          | isValOcc (nameOccName n) -> (escapeStr (getOccString n), "v")
+          | otherwise -> (escapeStr (getOccString n), "t")
+
+    line = case maybe_loc of
+      Nothing -> ""
+      Just span_ ->
+        case span_ of
+          RealSrcSpan span__ _ ->
+            show $ srcSpanStartLine span__
+          UnhelpfulSpan _ -> ""
+
+    run "" = ""
+    run ('%' : 'M' : rest) = mdl ++ run rest
+    run ('%' : 'N' : rest) = name ++ run rest
+    run ('%' : 'K' : rest) = kind ++ run rest
+    run ('%' : 'L' : rest) = line ++ run rest
+    run ('%' : '%' : rest) = '%' : run rest
+    run ('%' : '{' : 'M' : 'O' : 'D' : 'U' : 'L' : 'E' : '}' : rest) = mdl ++ run rest
+    run ('%' : '{' : 'N' : 'A' : 'M' : 'E' : '}' : rest) = name ++ run rest
+    run ('%' : '{' : 'K' : 'I' : 'N' : 'D' : '}' : rest) = kind ++ run rest
+    run ('%' : '{' : 'M' : 'O' : 'D' : 'U' : 'L' : 'E' : '/' : '.' : '/' : c : '}' : rest) =
+      map (\x -> if x == '.' then c else x) mdl ++ run rest
+    run ('%' : '{' : 'L' : 'I' : 'N' : 'E' : '}' : rest) = line ++ run rest
+    run (c : rest) = c : run rest
+
+renderToString :: Bool -> Html -> String
+renderToString debug html
+  | debug = renderHtml html
+  | otherwise = showHtml html
+
+hsep :: [Html] -> Html
+hsep [] = noHtml
+hsep htmls = foldr1 (<+>) htmls
+
+-- | Concatenate a series of 'Html' values vertically, with linebreaks in between.
+vcat :: [Html] -> Html
+vcat [] = noHtml
+vcat htmls = foldr1 (\a b -> a +++ br +++ b) htmls
+
+infixr 8 <+>
+(<+>) :: Html -> Html -> Html
+a <+> b = a +++ sep +++ b
+  where
+    sep = if isNoHtml a || isNoHtml b then noHtml else toHtml " "
+
+-- | Join two 'Html' values together with a linebreak in between.
+--   Has 'noHtml' as left identity.
+infixr 8 <=>
+
+(<=>) :: Html -> Html -> Html
+a <=> b = a +++ sep +++ b
+  where
+    sep = if isNoHtml a then noHtml else br
+
+keyword :: String -> Html
+keyword s = thespan ! [theclass "keyword"] << toHtml s
+
+equals, comma :: Html
+equals = char '='
+comma = char ','
+
+char :: Char -> Html
+char c = toHtml [c]
+
+quote :: Html -> Html
+quote h = char '`' +++ h +++ '`'
+
+-- | Promoted type quote (e.g. @'[a, b]@, @'(a, b, c)@).
+promoQuote :: Html -> Html
+promoQuote h = char '\'' +++ h
+
+parens, brackets, pabrackets, braces :: Html -> Html
+parens h = char '(' +++ h +++ char ')'
+brackets h = char '[' +++ h +++ char ']'
+pabrackets h = toHtml "[:" +++ h +++ toHtml ":]"
+braces h = char '{' +++ h +++ char '}'
+
+punctuate :: Html -> [Html] -> [Html]
+punctuate _ [] = []
+punctuate h (d0 : ds) = go d0 ds
+  where
+    go d [] = [d]
+    go d (e : es) = (d +++ h) : go e es
+
+parenList :: [Html] -> Html
+parenList = parens . hsep . punctuate comma
+
+ubxParenList :: [Html] -> Html
+ubxParenList = ubxparens . hsep . punctuate comma
+
+ubxSumList :: [Html] -> Html
+ubxSumList = ubxparens . hsep . punctuate (toHtml " | ")
+
+ubxparens :: Html -> Html
+ubxparens h = toHtml "(#" <+> h <+> toHtml "#)"
+
+dcolon, arrow, lollipop, darrow, forallSymbol :: Bool -> Html
+dcolon unicode = toHtml (if unicode then "∷" else "::")
+arrow unicode = toHtml (if unicode then "→" else "->")
+lollipop unicode = toHtml (if unicode then "⊸" else "%1 ->")
+darrow unicode = toHtml (if unicode then "⇒" else "=>")
+forallSymbol unicode = if unicode then toHtml "∀" else keyword "forall"
+
+atSign :: Html
+atSign = toHtml "@"
+
+multAnnotation :: Html
+multAnnotation = toHtml "%"
+
+dot :: Html
+dot = toHtml "."
+
+-- | Generate a named anchor
+namedAnchor :: String -> Html -> Html
+namedAnchor n = anchor ! [XHtml.identifier n]
+
+linkedAnchor :: String -> Html -> Html
+linkedAnchor n = anchor ! [href ('#' : n)]
+
+-- | generate an anchor identifier for a group
+groupId :: String -> String
+groupId g = makeAnchorId ("g:" ++ g)
+
+--
+-- A section of HTML which is collapsible.
+--
+
+data DetailsState = DetailsOpen | DetailsClosed
+
+collapseDetails :: String -> DetailsState -> Html -> Html
+collapseDetails id_ state = tag "details" ! (identifier id_ : openAttrs)
+  where
+    openAttrs = case state of DetailsOpen -> [emptyAttr "open"]; DetailsClosed -> []
+
+thesummary :: Html -> Html
+thesummary = tag "summary"
+
+-- | Attributes for an area that toggles a collapsed area
+collapseToggle :: String -> String -> [HtmlAttr]
+collapseToggle id_ classes = [theclass cs, strAttr "data-details-id" id_]
+  where
+    cs = unwords (words classes ++ ["details-toggle"])
+
+-- | Attributes for an area that toggles a collapsed area,
+-- and displays a control.
+collapseControl :: String -> String -> [HtmlAttr]
+collapseControl id_ classes = collapseToggle id_ cs
+  where
+    cs = unwords (words classes ++ ["details-toggle-control"])
diff --git a/utils/haddock/haddock-api/src/Haddock/Convert.hs b/utils/haddock/haddock-api/src/Haddock/Convert.hs
new file mode 100644
index 0000000000000000000000000000000000000000..5cfb4d84f0e074bd4af9a4208f5dfb2bae5ba4c0
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Convert.hs
@@ -0,0 +1,1160 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE PatternGuards #-}
+{-# LANGUAGE TypeFamilies #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Convert
+-- Copyright   :  (c) Isaac Dupree 2009,
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Conversion between TyThing and HsDecl. This functionality may be moved into
+-- GHC at some point.
+module Haddock.Convert
+  ( tyThingToLHsDecl
+  , synifyInstHead
+  , synifyFamInst
+  , PrintRuntimeReps (..)
+  ) where
+
+import Control.DeepSeq (force)
+import GHC.Core.Class
+import GHC.Core.Coercion.Axiom
+import GHC.Core.ConLike
+import GHC.Core.DataCon
+import GHC.Core.FamInstEnv
+import GHC.Core.PatSyn
+import GHC.Core.TyCo.Compare (eqTypes)
+import GHC.Core.TyCo.Rep
+import GHC.Core.TyCon
+import GHC.Core.Type
+import GHC.Data.Bag (emptyBag)
+import GHC.Types.Basic (DefMethSpec (..), TopLevelFlag (..), TupleSort (..))
+import GHC.Types.Fixity (LexicalFixity (..))
+import GHC.Types.SourceText (SourceText (..))
+
+import GHC.Builtin.Names
+  ( boxedRepDataConKey
+  , eqTyConKey
+  , hasKey
+  , ipClassKey
+  , liftedDataConKey
+  , tYPETyConKey
+  )
+import GHC.Builtin.Types
+  ( eqTyConName
+  , liftedTypeKindTyConName
+  , listTyConName
+  , promotedConsDataCon
+  , promotedNilDataCon
+  , unitTy
+  )
+import GHC.Builtin.Types.Prim (alphaTyVars)
+import GHC.Hs
+import GHC.Types.Id (idType, setIdType)
+import GHC.Types.Name
+import GHC.Types.Name.Reader (mkVarUnqual)
+import GHC.Types.Name.Set (emptyNameSet)
+import GHC.Types.SrcLoc
+import GHC.Types.TyThing
+import GHC.Types.Unique (getUnique)
+import GHC.Types.Var
+import GHC.Types.Var.Set
+import GHC.Unit.Types
+import GHC.Utils.Misc
+  ( chkAppend
+  , dropList
+  , equalLength
+  , filterByList
+  , filterOut
+  )
+import GHC.Utils.Panic.Plain (assert)
+
+import Language.Haskell.Syntax.Basic (FieldLabelString (..))
+
+import Haddock.GhcUtils (defaultRuntimeRepVars, mkEmptySigType, orderedFVs)
+import Haddock.Interface.RenameType
+import Haddock.Types
+
+import Data.Either (lefts, partitionEithers, rights)
+import Data.Maybe (catMaybes, mapMaybe, maybeToList)
+
+-- | Whether or not to default 'RuntimeRep' variables to 'LiftedRep'. Check
+-- out Note [Defaulting RuntimeRep variables] in GHC.Iface.Type for the
+-- motivation.
+data PrintRuntimeReps = ShowRuntimeRep | HideRuntimeRep deriving (Show)
+
+-- the main function here! yay!
+tyThingToLHsDecl
+  :: PrintRuntimeReps
+  -> TyThing
+  -> Either String ([String], (HsDecl GhcRn))
+tyThingToLHsDecl prr t = case t of
+  -- ids (functions and zero-argument a.k.a. CAFs) get a type signature.
+  -- Including built-in functions like seq.
+  -- foreign-imported functions could be represented with ForD
+  -- instead of SigD if we wanted...
+  --
+  -- in a future code version we could turn idVarDetails = foreign-call
+  -- into a ForD instead of a SigD if we wanted.  Haddock doesn't
+  -- need to care.
+  AnId i -> allOK $ SigD noExtField (synifyIdSig prr ImplicitizeForAll [] i)
+  -- type-constructors (e.g. Maybe) are complicated, put the definition
+  -- later in the file (also it's used for class associated-types too.)
+  ATyCon tc
+    | Just cl <- tyConClass_maybe tc -> -- classes are just a little tedious
+        let extractFamilyDecl :: TyClDecl a -> Either String (FamilyDecl a)
+            extractFamilyDecl (FamDecl _ d) = return d
+            extractFamilyDecl _ =
+              Left "tyThingToLHsDecl: impossible associated tycon"
+
+            cvt :: HsTyVarBndr flag GhcRn -> HsType GhcRn
+            -- Without this signature, we trigger GHC#18932
+            cvt (UserTyVar _ _ n) = HsTyVar noAnn NotPromoted n
+            cvt (KindedTyVar _ _ (L name_loc n) kind) =
+              HsKindSig
+                noAnn
+                (L (l2l name_loc) (HsTyVar noAnn NotPromoted (L name_loc n)))
+                kind
+
+            -- \| Convert a LHsTyVarBndr to an equivalent LHsType.
+            hsLTyVarBndrToType :: LHsTyVarBndr flag GhcRn -> LHsType GhcRn
+            hsLTyVarBndrToType = fmap cvt
+
+            extractFamDefDecl :: FamilyDecl GhcRn -> Type -> TyFamDefltDecl GhcRn
+            extractFamDefDecl fd rhs =
+              TyFamInstDecl noAnn $
+                FamEqn
+                  { feqn_ext = noAnn
+                  , feqn_tycon = fdLName fd
+                  , feqn_bndrs = HsOuterImplicit{hso_ximplicit = hsq_ext (fdTyVars fd)}
+                  , feqn_pats =
+                      map (HsValArg noExtField . hsLTyVarBndrToType) $
+                        hsq_explicit $
+                          fdTyVars fd
+                  , feqn_fixity = fdFixity fd
+                  , feqn_rhs = synifyType WithinType [] rhs
+                  }
+
+            extractAtItem
+              :: ClassATItem
+              -> Either String (LFamilyDecl GhcRn, Maybe (LTyFamDefltDecl GhcRn))
+            extractAtItem (ATI at_tc def) = do
+              tyDecl <- synifyTyCon prr Nothing at_tc
+              famDecl <- extractFamilyDecl tyDecl
+              let defEqnTy = fmap (noLocA . extractFamDefDecl famDecl . fst) def
+              pure (noLocA famDecl, defEqnTy)
+
+            atTyClDecls = map extractAtItem (classATItems cl)
+            (atFamDecls, atDefFamDecls) = unzip (rights atTyClDecls)
+            vs = tyConVisibleTyVars (classTyCon cl)
+         in withErrs (lefts atTyClDecls) . TyClD noExtField $
+              ClassDecl
+                { -- This should not always be `Just`, since `Just` of an empty
+                  -- context causes pretty printing to print `()` for the
+                  -- context
+                  tcdCtxt =
+                    case classSCTheta cl of
+                      [] -> Nothing
+                      th -> Just $ synifyCtx th
+                , tcdLName = synifyNameN cl
+                , tcdTyVars = synifyTyVars vs
+                , tcdFixity = synifyFixity cl
+                , tcdFDs =
+                    map
+                      ( \(l, r) ->
+                          noLocA
+                            (FunDep noAnn (map (noLocA . getName) l) (map (noLocA . getName) r))
+                      )
+                      $ snd
+                      $ classTvsFds cl
+                , tcdSigs =
+                    noLocA (MinimalSig (noAnn, NoSourceText) . noLocA . fmap noLocA $ classMinimalDef cl)
+                      : [ noLocA tcdSig
+                        | clsOp <- classOpItems cl
+                        , tcdSig <- synifyTcIdSig vs clsOp
+                        ]
+                , tcdMeths = emptyBag -- ignore default method definitions, they don't affect signature
+                -- class associated-types are a subset of TyCon:
+                , tcdATs = atFamDecls
+                , tcdATDefs = catMaybes atDefFamDecls
+                , tcdDocs = [] -- we don't have any docs at this point
+                , tcdCExt = emptyNameSet
+                }
+    | otherwise ->
+        synifyTyCon prr Nothing tc >>= allOK . TyClD noExtField
+  -- type-constructors (e.g. Maybe) are complicated, put the definition
+  -- later in the file (also it's used for class associated-types too.)
+  ACoAxiom ax -> synifyAxiom ax >>= allOK
+  -- a data-constructor alone just gets rendered as a function:
+  AConLike (RealDataCon dc) ->
+    allOK $
+      SigD
+        noExtField
+        ( TypeSig
+            noAnn
+            [synifyNameN dc]
+            (synifySigWcType ImplicitizeForAll [] (dataConWrapperType dc))
+        )
+  AConLike (PatSynCon ps) ->
+    allOK . SigD noExtField $ PatSynSig noAnn [synifyNameN ps] (synifyPatSynSigType ps)
+  where
+    withErrs e x = return (e, x)
+    allOK x = return (mempty, x)
+
+synifyAxBranch :: TyCon -> CoAxBranch -> TyFamInstEqn GhcRn
+synifyAxBranch tc (CoAxBranch{cab_tvs = tkvs, cab_lhs = args, cab_rhs = rhs}) =
+  let name = synifyNameN tc
+      args_types_only = filterOutInvisibleTypes tc args
+      typats = map (synifyType WithinType []) args_types_only
+      annot_typats = zipWith3 annotHsType args_poly args_types_only typats
+      hs_rhs = synifyType WithinType [] rhs
+      outer_bndrs = HsOuterImplicit{hso_ximplicit = map tyVarName tkvs}
+   in -- TODO: this must change eventually
+      FamEqn
+        { feqn_ext = noAnn
+        , feqn_tycon = name
+        , feqn_bndrs = outer_bndrs
+        , feqn_pats = map (HsValArg noExtField) annot_typats
+        , feqn_fixity = synifyFixity name
+        , feqn_rhs = hs_rhs
+        }
+  where
+    args_poly = tyConArgsPolyKinded tc
+
+synifyAxiom :: CoAxiom br -> Either String (HsDecl GhcRn)
+synifyAxiom ax@(CoAxiom{co_ax_tc = tc})
+  | isOpenTypeFamilyTyCon tc
+  , Just branch <- coAxiomSingleBranch_maybe ax =
+      return $
+        InstD noExtField $
+          TyFamInstD noExtField $
+            TyFamInstDecl{tfid_xtn = noAnn, tfid_eqn = synifyAxBranch tc branch}
+  | Just ax' <- isClosedSynFamilyTyConWithAxiom_maybe tc
+  , getUnique ax' == getUnique ax -- without the getUniques, type error
+    =
+      synifyTyCon ShowRuntimeRep (Just ax) tc >>= return . TyClD noExtField
+  | otherwise =
+      Left "synifyAxiom: closed/open family confusion"
+
+-- | Turn type constructors into data declarations, type families, or type synonyms
+synifyTyCon
+  :: PrintRuntimeReps
+  -> Maybe (CoAxiom br)
+  -- ^ RHS of type synonym
+  -> TyCon
+  -- ^ type constructor to convert
+  -> Either String (TyClDecl GhcRn)
+synifyTyCon prr _coax tc
+  | isPrimTyCon tc =
+      return $
+        DataDecl
+          { tcdLName = synifyNameN tc
+          , tcdTyVars =
+              HsQTvs
+                { hsq_ext = [] -- No kind polymorphism
+                , hsq_explicit =
+                    zipWith
+                      mk_hs_tv
+                      (map scaledThing tyVarKinds)
+                      alphaTyVars -- a, b, c... which are unfortunately all kind *
+                }
+          , tcdFixity = synifyFixity tc
+          , tcdDataDefn =
+              HsDataDefn
+                { dd_ext = noExtField
+                , dd_cons = DataTypeCons False [] -- No constructors; arbitrary lie, they are neither
+                -- algebraic data nor newtype:
+                , dd_ctxt = Nothing
+                , dd_cType = Nothing
+                , dd_kindSig = synifyDataTyConReturnKind tc
+                , -- we have their kind accurately:
+                  dd_derivs = []
+                }
+          , tcdDExt = DataDeclRn False emptyNameSet
+          }
+  where
+    -- tyConTyVars doesn't work on fun/prim, but we can make them up:
+    mk_hs_tv realKind fakeTyVar
+      | isLiftedTypeKind realKind = noLocA $ UserTyVar noAnn (HsBndrRequired noExtField) (noLocA (getName fakeTyVar))
+      | otherwise = noLocA $ KindedTyVar noAnn (HsBndrRequired noExtField) (noLocA (getName fakeTyVar)) (synifyKindSig realKind)
+
+    conKind = defaultType prr (tyConKind tc)
+    tyVarKinds = fst . splitFunTys . snd . splitInvisPiTys $ conKind
+synifyTyCon _prr _coax tc
+  | Just flav <- famTyConFlav_maybe tc =
+      case flav of
+        -- Type families
+        OpenSynFamilyTyCon -> mkFamDecl OpenTypeFamily
+        ClosedSynFamilyTyCon mb
+          | Just (CoAxiom{co_ax_branches = branches}) <- mb ->
+              mkFamDecl $
+                ClosedTypeFamily $
+                  Just $
+                    map (noLocA . synifyAxBranch tc) (fromBranches branches)
+          | otherwise ->
+              mkFamDecl $ ClosedTypeFamily $ Just []
+        BuiltInSynFamTyCon{} ->
+          mkFamDecl $ ClosedTypeFamily $ Just []
+        AbstractClosedSynFamilyTyCon{} ->
+          mkFamDecl $ ClosedTypeFamily Nothing
+        DataFamilyTyCon{} ->
+          mkFamDecl DataFamily
+  where
+    resultVar = tyConFamilyResVar_maybe tc
+    mkFamDecl i =
+      return $
+        FamDecl noExtField $
+          FamilyDecl
+            { fdExt = noAnn
+            , fdInfo = i
+            , fdTopLevel = TopLevel
+            , fdLName = synifyNameN tc
+            , fdTyVars = synifyTyVars (tyConVisibleTyVars tc)
+            , fdFixity = synifyFixity tc
+            , fdResultSig = synifyFamilyResultSig resultVar (tyConResKind tc)
+            , fdInjectivityAnn =
+                synifyInjectivityAnn
+                  resultVar
+                  (tyConTyVars tc)
+                  (tyConInjectivityInfo tc)
+            }
+synifyTyCon _prr coax tc
+  -- type synonyms
+  | Just ty <- synTyConRhs_maybe tc =
+      return $
+        SynDecl
+          { tcdSExt = emptyNameSet
+          , tcdLName = synifyNameN tc
+          , tcdTyVars = synifyTyVars (tyConVisibleTyVars tc)
+          , tcdFixity = synifyFixity tc
+          , tcdRhs = synifyType WithinType [] ty
+          }
+  -- (closed) newtype and data
+  | otherwise = do
+      let
+        -- This should not always be `Just`, since `Just` of an empty
+        -- context causes pretty printing to print `()` for the context
+        alg_ctx =
+          case tyConStupidTheta tc of
+            [] -> Nothing
+            th -> Just $ synifyCtx th
+
+        -- Data families are named according to their CoAxioms, not their TyCons
+        name = case coax of
+          Just a -> synifyNameN a
+          _ -> synifyNameN tc
+
+        -- For a data declaration:
+        --   data Vec :: Nat -> Type -> Type where
+        -- GHC will still report visible tyvars with default names 'a' and 'b'.
+        -- Since 'Nat' is not inhabited by lifted types, 'a' will be given a kind
+        -- signature (due to the logic in 'synify_ty_var'). Similarly, 'Vec'
+        -- constructs lifted types and will therefore not be given a result kind
+        -- signature. Thus, the generated documentation for 'Vec' will look like:
+        -- data Vec (a :: Nat) b where
+        tyvars = synifyTyVars (tyConVisibleTyVars tc)
+        kindSig = synifyDataTyConReturnKind tc
+
+        -- The data constructors.
+        --
+        -- Any data-constructors not exported from the module that *defines* the
+        -- type will not (cannot) be included.
+        --
+        -- Very simple constructors, Haskell98 with no existentials or anything,
+        -- probably look nicer in non-GADT syntax.  In source code, all constructors
+        -- must be declared with the same (GADT vs. not) syntax, and it probably
+        -- is less confusing to follow that principle for the documentation as well.
+        --
+        -- There is no sensible infix-representation for GADT-syntax constructor
+        -- declarations.  They cannot be made in source code, but we could end up
+        -- with some here in the case where some constructors use existentials.
+        -- That seems like an acceptable compromise (they'll just be documented
+        -- in prefix position), since, otherwise, the logic (at best) gets much more
+        -- complicated. (would use dataConIsInfix.)
+        use_gadt_syntax = isGadtSyntaxTyCon tc
+
+      consRaw <-
+        case partitionEithers $
+          synifyDataCon use_gadt_syntax
+            <$> tyConDataCons tc of
+          ([], cs) -> Right cs
+          (errs, _) -> Left (unlines errs)
+
+      cons <- case (isNewTyCon tc, consRaw) of
+        (False, cons) -> Right (DataTypeCons False cons)
+        (True, [con]) -> Right (NewTypeCon con)
+        (True, _) -> Left "Newtype hasn't 1 constructor"
+
+      let
+        -- "deriving" doesn't affect the signature, no need to specify any.
+        alg_deriv = []
+        defn =
+          HsDataDefn
+            { dd_ext = noExtField
+            , dd_ctxt = alg_ctx
+            , dd_cType = Nothing
+            , dd_kindSig = kindSig
+            , dd_cons = cons
+            , dd_derivs = alg_deriv
+            }
+      pure
+        DataDecl
+          { tcdLName = name
+          , tcdTyVars = tyvars
+          , tcdFixity = synifyFixity name
+          , tcdDataDefn = defn
+          , tcdDExt = DataDeclRn False emptyNameSet
+          }
+
+-- | In this module, every TyCon being considered has come from an interface
+-- file. This means that when considering a data type constructor such as:
+--
+-- > data Foo (w :: *) (m :: * -> *) (a :: *)
+--
+-- Then its tyConKind will be (* -> (* -> *) -> * -> *). But beware! We are
+-- also rendering the type variables of Foo, so if we synify the tyConKind of
+-- Foo in full, we will end up displaying this in Haddock:
+--
+-- > data Foo (w :: *) (m :: * -> *) (a :: *)
+-- >   :: * -> (* -> *) -> * -> *
+--
+-- Which is entirely wrong (#548). We only want to display the /return/ kind,
+-- which this function obtains.
+synifyDataTyConReturnKind :: TyCon -> Maybe (LHsKind GhcRn)
+synifyDataTyConReturnKind tc
+  | isLiftedTypeKind ret_kind = Nothing -- Don't bother displaying :: *
+  | otherwise = Just (synifyKindSig ret_kind)
+  where
+    ret_kind = tyConResKind tc
+
+synifyInjectivityAnn
+  :: Maybe Name
+  -> [TyVar]
+  -> Injectivity
+  -> Maybe (LInjectivityAnn GhcRn)
+synifyInjectivityAnn (Just lhs) tvs (Injective inj) =
+  let rhs = map (noLocA . tyVarName) (filterByList inj tvs)
+   in Just $ noLocA $ InjectivityAnn noAnn (noLocA lhs) rhs
+synifyInjectivityAnn _ _ _ = Nothing
+
+synifyFamilyResultSig :: Maybe Name -> Kind -> LFamilyResultSig GhcRn
+synifyFamilyResultSig Nothing kind
+  | isLiftedTypeKind kind =
+      noLocA $ NoSig noExtField
+  | otherwise =
+      noLocA $ KindSig noExtField (synifyKindSig kind)
+synifyFamilyResultSig (Just name) kind =
+  noLocA $ TyVarSig noExtField (noLocA $ KindedTyVar noAnn () (noLocA name) (synifyKindSig kind))
+
+-- User beware: it is your responsibility to pass True (use_gadt_syntax) for any
+-- constructor that would be misrepresented by omitting its result-type. But you
+-- might want pass False in simple enough cases, if you think it looks better.
+synifyDataCon :: Bool -> DataCon -> Either String (LConDecl GhcRn)
+synifyDataCon use_gadt_syntax dc =
+  let
+    -- dataConIsInfix allegedly tells us whether it was declared with
+    -- infix *syntax*.
+    use_infix_syntax = dataConIsInfix dc
+    use_named_field_syntax = not (null field_tys)
+    name = synifyNameN dc
+    -- con_qvars means a different thing depending on gadt-syntax
+    (_univ_tvs, ex_tvs, _eq_spec, theta, arg_tys, res_ty) = dataConFullSig dc
+    user_tvbndrs = dataConUserTyVarBinders dc -- Used for GADT data constructors
+    outer_bndrs
+      | null user_tvbndrs =
+          HsOuterImplicit{hso_ximplicit = []}
+      | otherwise =
+          HsOuterExplicit
+            { hso_xexplicit = noExtField
+            , hso_bndrs = map synifyTyVarBndr user_tvbndrs
+            }
+
+    -- skip any EqTheta, use 'orig'inal syntax
+    ctx
+      | null theta = Nothing
+      | otherwise = Just $ synifyCtx theta
+
+    linear_tys =
+      zipWith
+        ( \ty bang ->
+            let tySyn = synifyType WithinType [] (scaledThing ty)
+             in case bang of
+                  (HsSrcBang _ NoSrcUnpack NoSrcStrict) -> tySyn
+                  bang' -> noLocA $ HsBangTy noAnn bang' tySyn
+        )
+        arg_tys
+        (dataConSrcBangs dc)
+
+    field_tys = zipWith con_decl_field (dataConFieldLabels dc) linear_tys
+    con_decl_field fl synTy =
+      noLocA $
+        ConDeclField
+          noAnn
+          [noLocA $ FieldOcc (flSelector fl) (noLocA $ mkVarUnqual $ field_label $ flLabel fl)]
+          synTy
+          Nothing
+
+    mk_h98_arg_tys :: Either String (HsConDeclH98Details GhcRn)
+    mk_h98_arg_tys = case (use_named_field_syntax, use_infix_syntax) of
+      (True, True) -> Left "synifyDataCon: contradiction!"
+      (True, False) -> return $ RecCon (noLocA field_tys)
+      (False, False) -> return $ PrefixCon noTypeArgs (map hsUnrestricted linear_tys)
+      (False, True) -> case linear_tys of
+        [a, b] -> return $ InfixCon (hsUnrestricted a) (hsUnrestricted b)
+        _ -> Left "synifyDataCon: infix with non-2 args?"
+
+    mk_gadt_arg_tys :: HsConDeclGADTDetails GhcRn
+    mk_gadt_arg_tys
+      | use_named_field_syntax = RecConGADT noExtField (noLocA field_tys)
+      | otherwise = PrefixConGADT noExtField (map hsUnrestricted linear_tys)
+   in
+    -- finally we get synifyDataCon's result!
+    if use_gadt_syntax
+      then do
+        let hat = mk_gadt_arg_tys
+        return $
+          noLocA $
+            ConDeclGADT
+              { con_g_ext = noExtField
+              , con_names = pure name
+              , con_bndrs = noLocA outer_bndrs
+              , con_mb_cxt = ctx
+              , con_g_args = hat
+              , con_res_ty = synifyType WithinType [] res_ty
+              , con_doc = Nothing
+              }
+      else do
+        hat <- mk_h98_arg_tys
+        return $
+          noLocA $
+            ConDeclH98
+              { con_ext = noExtField
+              , con_name = name
+              , con_forall = False
+              , con_ex_tvs = map (synifyTyVarBndr . (mkForAllTyBinder InferredSpec)) ex_tvs
+              , con_mb_cxt = ctx
+              , con_args = hat
+              , con_doc = Nothing
+              }
+
+synifyNameN :: NamedThing n => n -> LocatedN Name
+synifyNameN n = L (noAnnSrcSpan $! srcLocSpan (getSrcLoc n)) (getName n)
+
+-- synifyName :: NamedThing n => n -> LocatedA Name
+-- synifyName n = L (noAnnSrcSpan $ srcLocSpan (getSrcLoc n)) (getName n)
+
+-- | Guess the fixity of a something with a name. This isn't quite right, since
+-- a user can always declare an infix name in prefix form or a prefix name in
+-- infix form. Unfortunately, that is not something we can usually reconstruct.
+synifyFixity :: NamedThing n => n -> LexicalFixity
+synifyFixity n
+  | isSymOcc (getOccName n) = Infix
+  | otherwise = Prefix
+
+synifyIdSig
+  :: PrintRuntimeReps
+  -- ^ are we printing tyvars of kind 'RuntimeRep'?
+  -> SynifyTypeState
+  -- ^ what to do with a 'forall'
+  -> [TyVar]
+  -- ^ free variables in the type to convert
+  -> Id
+  -- ^ the 'Id' from which to get the type signature
+  -> Sig GhcRn
+synifyIdSig prr s vs i = TypeSig noAnn [n] (synifySigWcType s vs t)
+  where
+    !n = force $ synifyNameN i
+    t = defaultType prr (varType i)
+
+-- | Turn a 'ClassOpItem' into a list of signatures. The list returned is going
+-- to contain the synified 'ClassOpSig' as well (when appropriate) a default
+-- 'ClassOpSig'.
+synifyTcIdSig :: [TyVar] -> ClassOpItem -> [Sig GhcRn]
+synifyTcIdSig vs (i, dm) =
+  [ClassOpSig noAnn False [synifyNameN i] (mainSig (varType i))]
+    ++ [ ClassOpSig noAnn True [noLocA dn] (defSig dt)
+       | Just (dn, GenericDM dt) <- [dm]
+       ]
+  where
+    mainSig t = synifySigType DeleteTopLevelQuantification vs t
+    defSig t = synifySigType ImplicitizeForAll vs t
+
+synifyCtx :: [PredType] -> LHsContext GhcRn
+synifyCtx ts = noLocA (map (synifyType WithinType []) ts)
+
+synifyTyVars :: [TyVar] -> LHsQTyVars GhcRn
+synifyTyVars ktvs =
+  HsQTvs
+    { hsq_ext = []
+    , hsq_explicit = map synifyTyVar ktvs
+    }
+
+synifyTyVar :: TyVar -> LHsTyVarBndr (HsBndrVis GhcRn) GhcRn
+synifyTyVar = synify_ty_var emptyVarSet (HsBndrRequired noExtField)
+
+synifyTyVarBndr :: VarBndr TyVar flag -> LHsTyVarBndr flag GhcRn
+synifyTyVarBndr = synifyTyVarBndr' emptyVarSet
+
+synifyTyVarBndr' :: VarSet -> VarBndr TyVar flag -> LHsTyVarBndr flag GhcRn
+synifyTyVarBndr' no_kinds (Bndr tv spec) = synify_ty_var no_kinds spec tv
+
+-- | Like 'synifyTyVarBndr', but accepts a set of variables for which to omit kind
+-- signatures (even if they don't have the lifted type kind).
+synify_ty_var :: VarSet -> flag -> TyVar -> LHsTyVarBndr flag GhcRn
+synify_ty_var no_kinds flag tv
+  | isLiftedTypeKind kind || tv `elemVarSet` no_kinds =
+      noLocA (UserTyVar noAnn flag (noLocA name))
+  | otherwise =
+      noLocA (KindedTyVar noAnn flag (noLocA name) (synifyKindSig kind))
+  where
+    kind = tyVarKind tv
+    name = getName tv
+
+-- | Annotate (with HsKingSig) a type if the first parameter is True
+-- and if the type contains a free variable.
+-- This is used to synify type patterns for poly-kinded tyvars in
+-- synifying class and type instances.
+annotHsType
+  :: Bool -- True <=> annotate
+  -> Type
+  -> LHsType GhcRn
+  -> LHsType GhcRn
+-- tiny optimization: if the type is annotated, don't annotate again.
+annotHsType _ _ hs_ty@(L _ (HsKindSig{})) = hs_ty
+annotHsType True ty hs_ty
+  | not $ isEmptyVarSet $ filterVarSet isTyVar $ tyCoVarsOfType ty =
+      let ki = typeKind ty
+          hs_ki = synifyType WithinType [] ki
+       in noLocA (HsKindSig noAnn hs_ty hs_ki)
+annotHsType _ _ hs_ty = hs_ty
+
+-- | For every argument type that a type constructor accepts,
+-- report whether or not the argument is poly-kinded. This is used to
+-- eventually feed into 'annotThType'.
+tyConArgsPolyKinded :: TyCon -> [Bool]
+tyConArgsPolyKinded tc =
+  map (is_poly_ty . tyVarKind) tc_vis_tvs
+    ++ map (is_poly_ty . piTyBinderType) tc_res_kind_vis_bndrs
+    ++ repeat True
+  where
+    is_poly_ty :: Type -> Bool
+    is_poly_ty ty =
+      not $
+        isEmptyVarSet $
+          filterVarSet isTyVar $
+            tyCoVarsOfType ty
+
+    tc_vis_tvs :: [TyVar]
+    tc_vis_tvs = tyConVisibleTyVars tc
+
+    tc_res_kind_vis_bndrs :: [PiTyBinder]
+    tc_res_kind_vis_bndrs = filter isVisiblePiTyBinder $ fst $ splitPiTys $ tyConResKind tc
+
+-- states of what to do with foralls:
+data SynifyTypeState
+  = -- | normal situation.  This is the safe one to use if you don't
+    -- quite understand what's going on.
+    WithinType
+  | -- | beginning of a function definition, in which, to make it look
+    --   less ugly, those rank-1 foralls (without kind annotations) are made
+    --   implicit.
+    ImplicitizeForAll
+  | -- | because in class methods the context is added to the type
+    --   (e.g. adding @forall a. Num a =>@ to @(+) :: a -> a -> a@)
+    --   which is rather sensible,
+    --   but we want to restore things to the source-syntax situation where
+    --   the defining class gets to quantify all its functions for free!
+    DeleteTopLevelQuantification
+
+synifySigType :: SynifyTypeState -> [TyVar] -> Type -> LHsSigType GhcRn
+-- The use of mkEmptySigType (which uses empty binders in OuterImplicit)
+-- is a bit suspicious; what if the type has free variables?
+synifySigType s vs ty = mkEmptySigType (synifyType s vs ty)
+
+synifySigWcType :: SynifyTypeState -> [TyVar] -> Type -> LHsSigWcType GhcRn
+-- Ditto (see synifySigType)
+synifySigWcType s vs ty = mkEmptyWildCardBndrs (mkEmptySigType (rename (map getName vs) $ synifyType s vs ty))
+
+synifyPatSynSigType :: PatSyn -> LHsSigType GhcRn
+-- Ditto (see synifySigType)
+synifyPatSynSigType ps = mkEmptySigType (synifyPatSynType ps)
+
+-- | Depending on the first argument, try to default all type variables of kind
+-- 'RuntimeRep' to 'LiftedType'.
+defaultType :: PrintRuntimeReps -> Type -> Type
+defaultType ShowRuntimeRep = id
+defaultType HideRuntimeRep = defaultRuntimeRepVars
+
+-- | Convert a core type into an 'HsType'.
+synifyType
+  :: SynifyTypeState
+  -- ^ what to do with a 'forall'
+  -> [TyVar]
+  -- ^ free variables in the type to convert
+  -> Type
+  -- ^ the type to convert
+  -> LHsType GhcRn
+synifyType _ _ (TyVarTy tv) = noLocA $ HsTyVar noAnn NotPromoted $ noLocA (getName tv)
+synifyType _ vs (TyConApp tc tys) =
+  maybe_sig res_ty
+  where
+    res_ty :: LHsType GhcRn
+    res_ty
+      -- Use */# instead of TYPE 'Lifted/TYPE 'Unlifted (#473)
+      | tc `hasKey` tYPETyConKey
+      , [TyConApp rep [TyConApp lev []]] <- tys
+      , rep `hasKey` boxedRepDataConKey
+      , lev `hasKey` liftedDataConKey =
+          noLocA (HsTyVar noAnn NotPromoted (noLocA liftedTypeKindTyConName))
+      -- Use non-prefix tuple syntax where possible, because it looks nicer.
+      | Just sort <- tyConTuple_maybe tc
+      , tyConArity tc == tys_len =
+          noLocA $
+            HsTupleTy
+              noAnn
+              ( case sort of
+                  BoxedTuple -> HsBoxedOrConstraintTuple
+                  ConstraintTuple -> HsBoxedOrConstraintTuple
+                  UnboxedTuple -> HsUnboxedTuple
+              )
+              (map (synifyType WithinType vs) vis_tys)
+      | isUnboxedSumTyCon tc =
+          noLocA $ HsSumTy noAnn (map (synifyType WithinType vs) vis_tys)
+      | Just dc <- isPromotedDataCon_maybe tc
+      , isTupleDataCon dc
+      , dataConSourceArity dc == length vis_tys =
+          noLocA $ HsExplicitTupleTy noExtField (map (synifyType WithinType vs) vis_tys)
+      -- ditto for lists
+      | getName tc == listTyConName
+      , [ty] <- vis_tys =
+          noLocA $ HsListTy noAnn (synifyType WithinType vs ty)
+      | tc == promotedNilDataCon
+      , [] <- vis_tys =
+          noLocA $ HsExplicitListTy noExtField IsPromoted []
+      | tc == promotedConsDataCon
+      , [ty1, ty2] <- vis_tys =
+          let hTy = synifyType WithinType vs ty1
+           in case synifyType WithinType vs ty2 of
+                tTy
+                  | L _ (HsExplicitListTy _ IsPromoted tTy') <- stripKindSig tTy ->
+                      noLocA $ HsExplicitListTy noExtField IsPromoted (hTy : tTy')
+                  | otherwise ->
+                      noLocA $ HsOpTy noAnn IsPromoted hTy (noLocA $ getName tc) tTy
+      -- ditto for implicit parameter tycons
+      | tc `hasKey` ipClassKey
+      , [name, ty] <- tys
+      , Just x <- isStrLitTy name =
+          noLocA $ HsIParamTy noAnn (noLocA $ HsIPName x) (synifyType WithinType vs ty)
+      -- and equalities
+      | tc `hasKey` eqTyConKey
+      , [ty1, ty2] <- tys =
+          noLocA $
+            HsOpTy
+              noAnn
+              NotPromoted
+              (synifyType WithinType vs ty1)
+              (noLocA eqTyConName)
+              (synifyType WithinType vs ty2)
+      -- and infix type operators
+      | isSymOcc (nameOccName (getName tc))
+      , ty1 : ty2 : tys_rest <- vis_tys =
+          mk_app_tys
+            ( HsOpTy
+                noAnn
+                prom
+                (synifyType WithinType vs ty1)
+                (noLocA $ getName tc)
+                (synifyType WithinType vs ty2)
+            )
+            tys_rest
+      -- Most TyCons:
+      | otherwise =
+          mk_app_tys
+            (HsTyVar noAnn prom $ noLocA (getName tc))
+            vis_tys
+      where
+        !prom = if isPromotedDataCon tc then IsPromoted else NotPromoted
+        mk_app_tys ty_app ty_args =
+          foldl
+            (\t1 t2 -> noLocA $ HsAppTy noExtField t1 t2)
+            (noLocA ty_app)
+            ( map (synifyType WithinType vs) $
+                filterOut isCoercionTy ty_args
+            )
+
+    tys_len = length tys
+    vis_tys = filterOutInvisibleTypes tc tys
+
+    maybe_sig :: LHsType GhcRn -> LHsType GhcRn
+    maybe_sig ty'
+      | tyConAppNeedsKindSig False tc tys_len =
+          let full_kind = typeKind (mkTyConApp tc tys)
+              full_kind' = synifyType WithinType vs full_kind
+           in noLocA $ HsKindSig noAnn ty' full_kind'
+      | otherwise = ty'
+synifyType _ vs ty@(AppTy{}) =
+  let
+    (ty_head, ty_args) = splitAppTys ty
+    ty_head' = synifyType WithinType vs ty_head
+    ty_args' =
+      map (synifyType WithinType vs) $
+        filterOut isCoercionTy $
+          filterByList
+            (map isVisibleForAllTyFlag $ appTyForAllTyFlags ty_head ty_args)
+            ty_args
+   in
+    foldl (\t1 t2 -> noLocA $ HsAppTy noExtField t1 t2) ty_head' ty_args'
+synifyType s vs funty@(FunTy af w t1 t2)
+  | isInvisibleFunArg af = synifySigmaType s vs funty
+  | otherwise = noLocA $ HsFunTy noExtField w' s1 s2
+  where
+    s1 = synifyType WithinType vs t1
+    s2 = synifyType WithinType vs t2
+    w' = synifyMult vs w
+synifyType s vs forallty@(ForAllTy (Bndr _ argf) _ty) =
+  case argf of
+    Required -> synifyVisForAllType vs forallty
+    Invisible _ -> synifySigmaType s vs forallty
+synifyType _ _ (LitTy t) = noLocA $ HsTyLit noExtField $ synifyTyLit t
+synifyType s vs (CastTy t _) = synifyType s vs t
+synifyType _ _ (CoercionTy{}) = error "synifyType:Coercion"
+
+-- | Process a 'Type' which starts with a visible @forall@ into an 'HsType'
+synifyVisForAllType
+  :: [TyVar]
+  -- ^ free variables in the type to convert
+  -> Type
+  -- ^ the forall type to convert
+  -> LHsType GhcRn
+synifyVisForAllType vs ty =
+  let (tvs, rho) = tcSplitForAllTysReqPreserveSynonyms ty
+
+      sTvs = map synifyTyVarBndr tvs
+
+      -- Figure out what the type variable order would be inferred in the
+      -- absence of an explicit forall
+      tvs' = orderedFVs (mkVarSet vs) [rho]
+   in noLocA $
+        HsForAllTy
+          { hst_tele = mkHsForAllVisTele noAnn sTvs
+          , hst_xforall = noExtField
+          , hst_body = synifyType WithinType (tvs' ++ vs) rho
+          }
+
+-- | Process a 'Type' which starts with an invisible @forall@ or a constraint
+-- into an 'HsType'
+synifySigmaType
+  :: SynifyTypeState
+  -- ^ what to do with the 'forall'
+  -> [TyVar]
+  -- ^ free variables in the type to convert
+  -> Type
+  -- ^ the forall type to convert
+  -> LHsType GhcRn
+synifySigmaType s vs ty =
+  let (tvs, ctx, tau) = tcSplitSigmaTyPreserveSynonyms ty
+      sPhi =
+        HsQualTy
+          { hst_ctxt = synifyCtx ctx
+          , hst_xqual = noExtField
+          , hst_body = synifyType WithinType (tvs' ++ vs) tau
+          }
+
+      sTy =
+        HsForAllTy
+          { hst_tele = mkHsForAllInvisTele noAnn sTvs
+          , hst_xforall = noExtField
+          , hst_body = noLocA sPhi
+          }
+
+      sTvs = map synifyTyVarBndr tvs
+
+      -- Figure out what the type variable order would be inferred in the
+      -- absence of an explicit forall
+      tvs' = orderedFVs (mkVarSet vs) (ctx ++ [tau])
+   in case s of
+        DeleteTopLevelQuantification -> synifyType ImplicitizeForAll (tvs' ++ vs) tau
+        -- Put a forall in if there are any type variables
+        WithinType
+          | not (null tvs) -> noLocA sTy
+          | otherwise -> noLocA sPhi
+        ImplicitizeForAll -> implicitForAll [] vs tvs ctx (synifyType WithinType) tau
+
+-- | Put a forall in if there are any type variables which require
+-- explicit kind annotations or if the inferred type variable order
+-- would be different.
+implicitForAll
+  :: [TyCon]
+  -- ^ type constructors that determine their args kinds
+  -> [TyVar]
+  -- ^ free variables in the type to convert
+  -> [InvisTVBinder]
+  -- ^ type variable binders in the forall
+  -> ThetaType
+  -- ^ constraints right after the forall
+  -> ([TyVar] -> Type -> LHsType GhcRn)
+  -- ^ how to convert the inner type
+  -> Type
+  -- ^ inner type
+  -> LHsType GhcRn
+implicitForAll tycons vs tvs ctx synInner tau
+  | any (isHsKindedTyVar . unLoc) sTvs = noLocA sTy
+  | tvs' /= (binderVars tvs) = noLocA sTy
+  | otherwise = noLocA sPhi
+  where
+    sRho = synInner (tvs' ++ vs) tau
+    sPhi
+      | null ctx = unLoc sRho
+      | otherwise =
+          HsQualTy
+            { hst_ctxt = synifyCtx ctx
+            , hst_xqual = noExtField
+            , hst_body = synInner (tvs' ++ vs) tau
+            }
+    sTy =
+      HsForAllTy
+        { hst_tele = mkHsForAllInvisTele noAnn sTvs
+        , hst_xforall = noExtField
+        , hst_body = noLocA sPhi
+        }
+
+    no_kinds_needed = noKindTyVars tycons tau
+    sTvs = map (synifyTyVarBndr' no_kinds_needed) tvs
+
+    -- Figure out what the type variable order would be inferred in the
+    -- absence of an explicit forall
+    tvs' = orderedFVs (mkVarSet vs) (ctx ++ [tau])
+
+-- | Find the set of type variables whose kind signatures can be properly
+-- inferred just from their uses in the type signature. This means the type
+-- variable to has at least one fully applied use @f x1 x2 ... xn@ where:
+--
+--   * @f@ has a function kind where the arguments have the same kinds
+--     as @x1 x2 ... xn@.
+--
+--   * @f@ has a function kind whose final return has lifted type kind
+noKindTyVars
+  :: [TyCon]
+  -- ^ type constructors that determine their args kinds
+  -> Type
+  -- ^ type to inspect
+  -> VarSet
+  -- ^ set of variables whose kinds can be inferred from uses in the type
+noKindTyVars _ (TyVarTy var)
+  | isLiftedTypeKind (tyVarKind var) = unitVarSet var
+noKindTyVars ts ty
+  | (f, xs) <- splitAppTys ty
+  , not (null xs) =
+      let args = map (noKindTyVars ts) xs
+          func = case f of
+            TyVarTy var
+              | (xsKinds, outKind) <- splitFunTys (tyVarKind var)
+              , map scaledThing xsKinds `eqTypes` map typeKind xs
+              , isLiftedTypeKind outKind ->
+                  unitVarSet var
+            TyConApp t ks
+              | t `elem` ts
+              , all noFreeVarsOfType ks ->
+                  mkVarSet [v | TyVarTy v <- xs]
+            _ -> noKindTyVars ts f
+       in unionVarSets (func : args)
+noKindTyVars ts (ForAllTy _ t) = noKindTyVars ts t
+noKindTyVars ts (FunTy _ w t1 t2) =
+  noKindTyVars ts w
+    `unionVarSet` noKindTyVars ts t1
+    `unionVarSet` noKindTyVars ts t2
+noKindTyVars ts (CastTy t _) = noKindTyVars ts t
+noKindTyVars _ _ = emptyVarSet
+
+synifyMult :: [TyVar] -> Mult -> HsArrow GhcRn
+synifyMult vs t = case t of
+  OneTy -> HsLinearArrow noExtField
+  ManyTy -> HsUnrestrictedArrow noExtField
+  ty -> HsExplicitMult noExtField (synifyType WithinType vs ty)
+
+synifyPatSynType :: PatSyn -> LHsType GhcRn
+synifyPatSynType ps =
+  let (univ_tvs, req_theta, ex_tvs, prov_theta, arg_tys, res_ty) = patSynSigBndr ps
+      ts = maybeToList (tyConAppTyCon_maybe res_ty)
+
+      -- HACK: a HsQualTy with theta = [unitTy] will be printed as "() =>",
+      -- i.e., an explicit empty context, which is what we need. This is not
+      -- possible by taking theta = [], as that will print no context at all
+      req_theta'
+        | null req_theta
+        , not (null prov_theta && null ex_tvs) =
+            [unitTy]
+        | otherwise = req_theta
+   in implicitForAll
+        ts
+        []
+        (univ_tvs ++ ex_tvs)
+        req_theta'
+        (\vs -> implicitForAll ts vs [] prov_theta (synifyType WithinType))
+        (mkScaledFunTys arg_tys res_ty)
+
+synifyTyLit :: TyLit -> HsTyLit GhcRn
+synifyTyLit (NumTyLit n) = HsNumTy NoSourceText n
+synifyTyLit (StrTyLit s) = HsStrTy NoSourceText s
+synifyTyLit (CharTyLit c) = HsCharTy NoSourceText c
+
+synifyKindSig :: Kind -> LHsKind GhcRn
+synifyKindSig k = synifyType WithinType [] k
+
+stripKindSig :: LHsType GhcRn -> LHsType GhcRn
+stripKindSig (L _ (HsKindSig _ t _)) = t
+stripKindSig t = t
+
+synifyInstHead :: ([TyVar], [PredType], Class, [Type]) -> [(FamInst, Bool, Maybe (MDoc Name), Located Name, Maybe Module)] -> InstHead GhcRn
+synifyInstHead (vs, preds, cls, types) associated_families =
+  InstHead
+    { ihdClsName = getName cls
+    , ihdTypes = map unLoc annot_ts
+    , ihdInstType =
+        ClassInst
+          { clsiCtx = map (unLoc . synifyType WithinType []) preds
+          , clsiTyVars = synifyTyVars (tyConVisibleTyVars cls_tycon)
+          , clsiSigs = map synifyClsIdSig $ specialized_class_methods
+          , clsiAssocTys =
+              [ (f_inst, f_doc, f_name, f_mod)
+              | (f_i, opaque, f_doc, f_name, f_mod) <- associated_families
+              , Right f_inst <- [synifyFamInst f_i opaque]
+              ]
+          }
+    }
+  where
+    cls_tycon = classTyCon cls
+    ts = filterOutInvisibleTypes cls_tycon types
+    ts' = map (synifyType WithinType vs) ts
+    annot_ts = zipWith3 annotHsType args_poly ts ts'
+    args_poly = tyConArgsPolyKinded cls_tycon
+    synifyClsIdSig = synifyIdSig ShowRuntimeRep DeleteTopLevelQuantification vs
+    specialized_class_methods = [setIdType m (piResultTys (idType m) types) | m <- classMethods cls]
+
+-- Convert a family instance, this could be a type family or data family
+synifyFamInst :: FamInst -> Bool -> Either String (InstHead GhcRn)
+synifyFamInst fi opaque = do
+  ityp' <- ityp fam_flavor
+  return
+    InstHead
+      { ihdClsName = fi_fam fi
+      , ihdTypes = map unLoc annot_ts
+      , ihdInstType = ityp'
+      }
+  where
+    ityp SynFamilyInst | opaque = return $ TypeInst Nothing
+    ityp SynFamilyInst =
+      return . TypeInst . Just . unLoc $ synifyType WithinType [] fam_rhs
+    ityp (DataFamilyInst c) =
+      DataInst <$> synifyTyCon HideRuntimeRep (Just $ famInstAxiom fi) c
+    fam_tc = famInstTyCon fi
+    fam_flavor = fi_flavor fi
+    fam_lhs = fi_tys fi
+    fam_rhs = fi_rhs fi
+
+    eta_expanded_lhs
+      -- eta-expand lhs types, because sometimes data/newtype
+      -- instances are eta-reduced; See Trac #9692
+      -- See Note [Eta reduction for data family axioms] in GHC.Tc.TyCl.Instance in GHC
+      | DataFamilyInst rep_tc <- fam_flavor =
+          let (_, rep_tc_args) = splitTyConApp fam_rhs
+              etad_tyvars = dropList rep_tc_args $ tyConTyVars rep_tc
+              etad_tys = mkTyVarTys etad_tyvars
+              eta_exp_lhs = fam_lhs `chkAppend` etad_tys
+           in eta_exp_lhs
+      | otherwise =
+          fam_lhs
+
+    ts = filterOutInvisibleTypes fam_tc eta_expanded_lhs
+    synifyTypes = map (synifyType WithinType [])
+    ts' = synifyTypes ts
+    annot_ts = zipWith3 annotHsType args_poly ts ts'
+    args_poly = tyConArgsPolyKinded fam_tc
+
+{-
+Note [Invariant: Never expand type synonyms]
+
+In haddock, we never want to expand a type synonym that may be presented to the
+user, as we want to keep the link to the abstraction captured in the synonym.
+
+All code in Haddock.Convert must make sure that this invariant holds.
+
+See https://github.com/haskell/haddock/issues/879 for a bug where this
+invariant didn't hold.
+-}
+
+-- | A version of 'TcType.tcSplitSigmaTy' that:
+--
+-- 1. Preserves type synonyms.
+-- 2. Returns 'InvisTVBinder's instead of 'TyVar's.
+--
+-- See Note [Invariant: Never expand type synonyms]
+tcSplitSigmaTyPreserveSynonyms :: Type -> ([InvisTVBinder], ThetaType, Type)
+tcSplitSigmaTyPreserveSynonyms ty =
+  case tcSplitForAllTysInvisPreserveSynonyms ty of
+    (tvs, rho) -> case tcSplitPhiTyPreserveSynonyms rho of
+      (theta, tau) -> (tvs, theta, tau)
+
+-- | See Note [Invariant: Never expand type synonyms]
+tcSplitSomeForAllTysPreserveSynonyms
+  :: (ForAllTyFlag -> Bool) -> Type -> ([ForAllTyBinder], Type)
+tcSplitSomeForAllTysPreserveSynonyms argf_pred ty = split ty ty []
+  where
+    split _ (ForAllTy tvb@(Bndr _ argf) ty') tvs
+      | argf_pred argf = split ty' ty' (tvb : tvs)
+    split orig_ty _ tvs = (reverse tvs, orig_ty)
+
+-- | See Note [Invariant: Never expand type synonyms]
+tcSplitForAllTysReqPreserveSynonyms :: Type -> ([ReqTVBinder], Type)
+tcSplitForAllTysReqPreserveSynonyms ty =
+  let (all_bndrs, body) = tcSplitSomeForAllTysPreserveSynonyms isVisibleForAllTyFlag ty
+      req_bndrs = mapMaybe mk_req_bndr_maybe all_bndrs
+   in assert
+        (req_bndrs `equalLength` all_bndrs)
+        (req_bndrs, body)
+  where
+    mk_req_bndr_maybe :: ForAllTyBinder -> Maybe ReqTVBinder
+    mk_req_bndr_maybe (Bndr tv argf) = case argf of
+      Required -> Just $ Bndr tv ()
+      Invisible _ -> Nothing
+
+-- | See Note [Invariant: Never expand type synonyms]
+tcSplitForAllTysInvisPreserveSynonyms :: Type -> ([InvisTVBinder], Type)
+tcSplitForAllTysInvisPreserveSynonyms ty =
+  let (all_bndrs, body) = tcSplitSomeForAllTysPreserveSynonyms isInvisibleForAllTyFlag ty
+      inv_bndrs = mapMaybe mk_inv_bndr_maybe all_bndrs
+   in assert
+        (inv_bndrs `equalLength` all_bndrs)
+        (inv_bndrs, body)
+  where
+    mk_inv_bndr_maybe :: ForAllTyBinder -> Maybe InvisTVBinder
+    mk_inv_bndr_maybe (Bndr tv argf) = case argf of
+      Invisible s -> Just $ Bndr tv s
+      Required -> Nothing
+
+-- | See Note [Invariant: Never expand type synonyms]
+
+-- | See Note [Invariant: Never expand type synonyms]
+tcSplitPhiTyPreserveSynonyms :: Type -> (ThetaType, Type)
+tcSplitPhiTyPreserveSynonyms ty0 = split ty0 []
+  where
+    split ty ts =
+      case tcSplitPredFunTyPreserveSynonyms_maybe ty of
+        Just (pred_, ty') -> split ty' (pred_ : ts)
+        Nothing -> (reverse ts, ty)
+
+-- | See Note [Invariant: Never expand type synonyms]
+tcSplitPredFunTyPreserveSynonyms_maybe :: Type -> Maybe (PredType, Type)
+tcSplitPredFunTyPreserveSynonyms_maybe (FunTy af _ arg res)
+  | isInvisibleFunArg af = Just (arg, res)
+tcSplitPredFunTyPreserveSynonyms_maybe _ = Nothing
diff --git a/utils/haddock/haddock-api/src/Haddock/Doc.hs b/utils/haddock/haddock-api/src/Haddock/Doc.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e6e4c404aa40dede2972617dfe02b7a76651ba76
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Doc.hs
@@ -0,0 +1,37 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Haddock.Doc
+  ( module Documentation.Haddock.Doc
+  , docCodeBlock
+  , combineDocumentation
+  ) where
+
+import Data.Maybe
+import Documentation.Haddock.Doc
+import Haddock.Types
+import Haddock.Utils (mkMeta)
+
+combineDocumentation :: Documentation name -> Maybe (MDoc name)
+combineDocumentation (Documentation Nothing Nothing) = Nothing
+combineDocumentation (Documentation mDoc mWarning) =
+  Just
+    ( maybe emptyMetaDoc mkMeta mWarning
+        `metaDocAppend` fromMaybe emptyMetaDoc mDoc
+    )
+
+-- Drop trailing whitespace from @..@ code blocks.  Otherwise this:
+--
+--    -- @
+--    -- foo
+--    -- @
+--
+-- turns into (DocCodeBlock "\nfoo\n ") which when rendered in HTML
+-- gives an extra vertical space after the code block.  The single space
+-- on the final line seems to trigger the extra vertical space.
+--
+docCodeBlock :: DocH mod id -> DocH mod id
+docCodeBlock (DocString s) =
+  DocString (reverse $ dropWhile (`elem` " \t") $ reverse s)
+docCodeBlock (DocAppend l r) =
+  DocAppend l (docCodeBlock r)
+docCodeBlock d = d
diff --git a/utils/haddock/haddock-api/src/Haddock/GhcUtils.hs b/utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
new file mode 100644
index 0000000000000000000000000000000000000000..f5713870b97085e7b60f6a7fdbbda9a15d68d9fc
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
@@ -0,0 +1,889 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE MonadComprehensions #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeOperators #-}
+{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
+{-# OPTIONS_GHC -Wno-redundant-constraints #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_HADDOCK hide #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.GhcUtils
+-- Copyright   :  (c) David Waern 2006-2009
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Utils for dealing with types from the GHC API
+module Haddock.GhcUtils where
+
+import Control.Arrow
+import Data.Char (isSpace)
+import Data.Foldable (foldl', toList)
+import Data.List.NonEmpty (NonEmpty)
+import Data.Maybe (fromMaybe, mapMaybe)
+import qualified Data.Set as Set
+
+import Haddock.Types (DocName, DocNameI, XRecCond)
+
+import GHC
+import GHC.Builtin.Names
+import GHC.Builtin.Types (liftedRepTy)
+import GHC.Core.TyCo.Rep (Type (..))
+import GHC.Core.Type (binderVar, isRuntimeRepVar)
+import GHC.Data.FastString
+import GHC.Driver.Ppr (showPpr)
+import GHC.Driver.Session
+import GHC.Types.Name
+import GHC.Types.SrcLoc (advanceSrcLoc)
+import GHC.Types.Var
+  ( Specificity
+  , TyVarBinder
+  , VarBndr (..)
+  , isInvisibleForAllTyFlag
+  , tyVarKind
+  , updateTyVarKind
+  )
+import GHC.Types.Var.Env (TyVarEnv, elemVarEnv, emptyVarEnv, extendVarEnv)
+import GHC.Types.Var.Set (VarSet, emptyVarSet)
+import GHC.Utils.FV as FV
+import GHC.Utils.Outputable (Outputable)
+import GHC.Utils.Panic (panic)
+
+import GHC.Data.StringBuffer (StringBuffer)
+import qualified GHC.Data.StringBuffer as S
+
+import Data.ByteString (ByteString)
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Internal as BS
+
+import GHC.HsToCore.Docs hiding (sigNameNoLoc)
+
+moduleString :: Module -> String
+moduleString = moduleNameString . moduleName
+
+isNameSym :: Name -> Bool
+isNameSym = isSymOcc . nameOccName
+
+-- Useful when there is a signature with multiple names, e.g.
+--   foo, bar :: Types..
+-- but only one of the names is exported and we have to change the
+-- type signature to only include the exported names.
+filterLSigNames :: (IdP (GhcPass p) -> Bool) -> LSig (GhcPass p) -> Maybe (LSig (GhcPass p))
+filterLSigNames p (L loc sig) = L loc <$> (filterSigNames p sig)
+
+filterSigNames :: (IdP (GhcPass p) -> Bool) -> Sig (GhcPass p) -> Maybe (Sig (GhcPass p))
+filterSigNames p orig@(SpecSig _ n _ _) = ifTrueJust (p $ unLoc n) orig
+filterSigNames p orig@(InlineSig _ n _) = ifTrueJust (p $ unLoc n) orig
+filterSigNames p (FixSig _ (FixitySig ns_spec ns ty)) =
+  case filter (p . unLoc) ns of
+    [] -> Nothing
+    filtered -> Just (FixSig noAnn (FixitySig ns_spec filtered ty))
+filterSigNames _ orig@(MinimalSig _ _) = Just orig
+filterSigNames p (TypeSig _ ns ty) =
+  case filter (p . unLoc) ns of
+    [] -> Nothing
+    filtered -> Just (TypeSig noAnn filtered ty)
+filterSigNames p (ClassOpSig _ is_default ns ty) =
+  case filter (p . unLoc) ns of
+    [] -> Nothing
+    filtered -> Just (ClassOpSig noAnn is_default filtered ty)
+filterSigNames p (PatSynSig _ ns ty) =
+  case filter (p . unLoc) ns of
+    [] -> Nothing
+    filtered -> Just (PatSynSig noAnn filtered ty)
+filterSigNames _ _ = Nothing
+
+ifTrueJust :: Bool -> name -> Maybe name
+ifTrueJust True = Just
+ifTrueJust False = const Nothing
+
+sigName :: LSig GhcRn -> [IdP GhcRn]
+sigName (L _ sig) = sigNameNoLoc' emptyOccEnv sig
+
+sigNameNoLoc' :: forall pass w. UnXRec pass => w -> Sig pass -> [IdP pass]
+sigNameNoLoc' _ (TypeSig _ ns _) = map (unXRec @pass) ns
+sigNameNoLoc' _ (ClassOpSig _ _ ns _) = map (unXRec @pass) ns
+sigNameNoLoc' _ (PatSynSig _ ns _) = map (unXRec @pass) ns
+sigNameNoLoc' _ (SpecSig _ n _ _) = [unXRec @pass n]
+sigNameNoLoc' _ (InlineSig _ n _) = [unXRec @pass n]
+sigNameNoLoc' _ (FixSig _ (FixitySig _ ns _)) = map (unXRec @pass) ns
+sigNameNoLoc' _ _ = []
+
+-- | Was this signature given by the user?
+isUserLSig :: forall p. UnXRec p => LSig p -> Bool
+isUserLSig = isUserSig . unXRec @p
+
+isClassD :: HsDecl a -> Bool
+isClassD (TyClD _ d) = isClassDecl d
+isClassD _ = False
+
+pretty :: Outputable a => DynFlags -> a -> String
+pretty = showPpr
+
+dataListModule :: Module
+dataListModule = mkBaseModule (fsLit "Data.List")
+
+dataTupleModule :: Module
+dataTupleModule = mkBaseModule (fsLit "Data.Tuple")
+
+-- ---------------------------------------------------------------------
+
+-- These functions are duplicated from the GHC API, as they must be
+-- instantiated at DocNameI instead of (GhcPass _).
+
+-- | Like 'hsTyVarName' from GHC API, but not instantiated at (GhcPass _)
+hsTyVarBndrName
+  :: forall flag n
+   . (XXTyVarBndr n ~ DataConCantHappen, UnXRec n)
+  => HsTyVarBndr flag n
+  -> IdP n
+hsTyVarBndrName (UserTyVar _ _ name) = unXRec @n name
+hsTyVarBndrName (KindedTyVar _ _ name _) = unXRec @n name
+
+hsTyVarNameI :: HsTyVarBndr flag DocNameI -> DocName
+hsTyVarNameI (UserTyVar _ _ (L _ n)) = n
+hsTyVarNameI (KindedTyVar _ _ (L _ n) _) = n
+
+hsLTyVarNameI :: LHsTyVarBndr flag DocNameI -> DocName
+hsLTyVarNameI = hsTyVarNameI . unLoc
+
+getConNamesI :: ConDecl DocNameI -> NonEmpty (LocatedN DocName)
+getConNamesI ConDeclH98{con_name = name} = pure name
+getConNamesI ConDeclGADT{con_names = names} = names
+
+hsSigTypeI :: LHsSigType DocNameI -> LHsType DocNameI
+hsSigTypeI = sig_body . unLoc
+
+mkEmptySigType :: LHsType GhcRn -> LHsSigType GhcRn
+-- Dubious, because the implicit binders are empty even
+-- though the type might have free variables
+mkEmptySigType lty@(L loc ty) = L loc $ case ty of
+  HsForAllTy
+    { hst_tele = HsForAllInvis{hsf_invis_bndrs = bndrs}
+    , hst_body = body
+    } ->
+      HsSig
+        { sig_ext = noExtField
+        , sig_bndrs =
+            HsOuterExplicit
+              { hso_xexplicit = noExtField
+              , hso_bndrs = bndrs
+              }
+        , sig_body = body
+        }
+  _ ->
+    HsSig
+      { sig_ext = noExtField
+      , sig_bndrs = HsOuterImplicit{hso_ximplicit = []}
+      , sig_body = lty
+      }
+
+mkHsForAllInvisTeleI
+  :: [LHsTyVarBndr Specificity DocNameI] -> HsForAllTelescope DocNameI
+mkHsForAllInvisTeleI invis_bndrs =
+  HsForAllInvis{hsf_xinvis = noExtField, hsf_invis_bndrs = invis_bndrs}
+
+mkHsImplicitSigTypeI :: LHsType DocNameI -> HsSigType DocNameI
+mkHsImplicitSigTypeI body =
+  HsSig
+    { sig_ext = noExtField
+    , sig_bndrs = HsOuterImplicit{hso_ximplicit = noExtField}
+    , sig_body = body
+    }
+
+getGADTConType :: ConDecl DocNameI -> LHsSigType DocNameI
+-- The full type of a GADT data constructor We really only get this in
+-- order to pretty-print it, and currently only in Haddock's code.  So
+-- we are cavalier about locations and extensions, hence the
+-- 'undefined's
+getGADTConType
+  ( ConDeclGADT
+      { con_bndrs = L _ outer_bndrs
+      , con_mb_cxt = mcxt
+      , con_g_args = args
+      , con_res_ty = res_ty
+      }
+    ) =
+    noLocA
+      ( HsSig
+          { sig_ext = noExtField
+          , sig_bndrs = outer_bndrs
+          , sig_body = theta_ty
+          }
+      )
+    where
+      theta_ty
+        | Just theta <- mcxt =
+            noLocA (HsQualTy{hst_xqual = noAnn, hst_ctxt = theta, hst_body = tau_ty})
+        | otherwise =
+            tau_ty
+
+      --  tau_ty :: LHsType DocNameI
+      tau_ty = case args of
+        RecConGADT _ flds -> mkFunTy (noLocA (HsRecTy noAnn (unLoc flds))) res_ty
+        PrefixConGADT _ pos_args -> foldr mkFunTy res_ty (map hsScaledThing pos_args)
+
+      mkFunTy :: LHsType DocNameI -> LHsType DocNameI -> LHsType DocNameI
+      mkFunTy a b = noLocA (HsFunTy noAnn (HsUnrestrictedArrow noExtField) a b)
+getGADTConType (ConDeclH98{}) = panic "getGADTConType"
+
+-- Should only be called on ConDeclGADT
+
+getMainDeclBinderI :: HsDecl DocNameI -> [IdP DocNameI]
+getMainDeclBinderI (TyClD _ d) = [tcdNameI d]
+getMainDeclBinderI (ValD _ d) =
+  case collectHsBindBinders CollNoDictBinders d of
+    [] -> []
+    (name : _) -> [name]
+getMainDeclBinderI (SigD _ d) = sigNameNoLoc' emptyOccEnv d
+getMainDeclBinderI (ForD _ (ForeignImport _ name _ _)) = [unLoc name]
+getMainDeclBinderI (ForD _ (ForeignExport _ _ _ _)) = []
+getMainDeclBinderI _ = []
+
+familyDeclLNameI :: FamilyDecl DocNameI -> LocatedN DocName
+familyDeclLNameI (FamilyDecl{fdLName = n}) = n
+
+tyClDeclLNameI :: TyClDecl DocNameI -> LocatedN DocName
+tyClDeclLNameI (FamDecl{tcdFam = fd}) = familyDeclLNameI fd
+tyClDeclLNameI (SynDecl{tcdLName = ln}) = ln
+tyClDeclLNameI (DataDecl{tcdLName = ln}) = ln
+tyClDeclLNameI (ClassDecl{tcdLName = ln}) = ln
+
+tcdNameI :: TyClDecl DocNameI -> DocName
+tcdNameI = unLoc . tyClDeclLNameI
+
+addClassContext :: Name -> LHsQTyVars GhcRn -> LSig GhcRn -> LSig GhcRn
+-- Add the class context to a class-op signature
+addClassContext cls tvs0 (L pos (ClassOpSig _ _ lname ltype)) =
+  L pos (TypeSig noAnn lname (mkEmptyWildCardBndrs (go_sig_ty ltype)))
+  where
+    go_sig_ty (L loc (HsSig{sig_bndrs = bndrs, sig_body = ty})) =
+      L
+        loc
+        ( HsSig
+            { sig_ext = noExtField
+            , sig_bndrs = bndrs
+            , sig_body = go_ty ty
+            }
+        )
+
+    go_ty (L loc (HsForAllTy{hst_tele = tele, hst_body = ty})) =
+      L
+        loc
+        ( HsForAllTy
+            { hst_xforall = noExtField
+            , hst_tele = tele
+            , hst_body = go_ty ty
+            }
+        )
+    go_ty (L loc (HsQualTy{hst_ctxt = ctxt, hst_body = ty})) =
+      L
+        loc
+        ( HsQualTy
+            { hst_xqual = noExtField
+            , hst_ctxt = add_ctxt ctxt
+            , hst_body = ty
+            }
+        )
+    go_ty (L loc ty) =
+      L
+        loc
+        ( HsQualTy
+            { hst_xqual = noExtField
+            , hst_ctxt = add_ctxt (noLocA [])
+            , hst_body = L loc ty
+            }
+        )
+
+    extra_pred = nlHsTyConApp NotPromoted Prefix cls (lHsQTyVarsToTypes tvs0)
+
+    add_ctxt (L loc preds) = L loc (extra_pred : preds)
+addClassContext _ _ sig = sig -- E.g. a MinimalSig is fine
+
+lHsQTyVarsToTypes :: LHsQTyVars GhcRn -> [LHsTypeArg GhcRn]
+lHsQTyVarsToTypes tvs =
+  [ HsValArg noExtField $ noLocA (HsTyVar noAnn NotPromoted (noLocA (hsLTyVarName tv)))
+  | tv <- hsQTvExplicit tvs
+  ]
+
+--------------------------------------------------------------------------------
+
+-- * Making abstract declarations
+
+--------------------------------------------------------------------------------
+
+restrictTo :: [Name] -> LHsDecl GhcRn -> LHsDecl GhcRn
+restrictTo names (L loc decl) = L loc $ case decl of
+  TyClD x d
+    | isDataDecl d ->
+        TyClD x (d{tcdDataDefn = restrictDataDefn names (tcdDataDefn d)})
+  TyClD x d
+    | isClassDecl d ->
+        TyClD
+          x
+          ( d
+              { tcdSigs = restrictDecls names (tcdSigs d)
+              , tcdATs = restrictATs names (tcdATs d)
+              }
+          )
+  _ -> decl
+
+restrictDataDefn :: [Name] -> HsDataDefn GhcRn -> HsDataDefn GhcRn
+restrictDataDefn names d = d{dd_cons = restrictDataDefnCons names (dd_cons d)}
+
+restrictDataDefnCons :: [Name] -> DataDefnCons (LConDecl GhcRn) -> DataDefnCons (LConDecl GhcRn)
+restrictDataDefnCons names = \case
+  DataTypeCons is_type_data cons -> DataTypeCons is_type_data (restrictCons names cons)
+  NewTypeCon con -> maybe (DataTypeCons False []) NewTypeCon $ restrictCons names (Just con)
+
+restrictCons :: MonadFail m => [Name] -> m (LConDecl GhcRn) -> m (LConDecl GhcRn)
+restrictCons names decls = [L p d | L p (Just d) <- fmap keep <$> decls]
+  where
+    keep :: ConDecl GhcRn -> Maybe (ConDecl GhcRn)
+    keep d
+      | any (`elem` names) (unLoc <$> getConNames d) =
+          case d of
+            ConDeclH98{con_args = con_args'} -> case con_args' of
+              PrefixCon{} -> Just d
+              RecCon fields
+                | all field_avail (unLoc fields) -> Just d
+                | otherwise -> Just (d{con_args = PrefixCon [] (field_types $ unLoc fields)})
+              -- if we have *all* the field names available, then
+              -- keep the record declaration.  Otherwise degrade to
+              -- a constructor declaration.  This isn't quite right, but
+              -- it's the best we can do.
+              InfixCon _ _ -> Just d
+            ConDeclGADT{con_g_args = con_args'} -> case con_args' of
+              PrefixConGADT{} -> Just d
+              RecConGADT _ fields
+                | all field_avail (unLoc fields) -> Just d
+                | otherwise -> Just (d{con_g_args = PrefixConGADT noExtField (field_types $ unLoc fields)})
+      where
+        -- see above
+
+        field_avail :: LConDeclField GhcRn -> Bool
+        field_avail (L _ (ConDeclField _ fs _ _)) =
+          all (\f -> foExt (unLoc f) `elem` names) fs
+
+        field_types flds = [hsUnrestricted t | L _ (ConDeclField _ _ t _) <- flds]
+    keep _ = Nothing
+
+restrictDecls :: [Name] -> [LSig GhcRn] -> [LSig GhcRn]
+restrictDecls names = mapMaybe (filterLSigNames (`elem` names))
+
+restrictATs :: [Name] -> [LFamilyDecl GhcRn] -> [LFamilyDecl GhcRn]
+restrictATs names ats = [at | at <- ats, unLoc (fdLName (unLoc at)) `elem` names]
+
+-------------------------------------------------------------------------------
+
+-- * Parenthesization
+
+-------------------------------------------------------------------------------
+
+-- | Precedence level (inside the 'HsType' AST).
+data Precedence
+  = -- | precedence of 'type' production in GHC's parser
+    PREC_TOP
+  | -- | explicit type signature
+    PREC_SIG
+  | -- | Used for single contexts, eg. ctx => type
+    -- (as opposed to (ctx1, ctx2) => type)
+    PREC_CTX
+  | -- | precedence of 'btype' production in GHC's parser
+    -- (used for LH arg of (->))
+    PREC_FUN
+  | -- | arg of any infix operator
+    -- (we don't keep have fixity info)
+    PREC_OP
+  | -- | arg of type application: always parenthesize unless atomic
+    PREC_CON
+  deriving (Eq, Ord)
+
+-- | Add in extra 'HsParTy' where needed to ensure that what would be printed
+-- out using 'ppr' has enough parentheses to be re-parsed properly.
+--
+-- We cannot add parens that may be required by fixities because we do not have
+-- any fixity information to work with in the first place :(.
+reparenTypePrec
+  :: forall a
+   . XRecCond a
+  => Precedence
+  -> HsType a
+  -> HsType a
+reparenTypePrec = go
+  where
+    -- Shorter name for 'reparenType'
+    go :: Precedence -> HsType a -> HsType a
+    go _ (HsBangTy x b ty) = HsBangTy x b (reparenLType ty)
+    go _ (HsTupleTy x con tys) = HsTupleTy x con (map reparenLType tys)
+    go _ (HsSumTy x tys) = HsSumTy x (map reparenLType tys)
+    go _ (HsListTy x ty) = HsListTy x (reparenLType ty)
+    go _ (HsRecTy x flds) = HsRecTy x (map (mapXRec @a reparenConDeclField) flds)
+    go p (HsDocTy x ty d) = HsDocTy x (goL p ty) d
+    go _ (HsExplicitListTy x p tys) = HsExplicitListTy x p (map reparenLType tys)
+    go _ (HsExplicitTupleTy x tys) = HsExplicitTupleTy x (map reparenLType tys)
+    go p (HsKindSig x ty kind) =
+      paren p PREC_SIG $ HsKindSig x (goL PREC_SIG ty) (goL PREC_SIG kind)
+    go p (HsIParamTy x n ty) =
+      paren p PREC_SIG $ HsIParamTy x n (reparenLType ty)
+    go p (HsForAllTy x tele ty) =
+      paren p PREC_CTX $ HsForAllTy x (reparenHsForAllTelescope tele) (reparenLType ty)
+    go p (HsQualTy x ctxt ty) =
+      let p' [_] = PREC_CTX
+          p' _ = PREC_TOP -- parens will get added anyways later...
+          ctxt' = mapXRec @a (\xs -> map (goL (p' xs)) xs) ctxt
+       in paren p PREC_CTX $ HsQualTy x ctxt' (goL PREC_TOP ty)
+    go p (HsFunTy x w ty1 ty2) =
+      paren p PREC_FUN $ HsFunTy x w (goL PREC_FUN ty1) (goL PREC_TOP ty2)
+    go p (HsAppTy x fun_ty arg_ty) =
+      paren p PREC_CON $ HsAppTy x (goL PREC_FUN fun_ty) (goL PREC_CON arg_ty)
+    go p (HsAppKindTy x fun_ty arg_ki) =
+      paren p PREC_CON $ HsAppKindTy x (goL PREC_FUN fun_ty) (goL PREC_CON arg_ki)
+    go p (HsOpTy x prom ty1 op ty2) =
+      paren p PREC_FUN $ HsOpTy x prom (goL PREC_OP ty1) op (goL PREC_OP ty2)
+    go p (HsParTy _ t) = unXRec @a $ goL p t -- pretend the paren doesn't exist - it will be added back if needed
+    go _ t@HsTyVar{} = t
+    go _ t@HsStarTy{} = t
+    go _ t@HsSpliceTy{} = t
+    go _ t@HsTyLit{} = t
+    go _ t@HsWildCardTy{} = t
+    go _ t@XHsType{} = t
+
+    -- Located variant of 'go'
+    goL :: Precedence -> LHsType a -> LHsType a
+    goL ctxt_prec = mapXRec @a (go ctxt_prec)
+
+    -- Optionally wrap a type in parens
+    paren
+      :: Precedence -- Precedence of context
+      -> Precedence -- Precedence of top-level operator
+      -> HsType a
+      -> HsType a -- Wrap in parens if (ctxt >= op)
+    paren ctxt_prec op_prec
+      | ctxt_prec >= op_prec = HsParTy noAnn . wrapXRec @a
+      | otherwise = id
+
+-- | Add parenthesis around the types in a 'HsType' (see 'reparenTypePrec')
+reparenType :: XRecCond a => HsType a -> HsType a
+reparenType = reparenTypePrec PREC_TOP
+
+-- | Add parenthesis around the types in a 'LHsType' (see 'reparenTypePrec')
+reparenLType :: forall a. XRecCond a => LHsType a -> LHsType a
+reparenLType = mapXRec @a reparenType
+
+-- | Add parentheses around the types in an 'HsSigType' (see 'reparenTypePrec')
+reparenSigType
+  :: forall a
+   . XRecCond a
+  => HsSigType a
+  -> HsSigType a
+reparenSigType (HsSig x bndrs body) =
+  HsSig x (reparenOuterTyVarBndrs bndrs) (reparenLType body)
+reparenSigType v@XHsSigType{} = v
+
+-- | Add parentheses around the types in an 'HsOuterTyVarBndrs' (see 'reparenTypePrec')
+reparenOuterTyVarBndrs
+  :: forall flag a
+   . XRecCond a
+  => HsOuterTyVarBndrs flag a
+  -> HsOuterTyVarBndrs flag a
+reparenOuterTyVarBndrs imp@HsOuterImplicit{} = imp
+reparenOuterTyVarBndrs (HsOuterExplicit x exp_bndrs) =
+  HsOuterExplicit x (map (mapXRec @(NoGhcTc a) reparenTyVar) exp_bndrs)
+reparenOuterTyVarBndrs v@XHsOuterTyVarBndrs{} = v
+
+-- | Add parentheses around the types in an 'HsForAllTelescope' (see 'reparenTypePrec')
+reparenHsForAllTelescope
+  :: forall a
+   . XRecCond a
+  => HsForAllTelescope a
+  -> HsForAllTelescope a
+reparenHsForAllTelescope (HsForAllVis x bndrs) =
+  HsForAllVis x (map (mapXRec @a reparenTyVar) bndrs)
+reparenHsForAllTelescope (HsForAllInvis x bndrs) =
+  HsForAllInvis x (map (mapXRec @a reparenTyVar) bndrs)
+reparenHsForAllTelescope v@XHsForAllTelescope{} = v
+
+-- | Add parenthesis around the types in a 'HsTyVarBndr' (see 'reparenTypePrec')
+reparenTyVar :: XRecCond a => HsTyVarBndr flag a -> HsTyVarBndr flag a
+reparenTyVar (UserTyVar x flag n) = UserTyVar x flag n
+reparenTyVar (KindedTyVar x flag n kind) = KindedTyVar x flag n (reparenLType kind)
+reparenTyVar v@XTyVarBndr{} = v
+
+-- | Add parenthesis around the types in a 'ConDeclField' (see 'reparenTypePrec')
+reparenConDeclField :: XRecCond a => ConDeclField a -> ConDeclField a
+reparenConDeclField (ConDeclField x n t d) = ConDeclField x n (reparenLType t) d
+reparenConDeclField c@XConDeclField{} = c
+
+-------------------------------------------------------------------------------
+
+-- * Located
+
+-------------------------------------------------------------------------------
+
+unL :: GenLocated l a -> a
+unL (L _ x) = x
+
+reL :: a -> GenLocated l a
+reL = L undefined
+
+mapMA :: Monad m => (a -> m b) -> LocatedAn an a -> m (Located b)
+mapMA f (L al a) = L (locA al) <$> f a
+
+-------------------------------------------------------------------------------
+
+-- * NamedThing instances
+
+-------------------------------------------------------------------------------
+
+instance NamedThing (TyClDecl GhcRn) where
+  getName = tcdName
+
+-------------------------------------------------------------------------------
+
+-- * Subordinates
+
+-------------------------------------------------------------------------------
+
+class Parent a where
+  children :: a -> [Name]
+
+instance Parent (ConDecl GhcRn) where
+  children con =
+    case getRecConArgs_maybe con of
+      Nothing -> []
+      Just flds -> map (foExt . unLoc) $ concatMap (cd_fld_names . unLoc) (unLoc flds)
+
+instance Parent (TyClDecl GhcRn) where
+  children d
+    | isDataDecl d =
+        map unLoc $
+          concatMap (toList . getConNames . unLoc) $
+            (dd_cons . tcdDataDefn) d
+    | isClassDecl d =
+        map (unLoc . fdLName . unLoc) (tcdATs d)
+          ++ [unLoc n | L _ (TypeSig _ ns _) <- tcdSigs d, n <- ns]
+    | otherwise = []
+
+-- | A parent and its children
+family :: (NamedThing a, Parent a) => a -> (Name, [Name])
+family = getName &&& children
+
+familyConDecl :: ConDecl GHC.GhcRn -> [(Name, [Name])]
+familyConDecl d = zip (toList $ unLoc <$> getConNames d) (repeat $ children d)
+
+-- | A mapping from the parent (main-binder) to its children and from each
+-- child to its grand-children, recursively.
+families :: TyClDecl GhcRn -> [(Name, [Name])]
+families d
+  | isDataDecl d = family d : concatMap (familyConDecl . unLoc) (dd_cons (tcdDataDefn d))
+  | isClassDecl d = [family d]
+  | otherwise = []
+
+-- | A mapping from child to parent
+parentMap :: TyClDecl GhcRn -> [(Name, Name)]
+parentMap d = [(c, p) | (p, cs) <- families d, c <- cs]
+
+-- | The parents of a subordinate in a declaration
+parents :: Name -> HsDecl GhcRn -> [Name]
+parents n (TyClD _ d) = [p | (c, p) <- parentMap d, c == n]
+parents _ _ = []
+
+-------------------------------------------------------------------------------
+
+-- * Utils that work in monads defined by GHC
+
+-------------------------------------------------------------------------------
+
+modifySessionDynFlags :: (DynFlags -> DynFlags) -> Ghc ()
+modifySessionDynFlags f = do
+  dflags <- getSessionDynFlags
+  _ <- setSessionDynFlags (f dflags)
+  return ()
+
+-------------------------------------------------------------------------------
+
+-- * DynFlags
+
+-------------------------------------------------------------------------------
+
+-- TODO: use `setOutputDir` from GHC
+setOutputDir :: FilePath -> DynFlags -> DynFlags
+setOutputDir dir dynFlags =
+  dynFlags
+    { objectDir = Just dir
+    , hiDir = Just dir
+    , hieDir = Just dir
+    , stubDir = Just dir
+    , includePaths = addGlobalInclude (includePaths dynFlags) [dir]
+    , dumpDir = Just dir
+    }
+
+-------------------------------------------------------------------------------
+
+-- * 'StringBuffer' and 'ByteString'
+
+-------------------------------------------------------------------------------
+-- We get away with a bunch of these functions because 'StringBuffer' and
+-- 'ByteString' have almost exactly the same structure.
+
+-- | Convert a UTF-8 encoded 'ByteString' into a 'StringBuffer. This really
+-- relies on the internals of both 'ByteString' and 'StringBuffer'.
+--
+-- /O(n)/ (but optimized into a @memcpy@ by @bytestring@ under the hood)
+stringBufferFromByteString :: ByteString -> StringBuffer
+stringBufferFromByteString bs =
+  let BS.PS fp off len = bs <> BS.pack [0, 0, 0]
+   in S.StringBuffer{S.buf = fp, S.len = len - 3, S.cur = off}
+
+-- | Take the first @n@ /bytes/ of the 'StringBuffer' and put them in a
+-- 'ByteString'.
+--
+-- /O(1)/
+takeStringBuffer :: Int -> StringBuffer -> ByteString
+takeStringBuffer !n (S.StringBuffer fp _ cur) = BS.PS fp cur n
+
+-- | Return the prefix of the first 'StringBuffer' that /isn't/ in the second
+-- 'StringBuffer'. **The behavior is undefined if the 'StringBuffers' use
+-- separate buffers.**
+--
+-- /O(1)/
+splitStringBuffer :: StringBuffer -> StringBuffer -> ByteString
+splitStringBuffer buf1 buf2 = takeStringBuffer n buf1
+  where
+    n = S.byteDiff buf1 buf2
+
+-- | Split the 'StringBuffer' at the next newline (or the end of the buffer).
+-- Also: initial position is passed in and the updated position is returned.
+--
+-- /O(n)/ (but /O(1)/ space)
+spanLine :: RealSrcLoc -> StringBuffer -> (ByteString, RealSrcLoc, StringBuffer)
+spanLine !loc !buf = go loc buf
+  where
+    go !l !b
+      | not (S.atEnd b) =
+          case S.nextChar b of
+            ('\n', b') -> (splitStringBuffer buf b', advanceSrcLoc l '\n', b')
+            (c, b') -> go (advanceSrcLoc l c) b'
+      | otherwise =
+          (splitStringBuffer buf b, advanceSrcLoc l '\n', b)
+
+-- | Given a start position and a buffer with that start position, split the
+-- buffer at an end position.
+--
+-- /O(n)/ (but /O(1)/ space)
+spanPosition
+  :: RealSrcLoc
+  -- ^ start of buffeer
+  -> RealSrcLoc
+  -- ^ position until which to take
+  -> StringBuffer
+  -- ^ buffer from which to take
+  -> (ByteString, StringBuffer)
+spanPosition !start !end !buf = go start buf
+  where
+    go !l !b
+      | l < end
+      , not (S.atEnd b)
+      , (c, b') <- S.nextChar b =
+          go (advanceSrcLoc l c) b'
+      | otherwise =
+          (splitStringBuffer buf b, b)
+
+-- | Try to parse a line of CPP from the from of the buffer. A \"line\" of CPP
+-- consists of
+--
+--   * at most 10 whitespace characters, including at least one newline
+--   * a @#@ character
+--   * keep parsing lines until you find a line not ending in @\\@.
+--
+-- This is chock full of heuristics about what a line of CPP is.
+--
+-- /O(n)/ (but /O(1)/ space)
+tryCppLine :: RealSrcLoc -> StringBuffer -> Maybe (ByteString, RealSrcLoc, StringBuffer)
+tryCppLine !loc !buf = spanSpace (S.prevChar buf '\n' == '\n') loc buf
+  where
+    -- Keep consuming space characters until we hit either a @#@ or something
+    -- else. If we hit a @#@, start parsing CPP
+    spanSpace !seenNl !l !b
+      | S.atEnd b =
+          Nothing
+      | otherwise =
+          case S.nextChar b of
+            ('#', b')
+              | not (S.atEnd b')
+              , ('-', b'') <- S.nextChar b'
+              , ('}', _) <- S.nextChar b'' ->
+                  Nothing -- Edge case exception for @#-}@
+              | seenNl ->
+                  Just (spanCppLine (advanceSrcLoc l '#') b') -- parse CPP
+              | otherwise ->
+                  Nothing -- We didn't see a newline, so this can't be CPP!
+            (c, b')
+              | isSpace c ->
+                  spanSpace
+                    (seenNl || c == '\n')
+                    (advanceSrcLoc l c)
+                    b'
+              | otherwise -> Nothing
+
+    -- Consume a CPP line to its "end" (basically the first line that ends not
+    -- with a @\@ character)
+    spanCppLine !l !b
+      | S.atEnd b =
+          (splitStringBuffer buf b, l, b)
+      | otherwise =
+          case S.nextChar b of
+            ('\\', b')
+              | not (S.atEnd b')
+              , ('\n', b'') <- S.nextChar b' ->
+                  spanCppLine (advanceSrcLoc (advanceSrcLoc l '\\') '\n') b''
+            ('\n', b') -> (splitStringBuffer buf b', advanceSrcLoc l '\n', b')
+            (c, b') -> spanCppLine (advanceSrcLoc l c) b'
+
+-------------------------------------------------------------------------------
+
+-- * Names in a 'Type'
+
+-------------------------------------------------------------------------------
+
+-- | Given a 'Type', return a set of 'Name's coming from the 'TyCon's within
+-- the type.
+typeNames :: Type -> Set.Set Name
+typeNames ty = go ty Set.empty
+  where
+    go :: Type -> Set.Set Name -> Set.Set Name
+    go t acc =
+      case t of
+        TyVarTy{} -> acc
+        AppTy t1 t2 -> go t2 $ go t1 acc
+        FunTy _ _ t1 t2 -> go t2 $ go t1 acc
+        TyConApp tcon args -> foldl' (\s t' -> go t' s) (Set.insert (getName tcon) acc) args
+        ForAllTy bndr t' -> go t' $ go (tyVarKind (binderVar bndr)) acc
+        LitTy _ -> acc
+        CastTy t' _ -> go t' acc
+        CoercionTy{} -> acc
+
+-------------------------------------------------------------------------------
+
+-- * Free variables of a 'Type'
+
+-------------------------------------------------------------------------------
+
+-- | Get free type variables in a 'Type' in their order of appearance.
+-- See [Ordering of implicit variables].
+orderedFVs
+  :: VarSet
+  -- ^ free variables to ignore
+  -> [Type]
+  -- ^ types to traverse (in order) looking for free variables
+  -> [TyVar]
+  -- ^ free type variables, in the order they appear in
+orderedFVs vs tys =
+  reverse . fst $ tyCoFVsOfTypes' tys (const True) vs ([], emptyVarSet)
+
+-- See the "Free variables of types and coercions" section in 'TyCoRep', or
+-- check out Note [Free variables of types]. The functions in this section
+-- don't output type variables in the order they first appear in in the 'Type'.
+--
+-- For example, 'tyCoVarsOfTypeList' reports an incorrect order for the type
+-- of 'const :: a -> b -> a':
+--
+-- >>> import GHC.Types.Name
+-- >>> import TyCoRep
+-- >>> import GHC.Builtin.Types.Prim
+-- >>> import GHC.Types.Var
+-- >>> a = TyVarTy alphaTyVar
+-- >>> b = TyVarTy betaTyVar
+-- >>> constTy = mkFunTys [a, b] a
+-- >>> map (getOccString . tyVarName) (tyCoVarsOfTypeList constTy)
+-- ["b","a"]
+--
+-- However, we want to reuse the very optimized traversal machinery there, so
+-- so we make our own `tyCoFVsOfType'`, `tyCoFVsBndr'`, and `tyCoVarsOfTypes'`.
+-- All these do differently is traverse in a different order and ignore
+-- coercion variables.
+
+-- | Just like 'tyCoFVsOfType', but traverses type variables in reverse order
+-- of  appearance.
+tyCoFVsOfType' :: Type -> FV
+tyCoFVsOfType' (TyVarTy v) a b c = (FV.unitFV v `unionFV` tyCoFVsOfType' (tyVarKind v)) a b c
+tyCoFVsOfType' (TyConApp _ tys) a b c = tyCoFVsOfTypes' tys a b c
+tyCoFVsOfType' (LitTy{}) a b c = emptyFV a b c
+tyCoFVsOfType' (AppTy fun arg) a b c = (tyCoFVsOfType' arg `unionFV` tyCoFVsOfType' fun) a b c
+tyCoFVsOfType' (FunTy _ w arg res) a b c =
+  ( tyCoFVsOfType' w
+      `unionFV` tyCoFVsOfType' res
+      `unionFV` tyCoFVsOfType' arg
+  )
+    a
+    b
+    c
+tyCoFVsOfType' (ForAllTy bndr ty) a b c = tyCoFVsBndr' bndr (tyCoFVsOfType' ty) a b c
+tyCoFVsOfType' (CastTy ty _) a b c = (tyCoFVsOfType' ty) a b c
+tyCoFVsOfType' (CoercionTy _) a b c = emptyFV a b c
+
+-- | Just like 'tyCoFVsOfTypes', but traverses type variables in reverse order
+-- of appearance.
+tyCoFVsOfTypes' :: [Type] -> FV
+tyCoFVsOfTypes' (ty : tys) fv_cand in_scope acc = (tyCoFVsOfTypes' tys `unionFV` tyCoFVsOfType' ty) fv_cand in_scope acc
+tyCoFVsOfTypes' [] fv_cand in_scope acc = emptyFV fv_cand in_scope acc
+
+-- | Just like 'tyCoFVsBndr', but traverses type variables in reverse order of
+-- appearance.
+tyCoFVsBndr' :: TyVarBinder -> FV -> FV
+tyCoFVsBndr' (Bndr tv _) fvs = FV.delFV tv fvs `unionFV` tyCoFVsOfType' (tyVarKind tv)
+
+-------------------------------------------------------------------------------
+
+-- * Defaulting RuntimeRep variables
+
+-------------------------------------------------------------------------------
+
+-- | Traverses the type, defaulting type variables of kind 'RuntimeRep' to
+-- 'LiftedType'. See 'defaultRuntimeRepVars' in GHC.Iface.Type the original such
+-- function working over `IfaceType`'s.
+defaultRuntimeRepVars :: Type -> Type
+defaultRuntimeRepVars = go emptyVarEnv
+  where
+    go :: TyVarEnv () -> Type -> Type
+    go subs (ForAllTy (Bndr var flg) ty)
+      | isRuntimeRepVar var
+      , isInvisibleForAllTyFlag flg =
+          let subs' = extendVarEnv subs var ()
+           in go subs' ty
+      | otherwise =
+          ForAllTy
+            (Bndr (updateTyVarKind (go subs) var) flg)
+            (go subs ty)
+    go subs (TyVarTy tv)
+      | tv `elemVarEnv` subs =
+          liftedRepTy
+      | otherwise =
+          TyVarTy (updateTyVarKind (go subs) tv)
+    go subs (TyConApp tc tc_args) =
+      TyConApp tc (map (go subs) tc_args)
+    go subs (FunTy af w arg res) =
+      FunTy af (go subs w) (go subs arg) (go subs res)
+    go subs (AppTy t u) =
+      AppTy (go subs t) (go subs u)
+    go subs (CastTy x co) =
+      CastTy (go subs x) co
+    go _ ty@(LitTy{}) = ty
+    go _ ty@(CoercionTy{}) = ty
+
+fromMaybeContext :: Maybe (LHsContext DocNameI) -> HsContext DocNameI
+fromMaybeContext mctxt = unLoc $ fromMaybe (noLocA []) mctxt
diff --git a/utils/haddock/haddock-api/src/Haddock/Interface.hs b/utils/haddock/haddock-api/src/Haddock/Interface.hs
new file mode 100644
index 0000000000000000000000000000000000000000..cd94add63c4f1400cf9e7354500b190389aa7fd3
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Interface.hs
@@ -0,0 +1,343 @@
+{-# LANGUAGE CPP               #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE BangPatterns      #-}
+{-# LANGUAGE NamedFieldPuns    #-}
+{-# LANGUAGE TupleSections     #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Haddock.Interface
+-- Copyright   :  (c) Simon Marlow      2003-2006,
+--                    David Waern       2006-2010,
+--                    Mateusz Kowalczyk 2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- This module typechecks Haskell modules using the GHC API and processes
+-- the result to create 'Interface's. The typechecking and the 'Interface'
+-- creation is interleaved, so that when a module is processed, the
+-- 'Interface's of all previously processed modules are available. The
+-- creation of an 'Interface' from a typechecked module is delegated to
+-- "Haddock.Interface.Create".
+--
+-- When all modules have been typechecked and processed, information about
+-- instances are attached to each 'Interface'. This task is delegated to
+-- "Haddock.Interface.AttachInstances". Note that this is done as a separate
+-- step because GHC can't know about all instances until all modules have been
+-- typechecked.
+--
+-- As a last step a link environment is built which maps names to the \"best\"
+-- places to link to in the documentation, and all 'Interface's are \"renamed\"
+-- using this environment.
+-----------------------------------------------------------------------------
+module Haddock.Interface (
+  processModules
+) where
+
+
+import Haddock.GhcUtils (moduleString, pretty)
+import Haddock.Interface.AttachInstances (attachInstances)
+import Haddock.Interface.Create (createInterface1)
+import Haddock.Interface.Rename (renameInterface)
+import Haddock.InterfaceFile (InterfaceFile, ifInstalledIfaces, ifLinkEnv)
+import Haddock.Options hiding (verbosity)
+import Haddock.Types
+import Haddock.Utils (Verbosity (..), normal, out, verbose)
+
+import Control.Monad
+import Data.List (foldl', isPrefixOf)
+import Data.Traversable (for)
+import qualified Data.Map.Strict as Map
+import qualified Data.Set as Set
+import Debug.Trace (traceMarkerIO)
+import System.Exit (exitFailure ) -- TODO use Haddock's die
+import Text.Printf
+
+import GHC hiding (verbosity, SuccessFlag(..))
+import GHC.Data.FastString (unpackFS)
+import GHC.Data.Graph.Directed
+import GHC.Data.Maybe
+import GHC.Driver.Env
+import GHC.Driver.Monad
+import GHC.Driver.Make
+import GHC.Driver.Main
+import GHC.Core.InstEnv
+import GHC.Driver.Session hiding (verbosity)
+import GHC.HsToCore.Docs (getMainDeclBinder)
+import GHC.Types.Error (mkUnknownDiagnostic)
+import GHC.Types.Name.Occurrence (emptyOccEnv)
+import GHC.Unit.Module.Graph (ModuleGraphNode (..))
+import GHC.Unit.Module.ModDetails
+import GHC.Unit.Module.ModSummary (isBootSummary)
+import GHC.Utils.Outputable ((<+>), pprModuleName)
+import GHC.Utils.Error (withTiming)
+import GHC.Unit.Home.ModInfo
+import GHC.Tc.Utils.Env (lookupGlobal_maybe)
+import GHC.Utils.Outputable (Outputable)
+
+#if defined(mingw32_HOST_OS)
+import System.IO
+import GHC.IO.Encoding.CodePage (mkLocaleEncoding)
+import GHC.IO.Encoding.Failure (CodingFailureMode(TransliterateCodingFailure))
+#endif
+
+-- | Create 'Interface's and a link environment by typechecking the list of
+-- modules using the GHC API and processing the resulting syntax trees.
+processModules
+  :: Verbosity                  -- ^ Verbosity of logging to 'stdout'
+  -> [String]                   -- ^ A list of file or module names sorted by
+                                -- module topology
+  -> [Flag]                     -- ^ Command-line flags
+  -> [InterfaceFile]            -- ^ Interface files of package dependencies
+  -> Ghc ([Interface], LinkEnv) -- ^ Resulting list of interfaces and renaming
+                                -- environment
+processModules verbosity modules flags extIfaces = do
+#if defined(mingw32_HOST_OS)
+  -- Avoid internal error: <stderr>: hPutChar: invalid argument (invalid character)' non UTF-8 Windows
+  liftIO $ hSetEncoding stdout $ mkLocaleEncoding TransliterateCodingFailure
+  liftIO $ hSetEncoding stderr $ mkLocaleEncoding TransliterateCodingFailure
+#endif
+
+  dflags <- getDynFlags
+
+  -- Map from a module to a corresponding installed interface
+  let instIfaceMap :: InstIfaceMap
+      instIfaceMap = Map.fromList
+        [ (instMod iface, iface)
+        | ext <- extIfaces
+        , iface <- ifInstalledIfaces ext
+        ]
+
+  interfaces <- createIfaces verbosity modules flags instIfaceMap
+
+  let exportedNames =
+        Set.unions $ map (Set.fromList . ifaceExports) $
+        filter (\i -> not $ OptHide `elem` ifaceOptions i) interfaces
+      mods = Set.fromList $ map ifaceMod interfaces
+
+  interfaces' <- {-# SCC attachInstances #-}
+                 withTimingM "attachInstances" (const ()) $ do
+                   attachInstances (exportedNames, mods) interfaces instIfaceMap
+
+  -- Combine the link envs of the external packages into one
+  let extLinks  = Map.unions (map ifLinkEnv extIfaces)
+      homeLinks = buildHomeLinks interfaces' -- Build the environment for the home
+                                             -- package
+      links     = homeLinks `Map.union` extLinks
+
+  let warnings = Flag_NoWarnings `notElem` flags
+      ignoredSymbolSet = ignoredSymbols flags
+
+  interfaces'' <-
+    withTimingM "renameAllInterfaces" (const ()) $
+      for interfaces' $ \i -> do
+        withTimingM ("renameInterface: " <+> pprModuleName (moduleName (ifaceMod i))) (const ()) $
+          renameInterface dflags ignoredSymbolSet links warnings (Flag_Hoogle `elem` flags) i
+
+  return (interfaces'', homeLinks)
+
+--------------------------------------------------------------------------------
+-- * Module typechecking and Interface creation
+--------------------------------------------------------------------------------
+
+createIfaces
+    :: Verbosity
+    -- ^ Verbosity requested by the caller
+    -> [String]
+    -- ^ List of modules provided as arguments to Haddock (still in FilePath
+    -- format)
+    -> [Flag]
+    -- ^ Command line flags which Hadddock was invoked with
+    -> InstIfaceMap
+    -- ^ Map from module to corresponding installed interface file
+    -> Ghc [Interface]
+    -- ^ Resulting interfaces
+createIfaces verbosity modules flags instIfaceMap = do
+  targets <- mapM (\filePath -> guessTarget filePath Nothing Nothing) modules
+  setTargets targets
+  (_errs, modGraph) <- depanalE [] False
+
+  liftIO $ traceMarkerIO "Load started"
+  -- Create (if necessary) and load .hi-files.
+  success <- withTimingM "load'" (const ()) $
+               load' noIfaceCache LoadAllTargets mkUnknownDiagnostic (Just batchMsg) modGraph
+  when (failed success) $ do
+    out verbosity normal "load' failed"
+    liftIO exitFailure
+  liftIO $ traceMarkerIO "Load ended"
+
+      -- We topologically sort the module graph including boot files,
+      -- so it should be acylic (hopefully we failed much earlier if this is not the case)
+      -- We then filter out boot modules from the resultant topological sort
+      --
+      -- We do it this way to make 'buildHomeLinks' a bit more stable
+      -- 'buildHomeLinks' depends on the topological order of its input in order
+      -- to construct its result. In particular, modules closer to the bottom of
+      -- the dependency chain are to be prefered for link destinations.
+      --
+      -- If there are cycles in the graph, then this order is indeterminate
+      -- (the nodes in the cycle can be ordered in any way).
+      -- While 'topSortModuleGraph' does guarantee stability for equivalent
+      -- module graphs, seemingly small changes in the ModuleGraph can have
+      -- big impacts on the `LinkEnv` constructed.
+      --
+      -- For example, suppose
+      --  G1 = A.hs -> B.hs -> C.hs (where '->' denotes an import).
+      --
+      -- Then suppose C.hs is changed to have a cyclic dependency on A
+      --
+      --  G2 = A.hs -> B.hs -> C.hs -> A.hs-boot
+      --
+      -- For G1, `C.hs` is preferred for link destinations. However, for G2,
+      -- the topologically sorted order not taking into account boot files (so
+      -- C -> A) is completely indeterminate.
+      -- Using boot files to resolve cycles, we end up with the original order
+      -- [C, B, A] (in decreasing order of preference for links)
+      --
+      -- This exact case came up in testing for the 'base' package, where there
+      -- is a big module cycle involving 'Prelude' on windows, but the cycle doesn't
+      -- include 'Prelude' on non-windows platforms. This lead to drastically different
+      -- LinkEnv's (and failing haddockHtmlTests) across the platforms
+      --
+      -- In effect, for haddock users this behaviour (using boot files to eliminate cycles)
+      -- means that {-# SOURCE #-} imports no longer count towards re-ordering
+      -- the preference of modules for linking.
+      --
+      -- i.e. if module A imports B, then B is preferred over A,
+      -- but if module A {-# SOURCE #-} imports B, then we can't say the same.
+      --
+  let
+      go (AcyclicSCC (ModuleNode _ ms))
+        | NotBoot <- isBootSummary ms = [ms]
+        | otherwise = []
+      go (AcyclicSCC _) = []
+      go (CyclicSCC _) = error "haddock: module graph cyclic even with boot files"
+
+      -- Visit modules in that order
+      sortedMods = concatMap go $ topSortModuleGraph False modGraph Nothing
+  out verbosity normal "Haddock coverage:"
+  (ifaces, _) <- foldM f ([], Map.empty) sortedMods
+  return (reverse ifaces)
+  where
+    f (ifaces, ifaceMap) modSummary = do
+      x <- {-# SCC processModule #-}
+           withTimingM "processModule" (const ()) $ do
+             processModule verbosity modSummary flags ifaceMap instIfaceMap
+      return $ case x of
+        Just iface -> ( iface:ifaces
+                      , Map.insert (ifaceMod iface) iface ifaceMap )
+        Nothing    -> ( ifaces
+                      , ifaceMap ) -- Boot modules don't generate ifaces.
+
+dropErr :: MaybeErr e a -> Maybe a
+dropErr (Succeeded a) = Just a
+dropErr (Failed _) = Nothing
+
+processModule :: Verbosity -> ModSummary -> [Flag] -> IfaceMap -> InstIfaceMap -> Ghc (Maybe Interface)
+processModule verbosity modSummary flags ifaceMap instIfaceMap = do
+  out verbosity verbose $ "Checking module " ++ moduleString (ms_mod modSummary) ++ "..."
+
+  hsc_env <- getSession
+  dflags <- getDynFlags
+  let hmi = case lookupHpt (hsc_HPT hsc_env) (moduleName $ ms_mod modSummary) of
+        Nothing -> error "processModule: All modules should be loaded into the HPT by this point"
+        Just x -> x
+      mod_iface = hm_iface hmi
+      unit_state = hsc_units hsc_env
+
+      cls_insts = instEnvElts . md_insts $ hm_details hmi
+
+      fam_insts = md_fam_insts $ hm_details hmi
+
+      insts = (cls_insts, fam_insts)
+
+  !interface <- do
+    logger <- getLogger
+    {-# SCC createInterface #-}
+      withTiming logger "createInterface" (const ()) $
+        runIfM (liftIO . fmap dropErr . lookupGlobal_maybe hsc_env) $
+          createInterface1 flags unit_state modSummary mod_iface ifaceMap instIfaceMap insts
+
+  let
+    (haddockable, haddocked) =
+      ifaceHaddockCoverage interface
+
+    percentage :: Int
+    percentage = div (haddocked * 100) haddockable
+
+    modString :: String
+    modString = moduleString (ifaceMod interface)
+
+    coverageMsg :: String
+    coverageMsg =
+      printf " %3d%% (%3d /%3d) in '%s'" percentage haddocked haddockable modString
+
+    header :: Bool
+    header = case ifaceDoc interface of
+      Documentation Nothing _ -> False
+      _ -> True
+
+    undocumentedExports :: [String]
+    undocumentedExports =
+      [ formatName (locA s) n
+      | ExportDecl ExportD
+          { expDDecl = L s n
+          , expDMbDoc = (Documentation Nothing _, _)
+          } <- ifaceExportItems interface
+      ]
+        where
+          formatName :: SrcSpan -> HsDecl GhcRn -> String
+          formatName loc n = p (getMainDeclBinder emptyOccEnv n) ++ case loc of
+            RealSrcSpan rss _ -> " (" ++ unpackFS (srcSpanFile rss) ++ ":" ++
+              show (srcSpanStartLine rss) ++ ")"
+            _ -> ""
+
+          p :: Outputable a => [a] -> String
+          p [] = ""
+          p (x:_) = let n = pretty dflags x
+                        ms = modString ++ "."
+                    in if ms `isPrefixOf` n
+                       then drop (length ms) n
+                       else n
+
+  when (OptHide `notElem` ifaceOptions interface) $ do
+    out verbosity normal coverageMsg
+    when (Flag_NoPrintMissingDocs `notElem` flags
+          && not (null undocumentedExports && header)) $ do
+      out verbosity normal "  Missing documentation for:"
+      unless header $ out verbosity normal "    Module header"
+      mapM_ (out verbosity normal . ("    " ++)) undocumentedExports
+
+  return (Just interface)
+
+
+--------------------------------------------------------------------------------
+-- * Building of cross-linking environment
+--------------------------------------------------------------------------------
+
+
+-- | Build a mapping which for each original name, points to the "best"
+-- place to link to in the documentation.  For the definition of
+-- "best", we use "the module nearest the bottom of the dependency
+-- graph which exports this name", not including hidden modules.  When
+-- there are multiple choices, we pick a random one.
+--
+-- The interfaces are passed in in topologically sorted order, but we start
+-- by reversing the list so we can do a foldl.
+buildHomeLinks :: [Interface] -> LinkEnv
+buildHomeLinks ifaces = foldl' upd Map.empty (reverse ifaces)
+  where
+    upd old_env iface
+      | OptHide `elem` ifaceOptions iface =
+          old_env
+      | OptNotHome `elem` ifaceOptions iface =
+          foldl' keep_old old_env exported_names
+      | otherwise =
+          foldl' keep_new old_env exported_names
+      where
+        exported_names = ifaceVisibleExports iface ++ map getName (ifaceInstances iface)
+        mdl            = ifaceMod iface
+        keep_old env n = Map.insertWith (\_ old -> old) n mdl env
+        keep_new env n = Map.insert n mdl env
diff --git a/utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs b/utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs
new file mode 100644
index 0000000000000000000000000000000000000000..0293afb7479a4a69cfc73755830ccd8cb170af9d
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs
@@ -0,0 +1,414 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE NamedFieldPuns #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Interface.AttachInstances
+-- Copyright   :  (c) Simon Marlow 2006,
+--                    David Waern  2006-2009,
+--                    Isaac Dupree 2009
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Interface.AttachInstances (attachInstances, instHead) where
+
+import Haddock.Convert
+import Haddock.GhcUtils (typeNames)
+import Haddock.Types
+
+import Control.Applicative ((<|>))
+import Control.Arrow hiding ((<+>))
+import Control.DeepSeq (force)
+import Data.Foldable (foldl', toList)
+import Data.List (sortBy)
+import qualified Data.Map.Strict as Map
+import Data.Maybe (fromMaybe, mapMaybe, maybeToList)
+import Data.Ord (comparing)
+import qualified Data.Sequence as Seq
+import qualified Data.Set as Set
+
+import GHC
+import GHC.Builtin.Types (unrestrictedFunTyConName)
+import GHC.Core (isOrphan)
+import GHC.Core.Class
+import GHC.Core.Coercion
+import GHC.Core.Coercion.Axiom
+import GHC.Core.FamInstEnv
+import GHC.Core.InstEnv
+import GHC.Core.TyCo.Compare (eqType)
+import GHC.Core.TyCo.Rep
+import GHC.Core.TyCon
+import GHC.Data.FastString (unpackFS)
+import GHC.Driver.Env.Types
+import GHC.HsToCore.Docs
+import GHC.Iface.Load
+import GHC.Tc.Instance.Family
+import GHC.Tc.Utils.Env
+import GHC.Tc.Utils.Monad
+import GHC.Types.Name
+import GHC.Types.Name.Env
+import GHC.Types.Name.Set
+import GHC.Types.SrcLoc
+import GHC.Types.Unique.Map
+import GHC.Types.Var hiding (varName)
+import GHC.Unit.Env
+import GHC.Unit.Module.Env (mkModuleSet, moduleSetElts)
+import GHC.Unit.State
+import GHC.Utils.Outputable (sep, text, (<+>))
+
+type ExportedNames = Set.Set Name
+type Modules = Set.Set Module
+type ExportInfo = (ExportedNames, Modules)
+
+-- Also attaches fixities
+attachInstances :: ExportInfo -> [Interface] -> InstIfaceMap -> Ghc [Interface]
+attachInstances expInfo ifaces instIfaceMap = do
+  -- We need to keep load modules in which we will look for instances. We've
+  -- somewhat arbitrarily decided to load all modules which are available -
+  -- either directly or from a re-export.
+  --
+  -- See https://github.com/haskell/haddock/issues/469.
+  env <- getSession
+  let mod_to_pkg_conf = moduleNameProvidersMap $ ue_units $ hsc_unit_env env
+      mods =
+        mkModuleSet
+          [ m
+          | mod_map <- nonDetEltsUniqMap mod_to_pkg_conf
+          , ( m
+              , ModOrigin
+                  { fromOrigUnit = fromOrig
+                  , fromExposedReexport = reExp
+                  }
+              ) <-
+              nonDetUniqMapToList mod_map
+          , fromOrig == Just True || not (null reExp)
+          ]
+      mods_to_load = moduleSetElts mods
+      mods_visible = mkModuleSet $ map ifaceMod ifaces
+
+  (_msgs, mb_index) <- do
+    hsc_env <- getSession
+    liftIO $ runTcInteractive hsc_env $ do
+      let doc = text "Need interface for haddock"
+      initIfaceTcRn $ mapM_ (loadSysInterface doc) mods_to_load
+      cls_env@InstEnvs{ie_global, ie_local} <- tcGetInstEnvs
+      fam_env@(pkg_fie, home_fie) <- tcGetFamInstEnvs
+      -- We use Data.Sequence.Seq because we are creating left associated
+      -- mappends.
+      -- cls_index and fam_index below are adapted from GHC.Tc.Module.lookupInsts
+      let cls_index =
+            Map.fromListWith
+              mappend
+              [ (n, Seq.singleton ispec)
+              | ispec <- instEnvElts ie_local ++ instEnvElts ie_global
+              , instIsVisible mods_visible ispec
+              , n <- nameSetElemsStable $ orphNamesOfClsInst ispec
+              ]
+          fam_index =
+            Map.fromListWith
+              mappend
+              [ (n, Seq.singleton fispec)
+              | fispec <- famInstEnvElts home_fie ++ famInstEnvElts pkg_fie
+              , n <- nameSetElemsStable $ orphNamesOfFamInst fispec
+              ]
+          instance_map =
+            mkNameEnv $
+              [ (nm, (toList clss, toList fams))
+              | (nm, (clss, fams)) <-
+                  Map.toList $
+                    Map.unionWith
+                      mappend
+                      (fmap (,Seq.empty) cls_index)
+                      (fmap (Seq.empty,) fam_index)
+              ]
+      pure $ (cls_env{ie_visible = mods_visible}, fam_env, instance_map)
+
+  let empty_index = (InstEnvs emptyInstEnv emptyInstEnv mods_visible, emptyFamInstEnvs, emptyNameEnv)
+  mapM (attach $ fromMaybe empty_index mb_index) ifaces
+  where
+    -- TODO: take an IfaceMap as input
+    ifaceMap = Map.fromList [(ifaceMod i, i) | i <- ifaces]
+
+    attach (cls_insts, fam_insts, inst_map) iface = do
+      let getInstDoc = findInstDoc iface ifaceMap instIfaceMap
+          getFixity = findFixity iface ifaceMap instIfaceMap
+
+      newItems <-
+        mapM
+          (attachToExportItem cls_insts fam_insts inst_map expInfo getInstDoc getFixity)
+          (ifaceExportItems iface)
+      let orphanInstances = attachOrphanInstances expInfo getInstDoc (ifaceInstances iface) fam_insts
+      return $
+        iface
+          { ifaceExportItems = newItems
+          , ifaceOrphanInstances = orphanInstances
+          }
+
+attachOrphanInstances
+  :: ExportInfo
+  -> (Name -> Maybe (MDoc Name))
+  -- ^ how to lookup the doc of an instance
+  -> [ClsInst]
+  -- ^ a list of orphan instances
+  -> FamInstEnvs
+  -- ^ all the family instances (that we know of)
+  -> [DocInstance GhcRn]
+attachOrphanInstances expInfo getInstDoc cls_instances fam_index =
+  [ (synifyInstHead i famInsts, getInstDoc n, (L (getSrcSpan n) n), nameModule_maybe n)
+  | let is = [(instanceSig i, getName i) | i <- cls_instances, isOrphan (is_orphan i)]
+  , (i@(_, _, cls, tys), n) <- sortBy (comparing $ first instHead) is
+  , not $ isInstanceHidden expInfo (getName cls) tys
+  , let famInsts = getFamInsts expInfo fam_index getInstDoc cls tys
+  ]
+
+attachToExportItem
+  :: InstEnvs
+  -- ^ all class instances (that we know of)
+  -> FamInstEnvs
+  -- ^ all the family instances (that we know of)
+  -> NameEnv ([ClsInst], [FamInst])
+  -- ^ all instances again, but for looking up instances for data families
+  -> ExportInfo
+  -> (Name -> Maybe (MDoc Name))
+  -- ^ how to lookup the doc of an instance
+  -> (Name -> Maybe Fixity)
+  -- ^ how to lookup a fixity
+  -> ExportItem GhcRn
+  -> Ghc (ExportItem GhcRn)
+attachToExportItem cls_index fam_index index expInfo getInstDoc getFixity export =
+  case attachFixities export of
+    ExportDecl e@(ExportD{expDDecl = L eSpan (TyClD _ d)}) -> do
+      insts <-
+        let nm = tcdName d
+            (cls_instances, fam_instances) = case d of
+              -- For type classes we can be more efficient by looking up the class in the inst map
+              ClassDecl{} -> (classNameInstances cls_index nm, familyNameInstances fam_index nm)
+              -- Otherwise, we have to filter through all the instances to see if they mention this
+              -- name. See GHCi :info implementation
+              _ -> fromMaybe ([], []) $ lookupNameEnv index nm
+
+            fam_insts =
+              [ ( synFamInst
+                , getInstDoc n
+                , spanNameE n synFamInst (L (locA eSpan) (tcdName d))
+                , mb_mdl
+                )
+              | i <- sortBy (comparing instFam) fam_instances
+              , let n = getName i
+              , not $ isNameHidden expInfo (fi_fam i)
+              , not $ any (isTypeHidden expInfo) (fi_tys i)
+              , let opaque = isTypeHidden expInfo (fi_rhs i)
+                    synFamInst = synifyFamInst i opaque
+                    !mb_mdl = force $ nameModule_maybe n
+              ]
+            cls_insts =
+              [ ( synClsInst
+                , getInstDoc n
+                , spanName n synClsInst (L (locA eSpan) (tcdName d))
+                , mb_mdl
+                )
+              | let is = [(instanceSig i, getName i) | i <- cls_instances]
+              , (i@(_, _, cls, tys), n) <- sortBy (comparing $ first instHead) is
+              , not $ isInstanceHidden expInfo (getName cls) tys
+              , let synClsInst = synifyInstHead i famInsts
+                    famInsts = getFamInsts expInfo fam_index getInstDoc cls tys
+                    !mb_mdl = force $ nameModule_maybe n
+              ]
+            -- fam_insts but with failing type fams filtered out
+            cleanFamInsts = [(fi, n, L l r, m) | (Right fi, n, L l (Right r), m) <- fam_insts]
+            famInstErrs = [errm | (Left errm, _, _, _) <- fam_insts]
+         in do
+              let mkBug = (text "haddock-bug:" <+>) . text
+              putMsgM (sep $ map mkBug famInstErrs)
+              return $ cls_insts ++ cleanFamInsts
+      return $ ExportDecl e{expDInstances = insts}
+    e -> return e
+  where
+    attachFixities
+      ( ExportDecl
+          ( e@ExportD
+              { expDDecl = L _ d
+              , expDPats = patsyns
+              , expDSubDocs = subDocs
+              }
+            )
+        ) =
+        ExportDecl
+          e
+            { expDFixities = fixities
+            }
+        where
+          fixities :: [(Name, Fixity)]
+          !fixities = force . Map.toList $ foldl' f Map.empty all_names
+
+          f :: Map.Map Name Fixity -> Name -> Map.Map Name Fixity
+          f !fs n = Map.alter (<|> getFixity n) n fs
+
+          patsyn_names :: [Name]
+          patsyn_names = concatMap (getMainDeclBinder emptyOccEnv . fst) patsyns
+
+          all_names :: [Name]
+          all_names =
+            getMainDeclBinder emptyOccEnv d
+              ++ map fst subDocs
+              ++ patsyn_names
+    attachFixities e = e
+
+    -- spanName: attach the location to the name that is the same file as the instance location
+    spanName s (InstHead{ihdClsName = clsn}) (L instL instn) =
+      let s1 = getSrcSpan s
+          sn =
+            if srcSpanFileName_maybe s1 == srcSpanFileName_maybe instL
+              then instn
+              else clsn
+       in L (getSrcSpan s) sn
+    -- spanName on Either
+    spanNameE s (Left e) _ = L (getSrcSpan s) (Left e)
+    spanNameE s (Right ok) linst =
+      let L l r = spanName s ok linst
+       in L l (Right r)
+
+substAgrees :: [(TyVar, Type)] -> [(TyVar, Type)] -> Bool
+substAgrees xs ys = go xs
+  where
+    go [] = True
+    go ((v, t1) : zs) = case lookup v ys of
+      Nothing -> go zs
+      Just t2 -> eqType t1 t2 && go zs
+
+getFamInsts
+  :: ExportInfo
+  -> FamInstEnvs
+  -- ^ all the family instances (that we know of)
+  -> (Name -> Maybe (MDoc Name))
+  -- ^ how to lookup the doc of an instance
+  -> Class
+  -> [Type]
+  -> [(FamInst, Bool, Maybe (MDoc Name), Located Name, Maybe Module)]
+getFamInsts expInfo fam_index getInstDoc cls tys =
+  [ (f_i, opaque, getInstDoc f_n, L (getSrcSpan f_n) f_n, nameModule_maybe f_n)
+  | fam <- classATs cls
+  , let vars = tyConTyVars fam
+        tv_env = zip (classTyVars cls) tys
+        m_instantiation = mapM (\v -> lookup v tv_env) vars
+  , f_i <- case m_instantiation of
+      -- If we have a complete instantation, we can just lookup in the family environment
+      Just instantiation -> map fim_instance $ lookupFamInstEnv fam_index fam instantiation
+      -- If we don't have a complete instantation, we need to look over all possible instances
+      -- for the family and filter out the ones that don't agree with the typeclass instance
+      Nothing ->
+        [ f_i
+        | f_i <- familyInstances fam_index fam
+        , let co_tvs = tyConTyVars fam
+              (_, lhs, _) = etaExpandCoAxBranch $ coAxiomSingleBranch $ fi_axiom f_i
+        , substAgrees (zip co_tvs lhs) tv_env
+        ]
+  , let ax = fi_axiom f_i
+        f_n = co_ax_name ax
+  , not $ isNameHidden expInfo (fi_fam f_i)
+  , not $ any (isTypeHidden expInfo) (fi_tys f_i)
+  , let opaque = isTypeHidden expInfo (fi_rhs f_i)
+  ]
+
+-- | Lookup the doc associated with a certain instance
+findInstDoc :: Interface -> IfaceMap -> InstIfaceMap -> Name -> Maybe (MDoc Name)
+findInstDoc iface ifaceMap instIfaceMap = \name ->
+  (Map.lookup name . ifaceDocMap $ iface)
+    <|> (Map.lookup name . ifaceDocMap =<< Map.lookup (nameModule name) ifaceMap)
+    <|> (Map.lookup name . instDocMap =<< Map.lookup (nameModule name) instIfaceMap)
+
+-- | Lookup the fixity associated with a certain name
+findFixity :: Interface -> IfaceMap -> InstIfaceMap -> Name -> Maybe Fixity
+findFixity iface ifaceMap instIfaceMap = \name ->
+  (Map.lookup name . ifaceFixMap $ iface)
+    <|> (Map.lookup name . ifaceFixMap =<< Map.lookup (nameModule name) ifaceMap)
+    <|> (Map.lookup name . instFixMap =<< Map.lookup (nameModule name) instIfaceMap)
+
+--------------------------------------------------------------------------------
+-- Collecting and sorting instances
+--------------------------------------------------------------------------------
+
+instHead :: ([TyVar], [PredType], Class, [Type]) -> ([Int], SName, [SimpleType])
+instHead (_, _, cls, args) =
+  (map argCount args, SName (className cls), map simplify args)
+
+argCount :: Type -> Int
+argCount (AppTy t _) = argCount t + 1
+argCount (TyConApp _ ts) = length ts
+argCount (FunTy _ _ _ _) = 2
+argCount (ForAllTy _ t) = argCount t
+argCount (CastTy t _) = argCount t
+argCount _ = 0
+
+simplify :: Type -> SimpleType
+simplify (FunTy _ _ t1 t2) = SimpleType (SName unrestrictedFunTyConName) [simplify t1, simplify t2]
+simplify (ForAllTy _ t) = simplify t
+simplify (AppTy t1 t2) = SimpleType s (ts ++ maybeToList (simplify_maybe t2))
+  where
+    (SimpleType s ts) = simplify t1
+simplify (TyVarTy v) = SimpleType (SName (tyVarName v)) []
+simplify (TyConApp tc ts) =
+  SimpleType
+    (SName (tyConName tc))
+    (mapMaybe simplify_maybe ts)
+simplify (LitTy (NumTyLit n)) = SimpleIntTyLit n
+simplify (LitTy (StrTyLit s)) = SimpleStringTyLit (unpackFS s)
+simplify (LitTy (CharTyLit c)) = SimpleCharTyLit c
+simplify (CastTy ty _) = simplify ty
+simplify (CoercionTy _) = error "simplify:Coercion"
+
+simplify_maybe :: Type -> Maybe SimpleType
+simplify_maybe (CoercionTy{}) = Nothing
+simplify_maybe ty = Just (simplify ty)
+
+-- Used for sorting
+instFam :: FamInst -> ([Int], SName, [SimpleType], Int, SimpleType)
+instFam FamInst{fi_fam = n, fi_tys = ts, fi_rhs = t} =
+  (map argCount ts, SName n, map simplify ts, argCount t, simplify t)
+
+--------------------------------------------------------------------------------
+-- Filtering hidden instances
+--------------------------------------------------------------------------------
+
+-- | A class or data type is hidden iff
+--
+-- * it is defined in one of the modules that are being processed
+--
+-- * and it is not exported by any non-hidden module
+isNameHidden :: ExportInfo -> Name -> Bool
+isNameHidden (names, modules) name =
+  nameModule name `Set.member` modules
+    && not (name `Set.member` names)
+
+-- | We say that an instance is «hidden» iff its class or any (part)
+-- of its type(s) is hidden.
+isInstanceHidden :: ExportInfo -> Name -> [Type] -> Bool
+isInstanceHidden expInfo cls tyNames =
+  instClassHidden || instTypeHidden
+  where
+    instClassHidden :: Bool
+    instClassHidden = isNameHidden expInfo cls
+
+    instTypeHidden :: Bool
+    instTypeHidden = any (isTypeHidden expInfo) tyNames
+
+isTypeHidden :: ExportInfo -> Type -> Bool
+isTypeHidden expInfo = typeHidden
+  where
+    typeHidden :: Type -> Bool
+    typeHidden t = any nameHidden $ typeNames t
+
+    nameHidden :: Name -> Bool
+    nameHidden = isNameHidden expInfo
diff --git a/utils/haddock/haddock-api/src/Haddock/Interface/Create.hs b/utils/haddock/haddock-api/src/Haddock/Interface/Create.hs
new file mode 100644
index 0000000000000000000000000000000000000000..df63ba98f1ec7f7fa8d441dddd899fc986001f45
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Interface/Create.hs
@@ -0,0 +1,1008 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE DerivingStrategies #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE NamedFieldPuns #-}
+{-# LANGUAGE OverloadedRecordDot #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE ViewPatterns #-}
+{-# OPTIONS_GHC -Wwarn #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Interface.Create
+-- Copyright   :  (c) Simon Marlow      2003-2006,
+--                    David Waern       2006-2009,
+--                    Mateusz Kowalczyk 2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- This module provides a single function 'createInterface',
+-- which creates a Haddock 'Interface' from the typechecking
+-- results 'TypecheckedModule' from GHC.
+module Haddock.Interface.Create (IfM, runIfM, createInterface1) where
+
+import Documentation.Haddock.Doc
+import Haddock.Convert (PrintRuntimeReps (..), tyThingToLHsDecl)
+import Haddock.GhcUtils
+import Haddock.Interface.LexParseRn
+import Haddock.Options (Flag (..), modulePackageInfo)
+import Haddock.Types
+import Haddock.Utils (replace)
+
+import Control.DeepSeq
+import Control.Monad.State.Strict
+import Data.Foldable
+import Data.IntMap (IntMap)
+import qualified Data.IntMap as IM
+import qualified Data.List.NonEmpty as NE
+import Data.Map.Strict (Map)
+import qualified Data.Map.Strict as Map
+import Data.Maybe (catMaybes, isJust, mapMaybe, maybeToList)
+import Data.Traversable (for)
+
+import Control.Arrow (first, (&&&))
+import GHC hiding (lookupName)
+import GHC.Builtin.Names
+import GHC.Builtin.Types
+import GHC.Builtin.Types.Prim
+import GHC.Core.ConLike (ConLike (..))
+import GHC.Data.FastString (FastString, bytesFS, unpackFS)
+import GHC.Driver.Ppr
+import GHC.HsToCore.Docs hiding (mkMaps)
+import GHC.Iface.Syntax
+import GHC.Types.Avail
+import GHC.Types.Basic
+import GHC.Types.Name
+import GHC.Types.Name.Set
+import GHC.Types.SafeHaskell
+import qualified GHC.Types.SrcLoc as SrcLoc
+import qualified GHC.Types.Unique.Map as UniqMap
+import GHC.Unit.Module.ModIface
+import GHC.Unit.State (PackageName (..), UnitState)
+import qualified GHC.Utils.Outputable as O
+import GHC.Utils.Panic (pprPanic)
+
+createInterface1
+  :: MonadIO m
+  => [Flag]
+  -> UnitState
+  -> ModSummary
+  -> ModIface
+  -> IfaceMap
+  -> InstIfaceMap
+  -> ([ClsInst], [FamInst])
+  -> IfM m Interface
+createInterface1 flags unit_state mod_sum mod_iface ifaces inst_ifaces (instances, fam_instances) = do
+  let
+    ModSummary
+      { -- Cached flags from OPTIONS, INCLUDE and LANGUAGE
+      -- pragmas in the modules source code. Used to infer
+      -- safety of module.
+      ms_hspp_opts
+      , ms_location =
+        ModLocation
+          { ml_hie_file
+          }
+      } = mod_sum
+
+    dflags = ms_hspp_opts
+    mdl = mi_module mod_iface
+    sem_mdl = mi_semantic_module mod_iface
+    is_sig = isJust (mi_sig_of mod_iface)
+    safety = getSafeMode (mi_trust mod_iface)
+
+    (pkg_name_fs, _) =
+      modulePackageInfo unit_state flags (Just mdl)
+
+    pkg_name :: Maybe Package
+    pkg_name =
+      let
+        unpack (PackageName name) = unpackFS name
+       in
+        fmap unpack pkg_name_fs
+
+    warnings = mi_warns mod_iface
+
+    -- See Note [Exporting built-in items]
+    special_exports
+      | mdl == gHC_PRIM = funAvail
+      | otherwise = []
+    !exportedNames =
+      concatMap
+        availNames
+        (special_exports <> mi_exports mod_iface)
+
+    fixities :: FixMap
+    fixities = mkFixMap exportedNames (mi_fixities mod_iface)
+
+    -- This is used for looking up the Name of a default method
+    -- from its OccName. See Note [default method Name] in GHC.Iface.Recomp
+    def_meths_env = mkOccEnv def_meths
+    def_meths =
+      [ (nameOccName nm, nm)
+      | (_, IfaceId{ifName = nm}) <- mi_decls mod_iface
+      , let occ = nameOccName nm
+      , isDefaultMethodOcc occ
+      ]
+
+  mod_iface_docs <- case mi_docs mod_iface of
+    Just docs -> pure docs
+    Nothing -> do
+      warn $ showPpr dflags mdl ++ " has no docs in its .hi file"
+      pure emptyDocs
+  -- Derive final options to use for haddocking this module
+  doc_opts <- mkDocOpts (docs_haddock_opts mod_iface_docs) flags mdl
+
+  let prr
+        | OptPrintRuntimeRep `elem` doc_opts = ShowRuntimeRep
+        | otherwise = HideRuntimeRep
+
+  (!info, header_doc) <-
+    processModuleHeader
+      dflags
+      pkg_name
+      safety
+      (docs_language mod_iface_docs)
+      (docs_extensions mod_iface_docs)
+      (docs_mod_hdr mod_iface_docs)
+  mod_warning <- moduleWarning dflags warnings
+
+  (docMap :: DocMap Name) <- do
+    let docsDecls = Map.fromList $ UniqMap.nonDetUniqMapToList mod_iface_docs.docs_decls
+    traverse (processDocStringsParas dflags pkg_name) docsDecls
+
+  exportsSinceMap <- mkExportSinceMap dflags pkg_name mod_iface_docs
+
+  (argMap :: Map Name (Map Int (MDoc Name))) <- do
+    let docsArgs = Map.fromList $ UniqMap.nonDetUniqMapToList mod_iface_docs.docs_args
+    (result :: Map Name (IntMap (MDoc Name))) <-
+      traverse (traverse (processDocStringParas dflags pkg_name)) docsArgs
+    let result2 = Map.map (\intMap -> Map.fromList $ IM.assocs intMap) result
+    pure $ result2
+
+  warningMap <- mkWarningMap dflags warnings exportedNames
+
+  let local_instances =
+        filter (nameIsLocalOrFrom sem_mdl) $
+          map getName instances
+            ++ map getName fam_instances
+      instanceMap = Map.fromList [(l, n) | n <- local_instances, RealSrcSpan l _ <- [getSrcSpan n]]
+
+  -- See Note [Exporting built-in items]
+  let builtinTys = DsiSectionHeading 1 (WithHsDocIdentifiers (mkGeneratedHsDocString "Builtin syntax") [])
+      bonus_ds mods
+        | mdl == gHC_PRIM = [builtinTys, DsiExports funAvail] <> mods
+        | otherwise = mods
+
+  let
+    -- Warnings in this module and transitive warnings from dependent modules
+    transitiveWarnings :: Map Name (Doc Name)
+    transitiveWarnings = Map.unions (warningMap : map ifaceWarningMap (Map.elems ifaces))
+
+  export_items <-
+    mkExportItems
+      prr
+      ifaces
+      pkg_name
+      mdl
+      transitiveWarnings
+      exportsSinceMap
+      docMap
+      argMap
+      fixities
+      (docs_named_chunks mod_iface_docs)
+      (bonus_ds $ docs_structure mod_iface_docs)
+      inst_ifaces
+      dflags
+      def_meths_env
+
+  let
+    visible_names :: [Name]
+    visible_names = mkVisibleNames instanceMap export_items doc_opts
+
+    -- Measure haddock documentation coverage.
+    pruned_export_items :: [ExportItem GhcRn]
+    pruned_export_items = pruneExportItems export_items
+
+    !haddockable = 1 + length export_items -- module + exports
+    !haddocked = (if isJust header_doc then 1 else 0) + length pruned_export_items
+
+    coverage :: (Int, Int)
+    !coverage = (haddockable, haddocked)
+
+  return $!
+    Interface
+      { ifaceMod = mdl
+      , ifaceIsSig = is_sig
+      , ifaceHieFile = ml_hie_file
+      , ifaceInfo = info
+      , ifaceDoc = Documentation header_doc mod_warning
+      , ifaceRnDoc = Documentation Nothing Nothing
+      , ifaceOptions = doc_opts
+      , ifaceDocMap = docMap
+      , ifaceArgMap = argMap
+      , ifaceExportItems =
+          if OptPrune `elem` doc_opts
+            then pruned_export_items
+            else export_items
+      , ifaceRnExportItems = []
+      , ifaceExports = exportedNames
+      , ifaceVisibleExports = visible_names
+      , ifaceFixMap = fixities
+      , ifaceInstances = instances
+      , ifaceOrphanInstances = [] -- Filled in attachInstances
+      , ifaceRnOrphanInstances = [] -- Filled in renameInterfaceRn
+      , ifaceHaddockCoverage = coverage
+      , ifaceWarningMap = warningMap
+      , ifaceDynFlags = dflags
+      , ifaceDefMeths = def_meths
+      }
+  where
+    -- Note [Exporting built-in items]
+    --
+    -- @(->)@ does not show up in module exports simply because Haskell
+    -- lacks the concrete syntax to represent such an export. We'd still like
+    -- it to show up in docs, so we manually patch "GHC.Prim" and "Prelude"
+    -- to have an extra exports for @(->)@
+    --
+    funAvail = [AvailTC fUNTyConName [fUNTyConName]]
+
+-------------------------------------------------------------------------------
+-- Export @since annotations
+-------------------------------------------------------------------------------
+mkExportSinceMap
+  :: forall m
+   . MonadIO m
+  => DynFlags
+  -> Maybe Package
+  -> Docs
+  -> IfM m (Map Name MetaSince)
+mkExportSinceMap dflags pkg_name docs = do
+  Map.unions <$> traverse processExportDoc (UniqMap.nonDetUniqMapToList (docs_exports docs))
+  where
+    processExportDoc :: (Name, HsDoc GhcRn) -> IfM m (Map Name MetaSince)
+    processExportDoc (nm, doc) = do
+      mdoc <- processDocStringsParas dflags pkg_name [doc]
+      case _doc mdoc of
+        DocEmpty -> return ()
+        _ -> warn "Export docstrings may only contain @since annotations"
+      case _metaSince (_meta mdoc) of
+        Nothing -> return mempty
+        Just since -> return $ Map.singleton nm since
+
+-------------------------------------------------------------------------------
+-- Warnings
+-------------------------------------------------------------------------------
+
+mkWarningMap
+  :: MonadIO m
+  => DynFlags
+  -> IfaceWarnings
+  -> [Name]
+  -> IfM m WarningMap
+mkWarningMap dflags warnings exps =
+  case warnings of
+    IfWarnSome ws _ ->
+      let expsOccEnv = mkOccEnv [(nameOccName n, n) | n <- exps]
+          ws' = flip mapMaybe ws $ \(occ, w) ->
+            -- Ensure we also look in the record field namespace. If the OccName
+            -- resolves to multiple GREs, take the first.
+            case lookupOccEnv_WithFields expsOccEnv occ of
+              (n : _) -> Just (n, w)
+              [] -> Nothing
+       in Map.fromList <$> traverse (traverse (parseWarning dflags)) ws'
+    _ -> pure Map.empty
+
+moduleWarning
+  :: MonadIO m
+  => DynFlags
+  -> IfaceWarnings
+  -> IfM m (Maybe (Doc Name))
+moduleWarning dflags (IfWarnAll w) = Just <$> parseWarning dflags w
+moduleWarning _ _ = pure Nothing
+
+parseWarning
+  :: MonadIO m
+  => DynFlags
+  -> IfaceWarningTxt
+  -> IfM m (Doc Name)
+parseWarning dflags w = case w of
+  IfDeprecatedTxt _ msg -> format "Deprecated: " (map dstToDoc msg)
+  IfWarningTxt _ _ msg -> format "Warning: " (map dstToDoc msg)
+  where
+    dstToDoc :: (IfaceStringLiteral, [Name]) -> HsDoc GhcRn
+    dstToDoc ((IfStringLiteral _ fs), ids) = WithHsDocIdentifiers (fsToDoc fs) (map noLoc ids)
+
+    fsToDoc :: FastString -> HsDocString
+    fsToDoc fs = GeneratedDocString $ HsDocStringChunk (bytesFS fs)
+
+    format x bs =
+      DocWarning . DocParagraph . DocAppend (DocString x)
+        <$> foldrM (\doc rest -> docAppend <$> processDocString dflags doc <*> pure rest) DocEmpty bs
+
+-------------------------------------------------------------------------------
+-- Doc options
+--
+-- Haddock options that are embedded in the source file
+-------------------------------------------------------------------------------
+
+mkDocOpts :: MonadIO m => Maybe String -> [Flag] -> Module -> IfM m [DocOption]
+mkDocOpts mbOpts flags mdl = do
+  opts <- case mbOpts of
+    Just opts -> case words $ replace ',' ' ' opts of
+      [] -> warn "No option supplied to DOC_OPTION/doc_option" >> return []
+      xs -> fmap catMaybes (mapM parseOption xs)
+    Nothing -> return []
+  pure (foldl go opts flags)
+  where
+    mdlStr = moduleString mdl
+
+    -- Later flags override earlier ones
+    go os m
+      | m == Flag_HideModule mdlStr = OptHide : os
+      | m == Flag_ShowModule mdlStr = filter (/= OptHide) os
+      | m == Flag_ShowAllModules = filter (/= OptHide) os
+      | m == Flag_ShowExtensions mdlStr = OptShowExtensions : os
+      | otherwise = os
+
+parseOption :: MonadIO m => String -> IfM m (Maybe DocOption)
+parseOption "hide" = return (Just OptHide)
+parseOption "prune" = return (Just OptPrune)
+parseOption "not-home" = return (Just OptNotHome)
+parseOption "show-extensions" = return (Just OptShowExtensions)
+parseOption "print-explicit-runtime-reps" = return (Just OptPrintRuntimeRep)
+parseOption other = warn ("Unrecognised option: " ++ other) >> return Nothing
+
+--------------------------------------------------------------------------------
+-- Declarations
+--------------------------------------------------------------------------------
+
+-- | Extract a map of fixity declarations only
+mkFixMap :: [Name] -> [(OccName, Fixity)] -> FixMap
+mkFixMap exps occFixs =
+  Map.fromList $ flip mapMaybe occFixs $ \(occ, fix_) ->
+    (,fix_) <$> lookupOccEnv expsOccEnv occ
+  where
+    expsOccEnv = mkOccEnv (map (nameOccName &&& id) exps)
+
+-- | Build the list of items that will become the documentation, from the
+-- export list.  At this point, the list of ExportItems is in terms of
+-- original names.
+--
+-- We create the export items even if the module is hidden, since they
+-- might be useful when creating the export items for other modules.
+mkExportItems
+  :: MonadIO m
+  => PrintRuntimeReps
+  -> IfaceMap
+  -> Maybe Package -- this package
+  -> Module -- this module
+  -> WarningMap
+  -> Map Name MetaSince
+  -> DocMap Name
+  -> ArgMap Name
+  -> FixMap
+  -> Map String (HsDoc GhcRn) -- named chunks
+  -> DocStructure
+  -> InstIfaceMap
+  -> DynFlags
+  -> OccEnv Name
+  -> IfM m [ExportItem GhcRn]
+mkExportItems
+  prr
+  modMap
+  pkgName
+  thisMod
+  warnings
+  exportSinceMap
+  docMap
+  argMap
+  fixMap
+  namedChunks
+  dsItems
+  instIfaceMap
+  dflags
+  defMeths =
+    concat <$> traverse lookupExport dsItems
+    where
+      lookupExport :: MonadIO m => DocStructureItem -> IfM m [ExportItem GhcRn]
+      lookupExport = \case
+        DsiSectionHeading lev hsDoc' -> do
+          doc <- processDocString dflags hsDoc'
+          pure [ExportGroup lev "" doc]
+        DsiDocChunk hsDoc' -> do
+          doc <- processDocStringParas dflags pkgName hsDoc'
+          pure [ExportDoc doc]
+        DsiNamedChunkRef ref -> do
+          case Map.lookup ref namedChunks of
+            Nothing -> do
+              warn $ "Cannot find documentation for: $" ++ ref
+              pure []
+            Just hsDoc' -> do
+              doc <- processDocStringParas dflags pkgName hsDoc'
+              pure [ExportDoc doc]
+        DsiExports avails ->
+          -- TODO: We probably don't need nubAvails here.
+          -- mkDocStructureFromExportList already uses it.
+          concat <$> traverse availExport (nubAvails avails)
+        DsiModExport mod_names avails -> do
+          -- only consider exporting a module if we are sure we are really
+          -- exporting the whole module and not some subset.
+          (unrestricted_mods, remaining_avails) <- unrestrictedModExports dflags thisMod modMap instIfaceMap avails (NE.toList mod_names)
+          avail_exps <- concat <$> traverse availExport remaining_avails
+          pure (map ExportModule unrestricted_mods ++ avail_exps)
+
+      availExport :: MonadIO m => AvailInfo -> IfM m [ExportItem GhcRn]
+      availExport avail =
+        availExportItem
+          prr
+          modMap
+          thisMod
+          warnings
+          exportSinceMap
+          docMap
+          argMap
+          fixMap
+          instIfaceMap
+          dflags
+          avail
+          defMeths
+
+unrestrictedModExports
+  :: MonadIO m
+  => DynFlags
+  -> Module
+  -- ^ Current Module
+  -> IfaceMap
+  -- ^ Already created interfaces
+  -> InstIfaceMap
+  -- ^ Interfaces in other packages
+  -> Avails
+  -> [ModuleName]
+  -- ^ Modules to be exported
+  -> IfM m ([Module], Avails)
+  -- ^ ( modules exported without restriction
+  --   , remaining exports not included in any
+  --     of these modules
+  --   )
+unrestrictedModExports dflags thisMod ifaceMap instIfaceMap avails mod_names = do
+  mods_and_exports <- fmap catMaybes $ for mod_names $ \mod_name -> do
+    let m_local = mkModule (moduleUnit thisMod) mod_name
+    case Map.lookup m_local ifaceMap of
+      -- First lookup locally
+      Just iface -> pure $ Just (ifaceMod iface, mkNameSet (ifaceExports iface))
+      Nothing ->
+        case Map.lookup mod_name instIfaceMap' of
+          Just iface -> pure $ Just (instMod iface, mkNameSet (instExports iface))
+          Nothing -> do
+            warn $
+              "Warning: "
+                ++ pretty dflags thisMod
+                ++ ": Could not find "
+                ++ "documentation for exported module: "
+                ++ pretty dflags mod_name
+            pure Nothing
+  let unrestricted = filter everythingVisible mods_and_exports
+      mod_exps = unionNameSets (map snd unrestricted)
+      remaining = nubAvails (filterAvails (\n -> not (n `elemNameSet` mod_exps)) avails)
+  pure (map fst unrestricted, remaining)
+  where
+    instIfaceMap' = Map.mapKeys moduleName instIfaceMap
+    all_names = availsToNameSet avails
+
+    -- Is everything in this (supposedly re-exported) module visible?
+    everythingVisible :: (Module, NameSet) -> Bool
+    everythingVisible (mdl, exps)
+      | not (exps `isSubsetOf` all_names) = False
+      | Just iface <- Map.lookup mdl ifaceMap = OptHide `notElem` ifaceOptions iface
+      | Just iface <- Map.lookup (moduleName mdl) instIfaceMap' = OptHide `notElem` instOptions iface
+      | otherwise = True
+
+    -- TODO: Add a utility based on IntMap.isSubmapOfBy
+    isSubsetOf :: NameSet -> NameSet -> Bool
+    isSubsetOf a b = nameSetAll (`elemNameSet` b) a
+
+availExportItem
+  :: forall m
+   . MonadIO m
+  => PrintRuntimeReps
+  -> IfaceMap
+  -> Module -- this module
+  -> WarningMap
+  -> Map Name MetaSince
+  -- ^ export \@since declarations
+  -> Map Name (MDoc Name) -- docs (keyed by 'Name's)
+  -> ArgMap Name -- docs for arguments (keyed by 'Name's)
+  -> FixMap
+  -> InstIfaceMap
+  -> DynFlags
+  -> AvailInfo
+  -> OccEnv Name -- Default methods
+  -> IfM m [ExportItem GhcRn]
+availExportItem
+  prr
+  modMap
+  thisMod
+  warnings
+  exportSinceMap
+  docMap
+  argMap
+  fixMap
+  instIfaceMap
+  dflags
+  availInfo
+  defMeths =
+    declWith availInfo
+    where
+      declWith :: AvailInfo -> IfM m [ExportItem GhcRn]
+      declWith avail = do
+        let t = availName avail
+        mayDecl <- hiDecl dflags prr t
+        case mayDecl of
+          Nothing -> return [ExportNoDecl t []]
+          Just decl -> do
+            availExportDecl avail decl =<< do
+              -- Find docs for decl
+              let tmod = nameModule t
+              if tmod == thisMod
+                then pure (lookupDocs avail warnings docMap argMap defMeths)
+                else case Map.lookup tmod modMap of
+                  Just iface ->
+                    pure $
+                      first (applyExportSince exportSinceMap t) $
+                        lookupDocs avail warnings (ifaceDocMap iface) (ifaceArgMap iface) (mkOccEnv (ifaceDefMeths iface))
+                  Nothing ->
+                    -- We try to get the subs and docs
+                    -- from the installed .haddock file for that package.
+                    -- TODO: This needs to be more sophisticated to deal
+                    -- with signature inheritance
+                    case Map.lookup (nameModule t) instIfaceMap of
+                      Nothing -> do
+                        warn $
+                          "Warning: "
+                            ++ pretty dflags thisMod
+                            ++ ": Couldn't find .haddock for export "
+                            ++ pretty dflags t
+                        let subs_ = availNoDocs avail
+                        pure (noDocForDecl, subs_)
+                      Just instIface ->
+                        pure $
+                          first (applyExportSince exportSinceMap t) $
+                            lookupDocs avail warnings (instDocMap instIface) (instArgMap instIface) (mkOccEnv (instDefMeths instIface))
+
+      -- Tries 'extractDecl' first then falls back to 'hiDecl' if that fails
+      availDecl :: Name -> LHsDecl GhcRn -> IfM m (LHsDecl GhcRn)
+      availDecl declName parentDecl =
+        extractDecl prr dflags declName parentDecl >>= \case
+          Right d -> pure d
+          Left err -> do
+            synifiedDeclOpt <- hiDecl dflags prr declName
+            case synifiedDeclOpt of
+              Just synifiedDecl -> pure synifiedDecl
+              Nothing -> pprPanic "availExportItem" (O.text err)
+
+      availExportDecl
+        :: AvailInfo
+        -> LHsDecl GhcRn
+        -> (DocForDecl Name, [(Name, DocForDecl Name)])
+        -> IfM m [ExportItem GhcRn]
+      availExportDecl avail decl (doc, subs)
+        | availExportsDecl avail = do
+            extractedDecl <- availDecl (availName avail) decl
+
+            -- bundled pattern synonyms only make sense if the declaration is
+            -- exported (otherwise there would be nothing to bundle to)
+            bundledPatSyns <- findBundledPatterns avail
+
+            let
+              !patSynNames =
+                force $
+                  concatMap (getMainDeclBinder emptyOccEnv . fst) bundledPatSyns
+
+              !doc' = force doc
+              !subs' = force subs
+
+              !restrictToNames = force $ fmap fst subs'
+
+              !fixities =
+                force
+                  [ (n, f)
+                  | n <- availName avail : fmap fst subs' ++ patSynNames
+                  , Just f <- [Map.lookup n fixMap]
+                  ]
+
+            return
+              [ ExportDecl
+                  ExportD
+                    { expDDecl = restrictTo restrictToNames extractedDecl
+                    , expDPats = bundledPatSyns
+                    , expDMbDoc = doc'
+                    , expDSubDocs = subs'
+                    , expDInstances = []
+                    , expDFixities = fixities
+                    , expDSpliced = False
+                    }
+              ]
+        | otherwise = for subs $ \(sub, sub_doc) -> do
+            extractedDecl <- availDecl sub decl
+
+            let
+              !fixities = force [(sub, f) | Just f <- [Map.lookup sub fixMap]]
+              !subDoc = force sub_doc
+
+            return $
+              ExportDecl
+                ExportD
+                  { expDDecl = extractedDecl
+                  , expDPats = []
+                  , expDMbDoc = subDoc
+                  , expDSubDocs = []
+                  , expDInstances = []
+                  , expDFixities = fixities
+                  , expDSpliced = False
+                  }
+
+      findBundledPatterns :: AvailInfo -> IfM m [(HsDecl GhcRn, DocForDecl Name)]
+      findBundledPatterns avail = do
+        patsyns <- for constructor_names $ \name -> do
+          mtyThing <- lookupName name
+          case mtyThing of
+            Just (AConLike PatSynCon{}) -> do
+              export_items <- declWith (Avail name)
+              pure
+                [ (unLoc patsyn_decl, patsyn_doc)
+                | ExportDecl
+                    ExportD
+                      { expDDecl = patsyn_decl
+                      , expDMbDoc = patsyn_doc
+                      } <-
+                    export_items
+                ]
+            _ -> pure []
+        pure (concat patsyns)
+        where
+          constructor_names =
+            filter isDataConName (availSubordinates avail)
+
+availSubordinates :: AvailInfo -> [Name]
+availSubordinates = availSubordinateNames
+
+availNoDocs :: AvailInfo -> [(Name, DocForDecl Name)]
+availNoDocs avail =
+  zip (availSubordinates avail) (repeat noDocForDecl)
+
+-- | Override 'MetaSince' of a declaration with that of its export if appropriate.
+applyExportSince
+  :: Map Name MetaSince
+  -> Name
+  -> DocForDecl Name
+  -> DocForDecl Name
+applyExportSince exportSinceMap nm (dd, argDoc)
+  | Just since <- Map.lookup nm exportSinceMap =
+      let dd' = dd{documentationDoc = setMDocSince (documentationDoc dd)}
+          setMDocSince :: Maybe (MDoc name) -> Maybe (MDoc name)
+          setMDocSince (Just (MetaDoc meta doc)) = Just $ MetaDoc (meta{_metaSince = Just since}) doc
+          setMDocSince Nothing = Just $ MetaDoc (Meta{_metaSince = Just since}) DocEmpty
+       in (dd', argDoc)
+applyExportSince _ _ dd = dd
+
+hiDecl
+  :: MonadIO m
+  => DynFlags
+  -> PrintRuntimeReps
+  -> Name
+  -> IfM m (Maybe (LHsDecl GhcRn))
+hiDecl dflags prr t = do
+  mayTyThing <- lookupName t
+  case mayTyThing of
+    Nothing -> do
+      warn $ "Warning: Not found in environment: " ++ pretty dflags t
+      return Nothing
+    Just x -> case tyThingToLHsDecl prr x of
+      Left m -> (warn $ bugWarn m) >> return Nothing
+      Right (m, t') -> mapM (warn . bugWarn) m >> return (Just $ L (noAnnSrcSpan (nameSrcSpan t)) t')
+  where
+    warnLine x =
+      O.text "haddock-bug:"
+        O.<+> O.text x
+        O.<> O.comma
+        O.<+> O.quotes (O.ppr t)
+        O.<+> O.text "-- Please report this on Haddock issue tracker!"
+    bugWarn = showSDoc dflags . warnLine
+
+-- | Lookup docs for a declaration from maps.
+lookupDocs
+  :: AvailInfo
+  -> WarningMap
+  -> Map Name (MDoc Name)
+  -> ArgMap Name
+  -> OccEnv Name
+  -> (DocForDecl Name, [(Name, DocForDecl Name)])
+  -- ^ documentation for declaration and its subordinates
+lookupDocs avail warningMap docMap argMap def_meths_env =
+  let
+    n = availName avail
+    lookupArgDoc x = Map.findWithDefault Map.empty x argMap
+    doc = (lookupDoc n, lookupArgDoc n)
+    subs = availSubordinates avail
+    def_meths =
+      [ (meth, (lookupDoc meth, lookupArgDoc meth))
+      | s <- subs
+      , let dmOcc = mkDefaultMethodOcc (nameOccName s)
+      , Just meth <- [lookupOccEnv def_meths_env dmOcc]
+      , availExportsDecl avail
+      ]
+    subDocs =
+      [ (s, (lookupDoc s, lookupArgDoc s))
+      | s <- subs
+      ]
+        ++ def_meths
+   in
+    (doc, subDocs)
+  where
+    lookupDoc name = Documentation (Map.lookup name docMap) (Map.lookup name warningMap)
+
+-- Note [1]:
+------------
+-- It is unnecessary to document a subordinate by itself at the top level if
+-- any of its parents is also documented. Furthermore, if the subordinate is a
+-- record field or a class method, documenting it under its parent
+-- indicates its special status.
+--
+-- A user might expect that it should show up separately, so we issue a
+-- warning. It's a fine opportunity to also tell the user she might want to
+-- export the subordinate through the parent export item for clarity.
+--
+-- The code removes top-level subordinates also when the parent is exported
+-- through a 'module' export. I think that is fine.
+--
+-- (For more information, see Trac #69)
+
+-- | Sometimes the declaration we want to export is not the "main" declaration:
+-- it might be an individual record selector or a class method.  In these
+-- cases we have to extract the required declaration (and somehow cobble
+-- together a type signature for it...).
+--
+-- This function looks through the declarations in this module to try to find
+-- the one with the right name.
+extractDecl
+  :: MonadIO m
+  => PrintRuntimeReps
+  -> DynFlags
+  -> Name
+  -- ^ name of the declaration to extract
+  -> LHsDecl GhcRn
+  -- ^ parent declaration
+  -> IfM m (Either String (LHsDecl GhcRn))
+extractDecl prr dflags name decl
+  | name `elem` getMainDeclBinder emptyOccEnv (unLoc decl) = pure $ Right decl
+  | otherwise =
+      case unLoc decl of
+        TyClD
+          _
+          d@ClassDecl
+            { tcdLName = L _ clsNm
+            , tcdSigs = clsSigs
+            , tcdATs = clsATs
+            } ->
+            let
+              matchesMethod =
+                [ lsig
+                | lsig <- clsSigs
+                , ClassOpSig _ False _ _ <- pure $ unLoc lsig
+                , -- Note: exclude `default` declarations (see #505)
+                name `elem` sigName lsig
+                ]
+
+              matchesAssociatedType =
+                [ lfam_decl
+                | lfam_decl <- clsATs
+                , name == unLoc (fdLName (unLoc lfam_decl))
+                ]
+             in
+              -- TODO: document fixity
+              case (matchesMethod, matchesAssociatedType) of
+                ([s0], _) ->
+                  let tyvar_names = tyClDeclTyVars d
+                      L pos sig = addClassContext clsNm tyvar_names s0
+                   in pure (Right $ L pos (SigD noExtField sig))
+                (_, [L pos fam_decl]) -> pure (Right $ L pos (TyClD noExtField (FamDecl noExtField fam_decl)))
+                ([], []) -> do
+                  famInstDeclOpt <- hiDecl dflags prr name
+                  case famInstDeclOpt of
+                    Nothing ->
+                      pure $
+                        Left
+                          ( concat
+                              [ "Ambiguous decl for "
+                              , getOccString name
+                              , " in class "
+                              , getOccString clsNm
+                              ]
+                          )
+                    Just famInstDecl -> extractDecl prr dflags name famInstDecl
+                _ ->
+                  pure $
+                    Left
+                      ( concat
+                          [ "Ambiguous decl for "
+                          , getOccString name
+                          , " in class "
+                          , getOccString clsNm
+                          ]
+                      )
+        TyClD
+          _
+          d@DataDecl
+            { tcdLName = L _ dataNm
+            , tcdDataDefn = HsDataDefn{dd_cons = dataCons}
+            } -> pure $ do
+            let ty_args = lHsQTyVarsToTypes (tyClDeclTyVars d)
+            lsig <-
+              if isDataConName name
+                then extractPatternSyn name dataNm ty_args (toList dataCons)
+                else extractRecSel name dataNm ty_args (toList dataCons)
+            pure (SigD noExtField <$> lsig)
+        TyClD _ FamDecl{}
+          | isValName name -> do
+              famInstOpt <- hiDecl dflags prr name
+              case famInstOpt of
+                Just famInst -> extractDecl prr dflags name famInst
+                Nothing -> pure $ Left ("extractDecl: Unhandled decl for " ++ getOccString name)
+        InstD
+          _
+          ( DataFamInstD
+              _
+              ( DataFamInstDecl
+                  ( FamEqn
+                      { feqn_tycon = L _ n
+                      , feqn_pats = tys
+                      , feqn_rhs = defn
+                      }
+                    )
+                )
+            ) ->
+            pure $
+              if isDataConName name
+                then fmap (SigD noExtField) <$> extractPatternSyn name n tys (toList $ dd_cons defn)
+                else fmap (SigD noExtField) <$> extractRecSel name n tys (toList $ dd_cons defn)
+        InstD _ (ClsInstD _ ClsInstDecl{cid_datafam_insts = insts})
+          | isDataConName name ->
+              let matches =
+                    [ d' | L _ d'@(DataFamInstDecl (FamEqn{feqn_rhs = dd})) <- insts, name `elem` map unLoc (concatMap (toList . getConNames . unLoc) (dd_cons dd))
+                    ]
+               in case matches of
+                    [d0] -> extractDecl prr dflags name (noLocA (InstD noExtField (DataFamInstD noExtField d0)))
+                    _ -> pure $ Left "internal: extractDecl (ClsInstD)"
+          | otherwise ->
+              let matches =
+                    [ d'
+                    | L _ d'@(DataFamInstDecl d) <-
+                        insts
+                    , -- , L _ ConDecl { con_details = RecCon rec } <- toList $ dd_cons (feqn_rhs d)
+                    Just rec <- toList $ getRecConArgs_maybe . unLoc <$> dd_cons (feqn_rhs d)
+                    , ConDeclField{cd_fld_names = ns} <- map unLoc (unLoc rec)
+                    , L _ n <- ns
+                    , foExt n == name
+                    ]
+               in case matches of
+                    [d0] -> extractDecl prr dflags name (noLocA . InstD noExtField $ DataFamInstD noExtField d0)
+                    _ -> pure $ Left "internal: extractDecl (ClsInstD)"
+        _ -> pure $ Left ("extractDecl: Unhandled decl for " ++ getOccString name)
+
+extractPatternSyn
+  :: Name
+  -> Name
+  -> [LHsTypeArg GhcRn]
+  -> [LConDecl GhcRn]
+  -> Either String (LSig GhcRn)
+extractPatternSyn nm t tvs cons =
+  case filter matches cons of
+    [] ->
+      Left . O.showSDocOneLine O.defaultSDocContext $
+        O.text "constructor pattern " O.<+> O.ppr nm O.<+> O.text "not found in type" O.<+> O.ppr t
+    con : _ -> pure (extract <$> con)
+  where
+    matches :: LConDecl GhcRn -> Bool
+    matches (L _ con) = nm `elem` (unLoc <$> getConNames con)
+    extract :: ConDecl GhcRn -> Sig GhcRn
+    extract con =
+      let args =
+            case con of
+              ConDeclH98{con_args = con_args'} -> case con_args' of
+                PrefixCon _ args' -> map hsScaledThing args'
+                RecCon (L _ fields) -> cd_fld_type . unLoc <$> fields
+                InfixCon arg1 arg2 -> map hsScaledThing [arg1, arg2]
+              ConDeclGADT{con_g_args = con_args'} -> case con_args' of
+                PrefixConGADT _ args' -> map hsScaledThing args'
+                RecConGADT _ (L _ fields) -> cd_fld_type . unLoc <$> fields
+          typ = longArrow args (data_ty con)
+          typ' =
+            case con of
+              ConDeclH98{con_mb_cxt = Just cxt} -> noLocA (HsQualTy noExtField cxt typ)
+              _ -> typ
+          typ'' = noLocA (HsQualTy noExtField (noLocA []) typ')
+       in PatSynSig noAnn [noLocA nm] (mkEmptySigType typ'')
+
+    longArrow :: [LHsType GhcRn] -> LHsType GhcRn -> LHsType GhcRn
+    longArrow inputs output = foldr (\x y -> noLocA (HsFunTy noExtField (HsUnrestrictedArrow noExtField) x y)) output inputs
+
+    data_ty con
+      | ConDeclGADT{} <- con = con_res_ty con
+      | otherwise = foldl' (\x y -> noLocA (mkAppTyArg x y)) (noLocA (HsTyVar noAnn NotPromoted (noLocA t))) tvs
+      where
+        mkAppTyArg :: LHsType GhcRn -> LHsTypeArg GhcRn -> HsType GhcRn
+        mkAppTyArg f (HsValArg _ ty) = HsAppTy noExtField f ty
+        mkAppTyArg f (HsTypeArg _ ki) = HsAppKindTy noExtField f ki
+        mkAppTyArg f (HsArgPar _) = HsParTy noAnn f
+
+extractRecSel
+  :: Name
+  -> Name
+  -> [LHsTypeArg GhcRn]
+  -> [LConDecl GhcRn]
+  -> Either String (LSig GhcRn)
+extractRecSel _ _ _ [] = Left "extractRecSel: selector not found"
+extractRecSel nm t tvs (L _ con : rest) =
+  case getRecConArgs_maybe con of
+    Just (L _ fields)
+      | ((l, L _ (ConDeclField _ _nn ty _)) : _) <- matching_fields fields ->
+          pure (L (noAnnSrcSpan l) (TypeSig noAnn [noLocA nm] (mkEmptyWildCardBndrs $ mkEmptySigType (noLocA (HsFunTy noExtField (HsUnrestrictedArrow noExtField) data_ty (getBangType ty))))))
+    _ -> extractRecSel nm t tvs rest
+  where
+    matching_fields :: [LConDeclField GhcRn] -> [(SrcSpan, LConDeclField GhcRn)]
+    matching_fields flds =
+      [ (locA l, f) | f@(L _ (ConDeclField _ ns _ _)) <- flds, L l n <- ns, foExt n == nm
+      ]
+    data_ty
+      -- ResTyGADT _ ty <- con_res con = ty
+      | ConDeclGADT{} <- con = con_res_ty con
+      | otherwise = foldl' (\x y -> noLocA (mkAppTyArg x y)) (noLocA (HsTyVar noAnn NotPromoted (noLocA t))) tvs
+      where
+        mkAppTyArg :: LHsType GhcRn -> LHsTypeArg GhcRn -> HsType GhcRn
+        mkAppTyArg f (HsValArg _ ty) = HsAppTy noExtField f ty
+        mkAppTyArg f (HsTypeArg _ ki) = HsAppKindTy noExtField f ki
+        mkAppTyArg f (HsArgPar _) = HsParTy noAnn f
+
+-- | Keep export items with docs.
+pruneExportItems :: [ExportItem GhcRn] -> [ExportItem GhcRn]
+pruneExportItems = filter hasDoc
+  where
+    hasDoc (ExportDecl ExportD{expDMbDoc = (Documentation d _, _)}) = isJust d
+    hasDoc _ = True
+
+mkVisibleNames :: InstMap -> [ExportItem GhcRn] -> [DocOption] -> [Name]
+mkVisibleNames instMap exports opts
+  | OptHide `elem` opts = []
+  | otherwise =
+      let ns = concatMap exportName exports
+       in seqList ns `seq` ns
+  where
+    exportName (ExportDecl e@ExportD{}) = name ++ subs ++ patsyns
+      where
+        subs = map fst (expDSubDocs e)
+        patsyns = concatMap (getMainDeclBinder emptyOccEnv . fst) (expDPats e)
+        name = case unLoc $ expDDecl e of
+          InstD _ d -> maybeToList $ SrcLoc.lookupSrcSpan (getInstLoc d) instMap
+          decl -> getMainDeclBinder emptyOccEnv decl
+    exportName ExportNoDecl{} = [] -- we don't count these as visible, since
+    -- we don't want links to go to them.
+    exportName _ = []
+
+seqList :: [a] -> ()
+seqList [] = ()
+seqList (x : xs) = x `seq` seqList xs
diff --git a/utils/haddock/haddock-api/src/Haddock/Interface/Json.hs b/utils/haddock/haddock-api/src/Haddock/Interface/Json.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b9abcf9c29c8432c5fd74504aedc57a34dac86b9
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Interface/Json.hs
@@ -0,0 +1,277 @@
+{-# LANGUAGE RecordWildCards #-}
+
+module Haddock.Interface.Json
+  ( jsonInstalledInterface
+  , jsonInterfaceFile
+  , renderJson
+  ) where
+
+import GHC.Types.Fixity
+import GHC.Types.Name
+import GHC.Unit.Module
+import GHC.Utils.Json
+import GHC.Utils.Outputable
+
+import Control.Arrow
+import Data.Map (Map)
+import qualified Data.Map as Map
+
+import Haddock.InterfaceFile
+import Haddock.Types
+
+jsonInterfaceFile :: InterfaceFile -> JsonDoc
+jsonInterfaceFile InterfaceFile{..} =
+  jsonObject
+    [ ("link_env", jsonMap nameStableString (jsonString . moduleNameString . moduleName) ifLinkEnv)
+    , ("inst_ifaces", jsonArray (map jsonInstalledInterface ifInstalledIfaces))
+    ]
+
+jsonInstalledInterface :: InstalledInterface -> JsonDoc
+jsonInstalledInterface InstalledInterface{..} = jsonObject properties
+  where
+    properties =
+      [ ("module", jsonModule instMod)
+      , ("is_sig", jsonBool instIsSig)
+      , ("info", jsonHaddockModInfo instInfo)
+      , ("doc_map", jsonMap nameStableString jsonMDoc instDocMap)
+      , ("arg_map", jsonMap nameStableString (jsonMap show jsonMDoc) instArgMap)
+      , ("exports", jsonArray (map jsonName instExports))
+      , ("visible_exports", jsonArray (map jsonName instVisibleExports))
+      , ("options", jsonArray (map (jsonString . show) instOptions))
+      , ("fix_map", jsonMap nameStableString jsonFixity instFixMap)
+      ]
+
+jsonHaddockModInfo :: HaddockModInfo Name -> JsonDoc
+jsonHaddockModInfo HaddockModInfo{..} =
+  jsonObject
+    [ ("description", jsonMaybe jsonDoc hmi_description)
+    , ("copyright", jsonMaybe jsonString hmi_copyright)
+    , ("maintainer", jsonMaybe jsonString hmi_maintainer)
+    , ("stability", jsonMaybe jsonString hmi_stability)
+    , ("protability", jsonMaybe jsonString hmi_portability)
+    , ("safety", jsonMaybe jsonString hmi_safety)
+    , ("language", jsonMaybe (jsonString . show) hmi_language)
+    , ("extensions", jsonArray (map (jsonString . show) hmi_extensions))
+    ]
+
+jsonMap :: (a -> String) -> (b -> JsonDoc) -> Map a b -> JsonDoc
+jsonMap f g = jsonObject . map (f *** g) . Map.toList
+
+jsonMDoc :: MDoc Name -> JsonDoc
+jsonMDoc MetaDoc{..} =
+  jsonObject
+    [ ("meta", jsonObject [("version", jsonMaybe (jsonString . show . sinceVersion) (_metaSince _meta))])
+    , ("document", jsonDoc _doc)
+    ]
+
+showModName :: Wrap (ModuleName, OccName) -> String
+showModName = showWrapped (moduleNameString . fst)
+
+showName :: Wrap Name -> String
+showName = showWrapped nameStableString
+
+jsonDoc :: Doc Name -> JsonDoc
+jsonDoc DocEmpty =
+  jsonObject
+    [("tag", jsonString "DocEmpty")]
+jsonDoc (DocAppend x y) =
+  jsonObject
+    [ ("tag", jsonString "DocAppend")
+    , ("first", jsonDoc x)
+    , ("second", jsonDoc y)
+    ]
+jsonDoc (DocString s) =
+  jsonObject
+    [ ("tag", jsonString "DocString")
+    , ("string", jsonString s)
+    ]
+jsonDoc (DocParagraph x) =
+  jsonObject
+    [ ("tag", jsonString "DocParagraph")
+    , ("document", jsonDoc x)
+    ]
+jsonDoc (DocIdentifier name) =
+  jsonObject
+    [ ("tag", jsonString "DocIdentifier")
+    , ("name", jsonString (showName name))
+    ]
+jsonDoc (DocIdentifierUnchecked modName) =
+  jsonObject
+    [ ("tag", jsonString "DocIdentifierUnchecked")
+    , ("modName", jsonString (showModName modName))
+    ]
+jsonDoc (DocModule (ModLink m _l)) =
+  jsonObject
+    [ ("tag", jsonString "DocModule")
+    , ("string", jsonString m)
+    ]
+jsonDoc (DocWarning x) =
+  jsonObject
+    [ ("tag", jsonString "DocWarning")
+    , ("document", jsonDoc x)
+    ]
+jsonDoc (DocEmphasis x) =
+  jsonObject
+    [ ("tag", jsonString "DocEmphasis")
+    , ("document", jsonDoc x)
+    ]
+jsonDoc (DocMonospaced x) =
+  jsonObject
+    [ ("tag", jsonString "DocMonospaced")
+    , ("document", jsonDoc x)
+    ]
+jsonDoc (DocBold x) =
+  jsonObject
+    [ ("tag", jsonString "DocBold")
+    , ("document", jsonDoc x)
+    ]
+jsonDoc (DocUnorderedList xs) =
+  jsonObject
+    [ ("tag", jsonString "DocUnorderedList")
+    , ("documents", jsonArray (fmap jsonDoc xs))
+    ]
+jsonDoc (DocOrderedList xs) =
+  jsonObject
+    [ ("tag", jsonString "DocOrderedList")
+    , ("items", jsonArray (fmap jsonItem xs))
+    ]
+  where
+    jsonItem (index, a) = jsonObject [("document", jsonDoc a), ("seq", jsonInt index)]
+jsonDoc (DocDefList xys) =
+  jsonObject
+    [ ("tag", jsonString "DocDefList")
+    , ("definitions", jsonArray (fmap jsonDef xys))
+    ]
+  where
+    jsonDef (x, y) = jsonObject [("document", jsonDoc x), ("y", jsonDoc y)]
+jsonDoc (DocCodeBlock x) =
+  jsonObject
+    [ ("tag", jsonString "DocCodeBlock")
+    , ("document", jsonDoc x)
+    ]
+jsonDoc (DocHyperlink hyperlink) =
+  jsonObject
+    [ ("tag", jsonString "DocHyperlink")
+    , ("hyperlink", jsonHyperlink hyperlink)
+    ]
+  where
+    jsonHyperlink Hyperlink{..} =
+      jsonObject
+        [ ("hyperlinkUrl", jsonString hyperlinkUrl)
+        , ("hyperlinkLabel", jsonMaybe jsonDoc hyperlinkLabel)
+        ]
+jsonDoc (DocPic picture) =
+  jsonObject
+    [ ("tag", jsonString "DocPic")
+    , ("picture", jsonPicture picture)
+    ]
+  where
+    jsonPicture Picture{..} =
+      jsonObject
+        [ ("pictureUrl", jsonString pictureUri)
+        , ("pictureLabel", jsonMaybe jsonString pictureTitle)
+        ]
+jsonDoc (DocMathInline s) =
+  jsonObject
+    [ ("tag", jsonString "DocMathInline")
+    , ("string", jsonString s)
+    ]
+jsonDoc (DocMathDisplay s) =
+  jsonObject
+    [ ("tag", jsonString "DocMathDisplay")
+    , ("string", jsonString s)
+    ]
+jsonDoc (DocAName s) =
+  jsonObject
+    [ ("tag", jsonString "DocAName")
+    , ("string", jsonString s)
+    ]
+jsonDoc (DocProperty s) =
+  jsonObject
+    [ ("tag", jsonString "DocProperty")
+    , ("string", jsonString s)
+    ]
+jsonDoc (DocExamples examples) =
+  jsonObject
+    [ ("tag", jsonString "DocExamples")
+    , ("examples", jsonArray (fmap jsonExample examples))
+    ]
+  where
+    jsonExample Example{..} =
+      jsonObject
+        [ ("exampleExpression", jsonString exampleExpression)
+        , ("exampleResult", jsonArray (fmap jsonString exampleResult))
+        ]
+jsonDoc (DocHeader header) =
+  jsonObject
+    [ ("tag", jsonString "DocHeader")
+    , ("header", jsonHeader header)
+    ]
+  where
+    jsonHeader Header{..} =
+      jsonObject
+        [ ("headerLevel", jsonInt headerLevel)
+        , ("headerTitle", jsonDoc headerTitle)
+        ]
+jsonDoc (DocTable table) =
+  jsonObject
+    [ ("tag", jsonString "DocTable")
+    , ("table", jsonTable table)
+    ]
+  where
+    jsonTable Table{..} =
+      jsonObject
+        [ ("tableHeaderRows", jsonArray (fmap jsonTableRow tableHeaderRows))
+        , ("tableBodyRows", jsonArray (fmap jsonTableRow tableBodyRows))
+        ]
+
+    jsonTableRow TableRow{..} = jsonArray (fmap jsonTableCell tableRowCells)
+
+    jsonTableCell TableCell{..} =
+      jsonObject
+        [ ("tableCellColspan", jsonInt tableCellColspan)
+        , ("tableCellRowspan", jsonInt tableCellRowspan)
+        , ("tableCellContents", jsonDoc tableCellContents)
+        ]
+
+jsonModule :: Module -> JsonDoc
+jsonModule = JSString . moduleStableString
+
+jsonName :: Name -> JsonDoc
+jsonName = JSString . nameStableString
+
+jsonFixity :: Fixity -> JsonDoc
+jsonFixity (Fixity _ prec dir) =
+  jsonObject
+    [ ("prec", jsonInt prec)
+    , ("direction", jsonFixityDirection dir)
+    ]
+
+jsonFixityDirection :: FixityDirection -> JsonDoc
+jsonFixityDirection InfixL = jsonString "infixl"
+jsonFixityDirection InfixR = jsonString "infixr"
+jsonFixityDirection InfixN = jsonString "infix"
+
+renderJson :: JsonDoc -> SDoc
+renderJson = renderJSON
+
+jsonMaybe :: (a -> JsonDoc) -> Maybe a -> JsonDoc
+jsonMaybe = maybe jsonNull
+
+jsonString :: String -> JsonDoc
+jsonString = JSString
+
+jsonObject :: [(String, JsonDoc)] -> JsonDoc
+jsonObject = JSObject
+
+jsonArray :: [JsonDoc] -> JsonDoc
+jsonArray = JSArray
+
+jsonNull :: JsonDoc
+jsonNull = JSNull
+
+jsonInt :: Int -> JsonDoc
+jsonInt = JSInt
+
+jsonBool :: Bool -> JsonDoc
+jsonBool = JSBool
diff --git a/utils/haddock/haddock-api/src/Haddock/Interface/LexParseRn.hs b/utils/haddock/haddock-api/src/Haddock/Interface/LexParseRn.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a366cbfcc9fe09f84f40c8a1e73d6bfcc0b3b9d6
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Interface/LexParseRn.hs
@@ -0,0 +1,286 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE ViewPatterns #-}
+{-# OPTIONS_GHC -Wwarn #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Interface.LexParseRn
+-- Copyright   :  (c) Isaac Dupree 2009,
+--                    Mateusz Kowalczyk 2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Interface.LexParseRn
+  ( processDocString
+  , processDocStringParas
+  , processDocStringsParas
+  , processModuleHeader
+  ) where
+
+import Control.Arrow
+import Control.Monad
+import Control.Monad.State.Strict
+import Data.Functor
+import Data.List (maximumBy, (\\))
+import Data.Ord
+import qualified Data.Set as Set
+import GHC
+import GHC.Data.EnumSet as EnumSet
+import GHC.Data.FastString (unpackFS)
+import GHC.Driver.Ppr (showPpr, showSDoc)
+import GHC.Driver.Session
+import qualified GHC.LanguageExtensions as LangExt
+import GHC.Parser.PostProcess
+import GHC.Types.Avail
+import GHC.Types.Name
+import GHC.Types.Name.Reader
+import GHC.Types.Name.Set
+import GHC.Utils.Misc ((<||>))
+import GHC.Utils.Outputable (Outputable)
+import Haddock.Interface.ParseModuleHeader
+import Haddock.Parser
+import Haddock.Types
+
+processDocStringsParas
+  :: MonadIO m
+  => DynFlags
+  -> Maybe Package
+  -> [HsDoc GhcRn]
+  -> IfM m (MDoc Name)
+processDocStringsParas dflags pkg hdss =
+  overDocF (rename dflags $ hsDocRenamer hds) $ parseParas dflags pkg (renderHsDocStrings $ hsDocString hds)
+  where
+    hds :: WithHsDocIdentifiers [HsDocString] GhcRn
+    hds = WithHsDocIdentifiers (map hsDocString hdss) (concatMap hsDocIdentifiers hdss)
+
+processDocStringParas
+  :: MonadIO m
+  => DynFlags
+  -> Maybe Package
+  -> (HsDoc GhcRn)
+  -> IfM m (MDoc Name)
+processDocStringParas dflags pkg hds =
+  overDocF (rename dflags $ hsDocRenamer hds) $ parseParas dflags pkg (renderHsDocString $ hsDocString hds)
+
+processDocString
+  :: MonadIO m
+  => DynFlags
+  -> (HsDoc GhcRn)
+  -> IfM m (Doc Name)
+processDocString dflags hds =
+  rename dflags (hsDocRenamer hds) $ parseString dflags (renderHsDocString $ hsDocString hds)
+
+processModuleHeader
+  :: MonadIO m
+  => DynFlags
+  -> Maybe Package
+  -> SafeHaskellMode
+  -> Maybe Language
+  -> EnumSet LangExt.Extension
+  -> Maybe (HsDoc GhcRn)
+  -> IfM m (HaddockModInfo Name, Maybe (MDoc Name))
+processModuleHeader dflags pkgName safety mayLang extSet mayStr = do
+  (hmi, doc) <-
+    case mayStr of
+      Nothing -> return failure
+      Just hsDoc -> do
+        let str = renderHsDocString $ hsDocString hsDoc
+            (hmi, doc) = parseModuleHeader dflags pkgName str
+            renamer = hsDocRenamer hsDoc
+        !descr <- case hmi_description hmi of
+          Just hmi_descr -> Just <$> rename dflags renamer hmi_descr
+          Nothing -> pure Nothing
+        let hmi' = hmi{hmi_description = descr}
+        doc' <- overDocF (rename dflags renamer) doc
+        return (hmi', Just doc')
+
+  let flags :: [LangExt.Extension]
+      -- We remove the flags implied by the language setting and we display the language instead
+      flags = EnumSet.toList extSet \\ languageExtensions mayLang
+  return
+    ( hmi
+        { hmi_safety = Just $ showPpr dflags safety
+        , hmi_language = language dflags
+        , hmi_extensions = flags
+        }
+    , doc
+    )
+  where
+    failure = (emptyHaddockModInfo, Nothing)
+
+traverseSnd :: (Traversable t, Applicative f) => (a -> f b) -> t (x, a) -> f (t (x, b))
+traverseSnd f =
+  traverse
+    ( \(x, a) ->
+        (\b -> (x, b)) <$> f a
+    )
+
+-- | Takes a 'GlobalRdrEnv' which (hopefully) contains all the
+-- definitions and a parsed comment and we attempt to make sense of
+-- where the identifiers in the comment point to. We're in effect
+-- trying to convert 'RdrName's to 'Name's, with some guesswork and
+-- fallbacks in case we can't locate the identifiers.
+--
+-- See the comments in the source for implementation commentary.
+rename
+  :: MonadIO m
+  => DynFlags
+  -> Renamer
+  -> Doc NsRdrName
+  -> IfM m (Doc Name)
+rename dflags renamer = rn
+  where
+    rn :: MonadIO m => Doc NsRdrName -> IfM m (Doc Name)
+    rn d = case d of
+      DocAppend a b -> DocAppend <$> rn a <*> rn b
+      DocParagraph p -> DocParagraph <$> rn p
+      DocIdentifier i -> do
+        let NsRdrName ns x = unwrap i
+            occ = rdrNameOcc x
+        let valueNsChoices
+              | isDataOcc occ = isDataConNameSpace
+              | otherwise = isTermVarOrFieldNameSpace
+            typeNsChoices
+              | isDataOcc occ = isTcClsNameSpace
+              | otherwise = isTvNameSpace
+        -- Generate the choices for the possible kind of thing this
+        -- is. We narrow down the possibilities with the namespace (if
+        -- there is one).
+        let choices = case ns of
+              Value -> valueNsChoices
+              Type -> typeNsChoices
+              None -> valueNsChoices <||> typeNsChoices
+        case renamer (showPpr dflags x) choices of
+          [] -> case ns of
+            Type -> outOfScope dflags ns (i $> setRdrNameSpace x tcName)
+            _ -> outOfScope dflags ns (i $> x)
+          [a] -> pure (DocIdentifier $ i $> a)
+          -- There are multiple names available.
+          names -> ambiguous dflags i names
+      DocWarning dw -> DocWarning <$> rn dw
+      DocEmphasis de -> DocEmphasis <$> rn de
+      DocBold db -> DocBold <$> rn db
+      DocMonospaced dm -> DocMonospaced <$> rn dm
+      DocUnorderedList docs -> DocUnorderedList <$> traverse rn docs
+      DocOrderedList docs -> DocOrderedList <$> traverseSnd rn docs
+      DocDefList list -> DocDefList <$> traverse (\(a, b) -> (,) <$> rn a <*> rn b) list
+      DocCodeBlock dcb -> DocCodeBlock <$> rn dcb
+      DocIdentifierUnchecked x -> pure (DocIdentifierUnchecked x)
+      DocModule (ModLink m l) -> DocModule . ModLink m <$> traverse rn l
+      DocHyperlink (Hyperlink u l) -> DocHyperlink . Hyperlink u <$> traverse rn l
+      DocPic str -> pure (DocPic str)
+      DocMathInline str -> pure (DocMathInline str)
+      DocMathDisplay str -> pure (DocMathDisplay str)
+      DocAName str -> pure (DocAName str)
+      DocProperty p -> pure (DocProperty p)
+      DocExamples e -> pure (DocExamples e)
+      DocEmpty -> pure (DocEmpty)
+      DocString str -> pure (DocString str)
+      DocHeader (Header l t) -> DocHeader . Header l <$> rn t
+      DocTable t -> DocTable <$> traverse rn t
+
+-- | Wrap an identifier that's out of scope (i.e. wasn't found in
+-- 'GlobalReaderEnv' during 'rename') in an appropriate doc. Currently
+-- we simply monospace the identifier in most cases except when the
+-- identifier is qualified: if the identifier is qualified then we can
+-- still try to guess and generate anchors accross modules but the
+-- users shouldn't rely on this doing the right thing. See tickets
+-- #253 and #375 on the confusion this causes depending on which
+-- default we pick in 'rename'.
+outOfScope :: MonadIO m => DynFlags -> Namespace -> Wrap RdrName -> IfM m (Doc a)
+outOfScope dflags ns x =
+  case unwrap x of
+    Unqual occ -> warnAndMonospace (x $> occ)
+    Qual mdl occ -> pure (DocIdentifierUnchecked (x $> (mdl, occ)))
+    Orig _ occ -> warnAndMonospace (x $> occ)
+    Exact name -> warnAndMonospace (x $> name) -- Shouldn't happen since x is out of scope
+  where
+    prefix =
+      case ns of
+        Value -> "the value "
+        Type -> "the type "
+        None -> ""
+
+    warnAndMonospace :: (MonadIO m, Outputable a) => Wrap a -> IfM m (DocH mod id)
+    warnAndMonospace a = do
+      let a' = showWrapped (showPpr dflags) a
+
+      -- If we have already warned for this identifier, don't warn again
+      firstWarn <- Set.notMember a' <$> gets ifeOutOfScopeNames
+      when firstWarn $ do
+        warn $
+          "Warning: "
+            ++ prefix
+            ++ "'"
+            ++ a'
+            ++ "' is out of scope.\n"
+            ++ "    If you qualify the identifier, haddock can try to link it anyway."
+        modify' (\env -> env{ifeOutOfScopeNames = Set.insert a' (ifeOutOfScopeNames env)})
+
+      pure (monospaced a')
+    monospaced = DocMonospaced . DocString
+
+-- | Handle ambiguous identifiers.
+--
+-- Prefers local names primarily and type constructors or class names secondarily.
+--
+-- Emits a warning if the 'GlobalRdrElts's don't belong to the same type or class.
+ambiguous
+  :: MonadIO m
+  => DynFlags
+  -> Wrap NsRdrName
+  -> [Name]
+  -- ^ More than one @gre@s sharing the same `RdrName` above.
+  -> IfM m (Doc Name)
+ambiguous dflags x names = do
+  let noChildren = map availName (nubAvails (map Avail names))
+      dflt = maximumBy (comparing (isLocalName &&& isTyConName)) noChildren
+      nameStr = showNsRdrName dflags x
+      msg =
+        "Warning: "
+          ++ nameStr
+          ++ " is ambiguous. It is defined\n"
+          ++ concatMap (\n -> "    * " ++ defnLoc n ++ "\n") names
+          ++ "    You may be able to disambiguate the identifier by qualifying it or\n"
+          ++ "    by specifying the type/value namespace explicitly.\n"
+          ++ "    Defaulting to the one defined "
+          ++ defnLoc dflt
+
+  -- TODO: Once we have a syntax for namespace qualification (#667) we may also
+  -- want to emit a warning when an identifier is a data constructor for a type
+  -- of the same name, but not the only constructor.
+  -- For example, for @data D = C | D@, someone may want to reference the @D@
+  -- constructor.
+
+  -- If we have already warned for this name, do not warn again
+  firstWarn <- Set.notMember nameStr <$> gets ifeAmbiguousNames
+  when (length noChildren > 1 && firstWarn) $ do
+    warn msg
+    modify' (\env -> env{ifeAmbiguousNames = Set.insert nameStr (ifeAmbiguousNames env)})
+
+  pure (DocIdentifier (x $> dflt))
+  where
+    isLocalName (nameSrcLoc -> RealSrcLoc{}) = True
+    isLocalName _ = False
+    defnLoc = showSDoc dflags . pprNameDefnLoc
+
+-- | Printable representation of a wrapped and namespaced name
+showNsRdrName :: DynFlags -> Wrap NsRdrName -> String
+showNsRdrName dflags = (\p i -> p ++ "'" ++ i ++ "'") <$> prefix <*> ident
+  where
+    ident = showWrapped (showPpr dflags . rdrName)
+    prefix = renderNs . namespace . unwrap
+
+hsDocRenamer :: WithHsDocIdentifiers a GhcRn -> Renamer
+hsDocRenamer hsDoc = \s cands -> nameSetElemsStable $ filterNameSet (nameMatches s cands) env
+  where
+    !env = hsDocIds hsDoc
+    nameMatches s ok_ns n =
+      let occ = occName n
+       in ok_ns (occNameSpace occ) && s == unpackFS (occNameFS occ)
diff --git a/utils/haddock/haddock-api/src/Haddock/Interface/ParseModuleHeader.hs b/utils/haddock/haddock-api/src/Haddock/Interface/ParseModuleHeader.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8b96408aae8e81433df8128a6340c0945087d2b0
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Interface/ParseModuleHeader.hs
@@ -0,0 +1,195 @@
+{-# LANGUAGE DeriveFunctor #-}
+{-# OPTIONS_GHC -Wwarn #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Interface.ParseModuleHeader
+-- Copyright   :  (c) Simon Marlow 2006, Isaac Dupree 2009
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Interface.ParseModuleHeader (parseModuleHeader) where
+
+import Control.Applicative (Alternative (..))
+import Control.Monad (ap)
+import Data.Char
+import GHC.Driver.Session
+import Haddock.Parser
+import Haddock.Types
+
+-- -----------------------------------------------------------------------------
+-- Parsing module headers
+
+-- NB.  The headers must be given in the order Module, Description,
+-- Copyright, License, Maintainer, Stability, Portability, except that
+-- any or all may be omitted.
+parseModuleHeader :: DynFlags -> Maybe Package -> String -> (HaddockModInfo NsRdrName, MDoc NsRdrName)
+parseModuleHeader dflags pkgName str0 =
+  let
+    kvs :: [(String, String)]
+    str1 :: String
+
+    (kvs, str1) = maybe ([], str0) id $ runP fields str0
+
+    -- trim whitespaces
+    trim :: String -> String
+    trim = dropWhile isSpace . reverse . dropWhile isSpace . reverse
+
+    getKey :: String -> Maybe String
+    getKey key = fmap trim (lookup key kvs)
+
+    descriptionOpt = getKey "Description"
+    copyrightOpt = getKey "Copyright"
+    licenseOpt = getKey "License"
+    licenceOpt = getKey "Licence"
+    spdxLicenceOpt = getKey "SPDX-License-Identifier"
+    maintainerOpt = getKey "Maintainer"
+    stabilityOpt = getKey "Stability"
+    portabilityOpt = getKey "Portability"
+   in
+    ( HaddockModInfo
+        { hmi_description = parseString dflags <$> descriptionOpt
+        , hmi_copyright = copyrightOpt
+        , hmi_license = spdxLicenceOpt <|> licenseOpt <|> licenceOpt
+        , hmi_maintainer = maintainerOpt
+        , hmi_stability = stabilityOpt
+        , hmi_portability = portabilityOpt
+        , hmi_safety = Nothing
+        , hmi_language = Nothing -- set in LexParseRn
+        , hmi_extensions = [] -- also set in LexParseRn
+        }
+    , parseParas dflags pkgName str1
+    )
+
+-------------------------------------------------------------------------------
+-- Small parser to parse module header.
+-------------------------------------------------------------------------------
+
+-- | The below is a small parser framework how we read keys.
+--
+-- all fields in the header are optional and have the form
+--
+-- [spaces1][field name][spaces] ":"
+--    [text]"\n" ([spaces2][space][text]"\n" | [spaces]"\n")*
+-- where each [spaces2] should have [spaces1] as a prefix.
+--
+-- Thus for the key "Description",
+--
+-- > Description : this is a
+-- >    rather long
+-- >
+-- >    description
+-- >
+-- > The module comment starts here
+--
+-- the value will be "this is a .. description" and the rest will begin
+-- at "The module comment".
+
+-- | 'C' is a 'Char' carrying its column.
+--
+-- This let us make an indentation-aware parser, as we know current indentation.
+-- by looking at the next character in the stream ('curInd').
+--
+-- Thus we can munch all spaces but only not-spaces which are indented.
+data C = C {-# UNPACK #-} !Int Char
+
+newtype P a = P {unP :: [C] -> Maybe ([C], a)}
+  deriving (Functor)
+
+instance Applicative P where
+  pure x = P $ \s -> Just (s, x)
+  (<*>) = ap
+
+instance Monad P where
+  return = pure
+  m >>= k = P $ \s0 -> do
+    (s1, x) <- unP m s0
+    unP (k x) s1
+
+instance Alternative P where
+  empty = P $ \_ -> Nothing
+  a <|> b = P $ \s -> unP a s <|> unP b s
+
+runP :: P a -> String -> Maybe a
+runP p input = fmap snd (unP p input')
+  where
+    input' =
+      concat
+        [ zipWith C [0 ..] l ++ [C (length l) '\n']
+        | l <- lines input
+        ]
+
+-------------------------------------------------------------------------------
+--
+-------------------------------------------------------------------------------
+
+curInd :: P Int
+curInd = P $ \s -> Just . (,) s $ case s of
+  [] -> 0
+  C i _ : _ -> i
+
+rest :: P String
+rest = P $ \cs -> Just ([], [c | C _ c <- cs])
+
+munch :: (Int -> Char -> Bool) -> P String
+munch p = P $ \cs ->
+  let (xs, ys) = takeWhileMaybe p' cs in Just (ys, xs)
+  where
+    p' (C i c)
+      | p i c = Just c
+      | otherwise = Nothing
+
+munch1 :: (Int -> Char -> Bool) -> P String
+munch1 p = P $ \s -> case s of
+  [] -> Nothing
+  (c : cs)
+    | Just c' <- p' c -> let (xs, ys) = takeWhileMaybe p' cs in Just (ys, c' : xs)
+    | otherwise -> Nothing
+  where
+    p' (C i c)
+      | p i c = Just c
+      | otherwise = Nothing
+
+char :: Char -> P Char
+char c = P $ \s -> case s of
+  [] -> Nothing
+  (C _ c' : cs)
+    | c == c' -> Just (cs, c)
+    | otherwise -> Nothing
+
+skipSpaces :: P ()
+skipSpaces = P $ \cs -> Just (dropWhile (\(C _ c) -> isSpace c) cs, ())
+
+takeWhileMaybe :: (a -> Maybe b) -> [a] -> ([b], [a])
+takeWhileMaybe f = go
+  where
+    go xs0@[] = ([], xs0)
+    go xs0@(x : xs) = case f x of
+      Just y -> let (ys, zs) = go xs in (y : ys, zs)
+      Nothing -> ([], xs0)
+
+-------------------------------------------------------------------------------
+-- Fields
+-------------------------------------------------------------------------------
+
+field :: Int -> P (String, String)
+field i = do
+  fn <- munch1 $ \_ c -> isAlpha c || c == '-'
+  skipSpaces
+  _ <- char ':'
+  skipSpaces
+  val <- munch $ \j c -> isSpace c || j > i
+  return (fn, val)
+
+fields :: P ([(String, String)], String)
+fields = do
+  skipSpaces
+  i <- curInd
+  fs <- many (field i)
+  r <- rest
+  return (fs, r)
diff --git a/utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs b/utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
new file mode 100644
index 0000000000000000000000000000000000000000..f0677995d911990983b2206200387c83cada1583
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
@@ -0,0 +1,953 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE DerivingStrategies #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE TypeFamilies #-}
+
+----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Interface.Rename
+-- Copyright   :  (c) Simon Marlow 2003-2006,
+--                    David Waern  2006-2009
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Interface.Rename (renameInterface) where
+
+import Data.Traversable (mapM)
+
+import Haddock.Backends.Hoogle (ppExportD)
+import Haddock.GhcUtils
+import Haddock.Types
+
+import GHC hiding (NoLink)
+import GHC.Builtin.Types (eqTyCon_RDR, tupleDataConName, tupleTyConName)
+import GHC.Data.Bag (emptyBag)
+import GHC.Types.Name
+import GHC.Types.Name.Reader (RdrName (Exact))
+
+import Control.Applicative
+import Control.DeepSeq (force)
+import Control.Monad hiding (mapM)
+import Control.Monad.Reader
+import Control.Monad.Writer.CPS
+import Data.Foldable (traverse_)
+import qualified Data.Map.Strict as Map
+import qualified Data.Set as Set
+import GHC.Types.Basic (Boxity (..), TopLevelFlag (..), TupleSort (..))
+import Prelude hiding (mapM)
+
+-- | Traverse docstrings and ASTs in the Haddock interface, renaming 'Name' to
+-- 'DocName'.
+--
+-- What this really boils down to is: for each 'Name', figure out which of the
+-- modules that export the name is the preferred place to link to.
+--
+-- The renamed output gets written into fields in the Haddock interface record
+-- that were previously left empty.
+renameInterface
+  :: DynFlags
+  -- ^ GHC session dyn flags
+  -> Map.Map (Maybe String) (Set.Set String)
+  -- ^ Ignored symbols. A map from module names to unqualified names. Module
+  -- 'Just M' mapping to name 'f' means that link warnings should not be
+  -- generated for occurances of specifically 'M.f'. Module 'Nothing' mapping to
+  -- name 'f' means that link warnings should not be generated for any 'f'.
+  -> LinkEnv
+  -- ^ Link environment. A map from 'Name' to 'Module', where name 'n' maps to
+  -- module 'M' if 'M' is the preferred link destination for name 'n'.
+  -> Bool
+  -- ^ Are warnings enabled?
+  -> Bool
+  -- ^ Is Hoogle output enabled?
+  -> Interface
+  -- ^ The interface we are renaming.
+  -> Ghc Interface
+  -- ^ The renamed interface. Note that there is nothing really special about
+  -- this being in the 'Ghc' monad. This could very easily be any 'MonadIO' or
+  -- even pure, depending on the link warnings are reported.
+renameInterface dflags ignoreSet renamingEnv warnings hoogle iface = do
+  let (iface', warnedNames) =
+        runRnM
+          dflags
+          mdl
+          localLinkEnv
+          warnName
+          (hoogle && not (OptHide `elem` ifaceOptions iface))
+          (renameInterfaceRn iface)
+  reportMissingLinks mdl warnedNames
+  return iface'
+  where
+    -- The current module
+    mdl :: Module
+    mdl = ifaceMod iface
+
+    -- The local link environment, where every name exported by this module is
+    -- mapped to the module itself, and everything else comes from the global
+    -- renaming env
+    localLinkEnv :: LinkEnv
+    localLinkEnv = foldr f renamingEnv (ifaceVisibleExports iface)
+      where
+        f name !env = Map.insert name mdl env
+
+    -- The function used to determine whether we should warn about a name
+    -- which we do not find in the renaming environment
+    warnName name =
+      -- Warnings must be enabled
+      warnings
+        -- Current module must not be hidden from Haddock
+        && not (OptHide `elem` ifaceOptions iface)
+        -- Must be an external name that is not built-in syntax, not a type
+        -- variable, and not '~'
+        && isExternalName name
+        && not (isBuiltInSyntax name)
+        && not (isTyVarName name)
+        && Exact name /= eqTyCon_RDR
+        -- Must not be in the set of ignored symbols for the module or the
+        -- unqualified ignored symbols
+        && not (getOccString name `Set.member` ignoreSet')
+      where
+        -- The set of ignored symbols within the module this name is located
+        -- in unioned with the set of globally ignored symbols
+        ignoreSet' :: Set.Set String
+        ignoreSet' =
+          Set.union
+            (Map.findWithDefault Set.empty (Just $ modString name) ignoreSet)
+            (Map.findWithDefault Set.empty Nothing ignoreSet)
+
+        modString :: Name -> String
+        modString = moduleString . nameModule
+
+-- | Output warning messages indicating that the renamer could not find link
+-- destinations for the names in the given set as they occur in the given
+-- module.
+reportMissingLinks :: Module -> Set.Set Name -> Ghc ()
+reportMissingLinks mdl names
+  | Set.null names = return ()
+  | otherwise =
+      liftIO $ do
+        putStrLn $ "Warning: " ++ moduleString mdl ++ ": could not find link destinations for: "
+        traverse_ (putStrLn . ("\t- " ++) . qualifiedName) names
+  where
+    qualifiedName :: Name -> String
+    qualifiedName name = moduleString (nameModule name) ++ "." ++ getOccString name
+
+--------------------------------------------------------------------------------
+-- Monad for renaming
+--------------------------------------------------------------------------------
+
+-- | A renaming monad which provides 'MonadReader' access to a renaming
+-- environment, and 'MonadWriter' access to a 'Set' of names for which link
+-- warnings should be generated, based on the renaming environment.
+newtype RnM a = RnM {unRnM :: ReaderT RnMEnv (Writer (Set.Set Name)) a}
+  deriving newtype (Functor, Applicative, Monad, MonadReader RnMEnv, MonadWriter (Set.Set Name))
+
+-- | The renaming monad environment. Stores the linking environment (mapping
+-- names to modules), the link warning predicate, and the current module.
+data RnMEnv = RnMEnv
+  { rnLinkEnv :: LinkEnv
+  -- ^ The linking environment (map from names to modules)
+  , rnWarnName :: (Name -> Bool)
+  -- ^ Link warning predicate (whether failing to find a link destination
+  -- for a given name should result in a warning)
+  , rnModuleString :: String
+  -- ^ The current module
+  , rnHoogleOutput :: Bool
+  -- ^ Should Hoogle output be generated for this module?
+  , rnDynFlags :: DynFlags
+  -- ^ GHC Session DynFlags, necessary for Hoogle output generation
+  }
+
+-- | Run the renamer action in a renaming environment built using the given
+-- module, link env, and link warning predicate. Returns the renamed value along
+-- with a set of 'Name's that were not renamed and should be warned for (i.e.
+-- they satisfied the link warning predicate).
+runRnM :: DynFlags -> Module -> LinkEnv -> (Name -> Bool) -> Bool -> RnM a -> (a, Set.Set Name)
+runRnM dflags mdl linkEnv warnName hoogleOutput rn =
+  runWriter $ runReaderT (unRnM rn) rnEnv
+  where
+    rnEnv :: RnMEnv
+    rnEnv =
+      RnMEnv
+        { rnLinkEnv = linkEnv
+        , rnWarnName = warnName
+        , rnModuleString = moduleString mdl
+        , rnHoogleOutput = hoogleOutput
+        , rnDynFlags = dflags
+        }
+
+--------------------------------------------------------------------------------
+-- Renaming
+--------------------------------------------------------------------------------
+
+-- | Rename an `Interface` in the renaming environment.
+renameInterfaceRn :: Interface -> RnM Interface
+renameInterfaceRn iface = do
+  exportItems <- renameExportItems (ifaceExportItems iface)
+  orphans <- mapM renameDocInstance (ifaceOrphanInstances iface)
+  finalModDoc <- renameDocumentation (ifaceDoc iface)
+  pure $!
+    iface
+      { ifaceRnDoc = finalModDoc
+      , -- The un-renamed export items are not used after renaming
+        ifaceRnExportItems = exportItems
+      , ifaceExportItems = []
+      , -- The un-renamed orphan instances are not used after renaming
+        ifaceRnOrphanInstances = orphans
+      , ifaceOrphanInstances = []
+      }
+
+-- | Lookup a 'Name' in the renaming environment.
+lookupRn :: Name -> RnM DocName
+lookupRn name = RnM $ do
+  linkEnv <- asks rnLinkEnv
+  case Map.lookup name linkEnv of
+    Nothing -> return $ Undocumented name
+    Just mdl -> return $ Documented name mdl
+
+-- | Rename a 'Name' in the renaming environment. This is very similar to
+-- 'lookupRn', but tracks any names not found in the renaming environment if the
+-- `rnWarnName` predicate is true.
+renameName :: Name -> RnM DocName
+renameName name = do
+  warnName <- asks rnWarnName
+  docName <- lookupRn name
+  case docName of
+    Undocumented _ -> do
+      when (warnName name) $
+        tell $
+          Set.singleton name
+      return docName
+    _ -> return docName
+
+-- | Rename a located 'Name' in the current renaming environment.
+renameNameL :: GenLocated l Name -> RnM (GenLocated l DocName)
+renameNameL = mapM renameName
+
+-- | Rename a list of export items in the current renaming environment.
+renameExportItems :: [ExportItem GhcRn] -> RnM [ExportItem DocNameI]
+renameExportItems = mapM renameExportItem
+
+-- | Rename an 'ExportItem' in the current renaming environment.
+renameExportItem :: ExportItem GhcRn -> RnM (ExportItem DocNameI)
+renameExportItem item = case item of
+  ExportModule mdl -> return (ExportModule mdl)
+  ExportGroup lev id_ doc -> do
+    doc' <- renameDoc doc
+    return (ExportGroup lev id_ doc')
+  ExportDecl ed@(ExportD decl pats doc subs instances fixities splice) -> do
+    -- If Hoogle output should be generated, generate it
+    RnMEnv{..} <- ask
+    let !hoogleOut =
+          force $
+            if rnHoogleOutput
+              then ppExportD rnDynFlags ed
+              else []
+
+    decl' <- renameLDecl decl
+    pats' <- renamePats pats
+    doc' <- renameDocForDecl doc
+    subs' <- mapM renameSub subs
+    instances' <- forM instances renameDocInstance
+    fixities' <- forM fixities $ \(name, fixity) -> do
+      name' <- lookupRn name
+      return (name', fixity)
+
+    return $
+      ExportDecl
+        RnExportD
+          { rnExpDExpD = ExportD decl' pats' doc' subs' instances' fixities' splice
+          , rnExpDHoogle = hoogleOut
+          }
+  ExportNoDecl x subs -> do
+    x' <- lookupRn x
+    subs' <- mapM lookupRn subs
+    return (ExportNoDecl x' subs')
+  ExportDoc doc -> do
+    doc' <- renameDoc doc
+    return (ExportDoc doc')
+
+renameDocForDecl :: DocForDecl Name -> RnM (DocForDecl DocName)
+renameDocForDecl (doc, fnArgsDoc) =
+  (,) <$> renameDocumentation doc <*> renameFnArgsDoc fnArgsDoc
+
+renameDocumentation :: Documentation Name -> RnM (Documentation DocName)
+renameDocumentation (Documentation mDoc mWarning) =
+  Documentation <$> mapM renameDoc mDoc <*> mapM renameDoc mWarning
+
+renameLDocHsSyn :: Located (WithHsDocIdentifiers HsDocString a) -> RnM (Located (WithHsDocIdentifiers HsDocString b))
+renameLDocHsSyn (L l doc) = return (L l (WithHsDocIdentifiers (hsDocString doc) []))
+
+renameDoc :: Traversable t => t (Wrap Name) -> RnM (t (Wrap DocName))
+renameDoc = traverse (traverse renameName)
+
+renameFnArgsDoc :: FnArgsDoc Name -> RnM (FnArgsDoc DocName)
+renameFnArgsDoc = mapM renameDoc
+
+renameLType :: LHsType GhcRn -> RnM (LHsType DocNameI)
+renameLType = mapM renameType
+
+renameLTypeArg :: LHsTypeArg GhcRn -> RnM (LHsTypeArg DocNameI)
+renameLTypeArg (HsValArg _ ty) = do
+  ty' <- renameLType ty
+  return $ HsValArg noExtField ty'
+renameLTypeArg (HsTypeArg _ ki) = do
+  ki' <- renameLKind ki
+  return $ HsTypeArg noExtField ki'
+renameLTypeArg (HsArgPar _) = return $ HsArgPar noExtField
+
+renameLSigType :: LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
+renameLSigType = mapM renameSigType
+
+renameLSigWcType :: LHsSigWcType GhcRn -> RnM (LHsSigWcType DocNameI)
+renameLSigWcType = renameWc renameLSigType
+
+renameLKind :: LHsKind GhcRn -> RnM (LHsKind DocNameI)
+renameLKind = renameLType
+
+renameMaybeLKind :: Maybe (LHsKind GhcRn) -> RnM (Maybe (LHsKind DocNameI))
+renameMaybeLKind = traverse renameLKind
+
+renameFamilyResultSig :: LFamilyResultSig GhcRn -> RnM (LFamilyResultSig DocNameI)
+renameFamilyResultSig (L loc (NoSig _)) =
+  return (L loc (NoSig noExtField))
+renameFamilyResultSig (L loc (KindSig _ ki)) =
+  do
+    ki' <- renameLKind ki
+    return (L loc (KindSig noExtField ki'))
+renameFamilyResultSig (L loc (TyVarSig _ bndr)) =
+  do
+    bndr' <- renameLTyVarBndr return bndr
+    return (L loc (TyVarSig noExtField bndr'))
+
+renameInjectivityAnn :: LInjectivityAnn GhcRn -> RnM (LInjectivityAnn DocNameI)
+renameInjectivityAnn (L loc (InjectivityAnn _ lhs rhs)) =
+  do
+    lhs' <- renameNameL lhs
+    rhs' <- mapM renameNameL rhs
+    return (L loc (InjectivityAnn noExtField lhs' rhs'))
+
+renameMaybeInjectivityAnn
+  :: Maybe (LInjectivityAnn GhcRn)
+  -> RnM (Maybe (LInjectivityAnn DocNameI))
+renameMaybeInjectivityAnn = traverse renameInjectivityAnn
+
+renameArrow :: HsArrow GhcRn -> RnM (HsArrow DocNameI)
+renameArrow (HsUnrestrictedArrow _) = return (HsUnrestrictedArrow noExtField)
+renameArrow (HsLinearArrow _) = return (HsLinearArrow noExtField)
+renameArrow (HsExplicitMult _ p) = HsExplicitMult noExtField <$> renameLType p
+
+renameType :: HsType GhcRn -> RnM (HsType DocNameI)
+renameType t = case t of
+  HsForAllTy{hst_tele = tele, hst_body = ltype} -> do
+    tele' <- renameHsForAllTelescope tele
+    ltype' <- renameLType ltype
+    return
+      ( HsForAllTy
+          { hst_xforall = noAnn
+          , hst_tele = tele'
+          , hst_body = ltype'
+          }
+      )
+  HsQualTy{hst_ctxt = lcontext, hst_body = ltype} -> do
+    lcontext' <- renameLContext lcontext
+    ltype' <- renameLType ltype
+    return (HsQualTy{hst_xqual = noAnn, hst_ctxt = lcontext', hst_body = ltype'})
+  HsTyVar _ ip (L l n) -> return . HsTyVar noAnn ip . L l =<< renameName n
+  HsBangTy _ b ltype -> return . HsBangTy noAnn b =<< renameLType ltype
+  HsStarTy _ isUni -> return (HsStarTy noAnn isUni)
+  HsAppTy _ a b -> do
+    a' <- renameLType a
+    b' <- renameLType b
+    return (HsAppTy noAnn a' b')
+  HsAppKindTy _ a b -> do
+    a' <- renameLType a
+    b' <- renameLKind b
+    return (HsAppKindTy noAnn a' b')
+  HsFunTy _ w a b -> do
+    a' <- renameLType a
+    b' <- renameLType b
+    w' <- renameArrow w
+    return (HsFunTy noAnn w' a' b')
+  HsListTy _ ty -> return . (HsListTy noAnn) =<< renameLType ty
+  HsIParamTy _ n ty -> liftM (HsIParamTy noAnn n) (renameLType ty)
+  -- Special-case unary boxed tuples so that they are pretty-printed as
+  -- `Solo x`, not `(x)`
+  HsTupleTy _ HsBoxedOrConstraintTuple [ty] -> do
+    name <- renameName (tupleTyConName BoxedTuple 1)
+    let lhs = noLocA $ HsTyVar noAnn NotPromoted (noLocA name)
+    rhs <- renameLType ty
+    return (HsAppTy noAnn lhs rhs)
+  HsTupleTy _ b ts -> return . HsTupleTy noAnn b =<< mapM renameLType ts
+  HsSumTy _ ts -> HsSumTy noAnn <$> mapM renameLType ts
+  HsOpTy _ prom a (L loc op) b -> do
+    op' <- renameName op
+    a' <- renameLType a
+    b' <- renameLType b
+    return (HsOpTy noAnn prom a' (L loc op') b')
+  HsParTy _ ty -> return . (HsParTy noAnn) =<< renameLType ty
+  HsKindSig _ ty k -> do
+    ty' <- renameLType ty
+    k' <- renameLKind k
+    return (HsKindSig noAnn ty' k')
+  HsDocTy _ ty doc -> do
+    ty' <- renameLType ty
+    doc' <- renameLDocHsSyn doc
+    return (HsDocTy noAnn ty' doc')
+  HsTyLit _ x -> return (HsTyLit noAnn (renameTyLit x))
+  HsRecTy _ a -> HsRecTy noAnn <$> mapM renameConDeclFieldField a
+  XHsType a -> pure (XHsType a)
+  HsExplicitListTy _ a b -> HsExplicitListTy noAnn a <$> mapM renameLType b
+  -- Special-case unary boxed tuples so that they are pretty-printed as
+  -- `'MkSolo x`, not `'(x)`
+  HsExplicitTupleTy _ [ty] -> do
+    name <- renameName (tupleDataConName Boxed 1)
+    let lhs = noLocA $ HsTyVar noAnn IsPromoted (noLocA name)
+    rhs <- renameLType ty
+    return (HsAppTy noAnn lhs rhs)
+  HsExplicitTupleTy _ b -> HsExplicitTupleTy noAnn <$> mapM renameLType b
+  HsSpliceTy (HsUntypedSpliceTop _ st) _ -> renameType (unLoc st)
+  HsSpliceTy (HsUntypedSpliceNested _) _ -> error "renameType: not an top level type splice"
+  HsWildCardTy _ -> pure (HsWildCardTy noAnn)
+
+renameTyLit :: HsTyLit GhcRn -> HsTyLit DocNameI
+renameTyLit t = case t of
+  HsNumTy _ v -> HsNumTy noExtField v
+  HsStrTy _ v -> HsStrTy noExtField v
+  HsCharTy _ v -> HsCharTy noExtField v
+
+renameSigType :: HsSigType GhcRn -> RnM (HsSigType DocNameI)
+renameSigType (HsSig{sig_bndrs = bndrs, sig_body = body}) = do
+  bndrs' <- renameOuterTyVarBndrs bndrs
+  body' <- renameLType body
+  pure $ HsSig{sig_ext = noExtField, sig_bndrs = bndrs', sig_body = body'}
+
+renameLHsQTyVars :: LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
+renameLHsQTyVars (HsQTvs{hsq_explicit = tvs}) =
+  do
+    tvs' <- mapM (renameLTyVarBndr renameHsBndrVis) tvs
+    return
+      ( HsQTvs
+          { hsq_ext = noExtField
+          , hsq_explicit = tvs'
+          }
+      )
+
+renameHsBndrVis :: HsBndrVis GhcRn -> RnM (HsBndrVis DocNameI)
+renameHsBndrVis (HsBndrRequired _) = return (HsBndrRequired noExtField)
+renameHsBndrVis (HsBndrInvisible at) = return (HsBndrInvisible at)
+
+renameHsForAllTelescope :: HsForAllTelescope GhcRn -> RnM (HsForAllTelescope DocNameI)
+renameHsForAllTelescope tele = case tele of
+  HsForAllVis _ bndrs -> do
+    bndrs' <- mapM (renameLTyVarBndr return) bndrs
+    pure $ HsForAllVis noExtField bndrs'
+  HsForAllInvis _ bndrs -> do
+    bndrs' <- mapM (renameLTyVarBndr return) bndrs
+    pure $ HsForAllInvis noExtField bndrs'
+
+renameLTyVarBndr :: (flag -> RnM flag') -> LHsTyVarBndr flag GhcRn -> RnM (LHsTyVarBndr flag' DocNameI)
+renameLTyVarBndr rn_flag (L loc (UserTyVar _ fl (L l n))) =
+  do
+    fl' <- rn_flag fl
+    n' <- renameName n
+    return (L loc (UserTyVar noExtField fl' (L l n')))
+renameLTyVarBndr rn_flag (L loc (KindedTyVar _ fl (L lv n) kind)) =
+  do
+    fl' <- rn_flag fl
+    n' <- renameName n
+    kind' <- renameLKind kind
+    return (L loc (KindedTyVar noExtField fl' (L lv n') kind'))
+
+renameLContext :: LocatedC [LHsType GhcRn] -> RnM (LocatedC [LHsType DocNameI])
+renameLContext (L loc context) = do
+  context' <- mapM renameLType context
+  return (L loc context')
+
+renameInstHead :: InstHead GhcRn -> RnM (InstHead DocNameI)
+renameInstHead InstHead{..} = do
+  cname <- renameName ihdClsName
+  types <- mapM renameType ihdTypes
+  itype <- case ihdInstType of
+    ClassInst{..} ->
+      ClassInst
+        <$> mapM renameType clsiCtx
+        <*> renameLHsQTyVars clsiTyVars
+        <*> mapM renameSig clsiSigs
+        <*> mapM renameDocInstance clsiAssocTys
+    TypeInst ts -> TypeInst <$> traverse renameType ts
+    DataInst dd -> DataInst <$> renameTyClD dd
+  return
+    InstHead
+      { ihdClsName = cname
+      , ihdTypes = types
+      , ihdInstType = itype
+      }
+
+renameLDecl :: LHsDecl GhcRn -> RnM (LHsDecl DocNameI)
+renameLDecl (L loc d) = return . L loc =<< renameDecl d
+
+renamePats :: [(HsDecl GhcRn, DocForDecl Name)] -> RnM [(HsDecl DocNameI, DocForDecl DocName)]
+renamePats =
+  mapM
+    ( \(d, doc) -> do
+        d' <- renameDecl d
+        doc' <- renameDocForDecl doc
+        return (d', doc')
+    )
+
+renameDecl :: HsDecl GhcRn -> RnM (HsDecl DocNameI)
+renameDecl decl = case decl of
+  TyClD _ d -> do
+    d' <- renameTyClD d
+    return (TyClD noExtField d')
+  SigD _ s -> do
+    s' <- renameSig s
+    return (SigD noExtField s')
+  ForD _ d -> do
+    d' <- renameForD d
+    return (ForD noExtField d')
+  InstD _ d -> do
+    d' <- renameInstD d
+    return (InstD noExtField d')
+  DerivD _ d -> do
+    d' <- renameDerivD d
+    return (DerivD noExtField d')
+  _ -> error "renameDecl"
+
+renameLThing :: (a GhcRn -> RnM (a DocNameI)) -> LocatedAn an (a GhcRn) -> RnM (Located (a DocNameI))
+renameLThing fn (L loc x) = return . L (locA loc) =<< fn x
+
+renameTyClD :: TyClDecl GhcRn -> RnM (TyClDecl DocNameI)
+renameTyClD d = case d of
+  --  TyFamily flav lname ltyvars kind tckind -> do
+  FamDecl{tcdFam = decl} -> do
+    decl' <- renameFamilyDecl decl
+    return (FamDecl{tcdFExt = noExtField, tcdFam = decl'})
+  SynDecl{tcdLName = lname, tcdTyVars = tyvars, tcdFixity = fixity, tcdRhs = rhs} -> do
+    lname' <- renameNameL lname
+    tyvars' <- renameLHsQTyVars tyvars
+    rhs' <- renameLType rhs
+    return
+      ( SynDecl
+          { tcdSExt = noExtField
+          , tcdLName = lname'
+          , tcdTyVars = tyvars'
+          , tcdFixity = fixity
+          , tcdRhs = rhs'
+          }
+      )
+  DataDecl{tcdLName = lname, tcdTyVars = tyvars, tcdFixity = fixity, tcdDataDefn = defn} -> do
+    lname' <- renameNameL lname
+    tyvars' <- renameLHsQTyVars tyvars
+    defn' <- renameDataDefn defn
+    return
+      ( DataDecl
+          { tcdDExt = noExtField
+          , tcdLName = lname'
+          , tcdTyVars = tyvars'
+          , tcdFixity = fixity
+          , tcdDataDefn = defn'
+          }
+      )
+  ClassDecl
+    { tcdCtxt = lcontext
+    , tcdLName = lname
+    , tcdTyVars = ltyvars
+    , tcdFixity = fixity
+    , tcdFDs = lfundeps
+    , tcdSigs = lsigs
+    , tcdATs = ats
+    , tcdATDefs = at_defs
+    } -> do
+      lcontext' <- traverse renameLContext lcontext
+      lname' <- renameNameL lname
+      ltyvars' <- renameLHsQTyVars ltyvars
+      lfundeps' <- mapM renameLFunDep lfundeps
+      lsigs' <- mapM renameLSig lsigs
+      ats' <- mapM (renameLThing renameFamilyDecl) ats
+      at_defs' <- mapM (mapM renameTyFamDefltD) at_defs
+      -- we don't need the default methods or the already collected doc entities
+      return
+        ( ClassDecl
+            { tcdCExt = noExtField
+            , tcdCtxt = lcontext'
+            , tcdLName = lname'
+            , tcdTyVars = ltyvars'
+            , tcdFixity = fixity
+            , tcdFDs = lfundeps'
+            , tcdSigs = lsigs'
+            , tcdMeths = emptyBag
+            , tcdATs = ats'
+            , tcdATDefs = at_defs'
+            , tcdDocs = []
+            }
+        )
+  where
+    renameLFunDep :: LHsFunDep GhcRn -> RnM (LHsFunDep DocNameI)
+    renameLFunDep (L loc (FunDep _ xs ys)) = do
+      xs' <- mapM renameName (map unLoc xs)
+      ys' <- mapM renameName (map unLoc ys)
+      return (L (locA loc) (FunDep noExtField (map noLocA xs') (map noLocA ys')))
+
+    renameLSig (L loc sig) = return . L (locA loc) =<< renameSig sig
+
+renameFamilyDecl :: FamilyDecl GhcRn -> RnM (FamilyDecl DocNameI)
+renameFamilyDecl
+  ( FamilyDecl
+      { fdInfo = info
+      , fdLName = lname
+      , fdTyVars = ltyvars
+      , fdFixity = fixity
+      , fdResultSig = result
+      , fdInjectivityAnn = injectivity
+      }
+    ) = do
+    info' <- renameFamilyInfo info
+    lname' <- renameNameL lname
+    ltyvars' <- renameLHsQTyVars ltyvars
+    result' <- renameFamilyResultSig result
+    injectivity' <- renameMaybeInjectivityAnn injectivity
+    return
+      ( FamilyDecl
+          { fdExt = noExtField
+          , fdInfo = info'
+          , fdTopLevel = TopLevel
+          , fdLName = lname'
+          , fdTyVars = ltyvars'
+          , fdFixity = fixity
+          , fdResultSig = result'
+          , fdInjectivityAnn = injectivity'
+          }
+      )
+
+renameFamilyInfo :: FamilyInfo GhcRn -> RnM (FamilyInfo DocNameI)
+renameFamilyInfo DataFamily = return DataFamily
+renameFamilyInfo OpenTypeFamily = return OpenTypeFamily
+renameFamilyInfo (ClosedTypeFamily eqns) =
+  do
+    eqns' <- mapM (mapM (mapM renameTyFamInstEqn)) eqns
+    return $ ClosedTypeFamily eqns'
+
+renameDataDefn :: HsDataDefn GhcRn -> RnM (HsDataDefn DocNameI)
+renameDataDefn
+  ( HsDataDefn
+      { dd_ctxt = lcontext
+      , dd_cType = cType
+      , dd_kindSig = k
+      , dd_cons = cons
+      }
+    ) = do
+    lcontext' <- traverse renameLContext lcontext
+    k' <- renameMaybeLKind k
+    cons' <- mapM (mapMA renameCon) cons
+    -- I don't think we need the derivings, so we return Nothing
+    return
+      ( HsDataDefn
+          { dd_ext = noExtField
+          , dd_ctxt = lcontext'
+          , dd_cType = cType
+          , dd_kindSig = k'
+          , dd_cons = cons'
+          , dd_derivs = []
+          }
+      )
+
+renameCon :: ConDecl GhcRn -> RnM (ConDecl DocNameI)
+renameCon
+  decl@( ConDeclH98
+          { con_name = lname
+          , con_ex_tvs = ltyvars
+          , con_mb_cxt = lcontext
+          , con_args = details
+          , con_doc = mbldoc
+          , con_forall = forall_
+          }
+        ) = do
+    lname' <- renameNameL lname
+    ltyvars' <- mapM (renameLTyVarBndr return) ltyvars
+    lcontext' <- traverse renameLContext lcontext
+    details' <- renameH98Details details
+    mbldoc' <- mapM (renameLDocHsSyn) mbldoc
+    return
+      ( decl
+          { con_ext = noExtField
+          , con_name = lname'
+          , con_ex_tvs = ltyvars'
+          , con_mb_cxt = lcontext'
+          , con_forall = forall_ -- Remove when #18311 is fixed
+          , con_args = details'
+          , con_doc = mbldoc'
+          }
+      )
+renameCon
+  ConDeclGADT
+    { con_names = lnames
+    , con_bndrs = bndrs
+    , con_mb_cxt = lcontext
+    , con_g_args = details
+    , con_res_ty = res_ty
+    , con_doc = mbldoc
+    } = do
+    lnames' <- mapM renameNameL lnames
+    bndrs' <- mapM renameOuterTyVarBndrs bndrs
+    lcontext' <- traverse renameLContext lcontext
+    details' <- renameGADTDetails details
+    res_ty' <- renameLType res_ty
+    mbldoc' <- mapM renameLDocHsSyn mbldoc
+    return
+      ( ConDeclGADT
+          { con_g_ext = noExtField
+          , con_names = lnames'
+          , con_bndrs = bndrs'
+          , con_mb_cxt = lcontext'
+          , con_g_args = details'
+          , con_res_ty = res_ty'
+          , con_doc = mbldoc'
+          }
+      )
+
+renameHsScaled
+  :: HsScaled GhcRn (LHsType GhcRn)
+  -> RnM (HsScaled DocNameI (LHsType DocNameI))
+renameHsScaled (HsScaled w ty) = HsScaled <$> renameArrow w <*> renameLType ty
+
+renameH98Details
+  :: HsConDeclH98Details GhcRn
+  -> RnM (HsConDeclH98Details DocNameI)
+renameH98Details (RecCon (L l fields)) = do
+  fields' <- mapM renameConDeclFieldField fields
+  return (RecCon (L (locA l) fields'))
+renameH98Details (PrefixCon ts ps) = PrefixCon ts <$> mapM renameHsScaled ps
+renameH98Details (InfixCon a b) = do
+  a' <- renameHsScaled a
+  b' <- renameHsScaled b
+  return (InfixCon a' b')
+
+renameGADTDetails
+  :: HsConDeclGADTDetails GhcRn
+  -> RnM (HsConDeclGADTDetails DocNameI)
+renameGADTDetails (RecConGADT _ (L l fields)) = do
+  fields' <- mapM renameConDeclFieldField fields
+  return (RecConGADT noExtField (L (locA l) fields'))
+renameGADTDetails (PrefixConGADT _ ps) = PrefixConGADT noExtField <$> mapM renameHsScaled ps
+
+renameConDeclFieldField :: LConDeclField GhcRn -> RnM (LConDeclField DocNameI)
+renameConDeclFieldField (L l (ConDeclField _ names t doc)) = do
+  names' <- mapM renameLFieldOcc names
+  t' <- renameLType t
+  doc' <- mapM renameLDocHsSyn doc
+  return $ L (locA l) (ConDeclField noExtField names' t' doc')
+
+renameLFieldOcc :: LFieldOcc GhcRn -> RnM (LFieldOcc DocNameI)
+renameLFieldOcc (L l (FieldOcc sel lbl)) = do
+  sel' <- renameName sel
+  return $ L l (FieldOcc sel' lbl)
+
+renameSig :: Sig GhcRn -> RnM (Sig DocNameI)
+renameSig sig = case sig of
+  TypeSig _ lnames ltype -> do
+    lnames' <- mapM renameNameL lnames
+    ltype' <- renameLSigWcType ltype
+    return (TypeSig noExtField lnames' ltype')
+  ClassOpSig _ is_default lnames sig_ty -> do
+    lnames' <- mapM renameNameL lnames
+    ltype' <- renameLSigType sig_ty
+    return (ClassOpSig noExtField is_default lnames' ltype')
+  PatSynSig _ lnames sig_ty -> do
+    lnames' <- mapM renameNameL lnames
+    sig_ty' <- renameLSigType sig_ty
+    return $ PatSynSig noExtField lnames' sig_ty'
+  FixSig _ (FixitySig _ lnames fixity) -> do
+    lnames' <- mapM renameNameL lnames
+    return $ FixSig noExtField (FixitySig noExtField lnames' fixity)
+  MinimalSig _ (L l s) -> do
+    s' <- traverse (traverse lookupRn) s
+    return $ MinimalSig noExtField (L l s')
+  -- we have filtered out all other kinds of signatures in Interface.Create
+  _ -> error "expected TypeSig"
+
+renameForD :: ForeignDecl GhcRn -> RnM (ForeignDecl DocNameI)
+renameForD (ForeignImport _ lname ltype x) = do
+  lname' <- renameNameL lname
+  ltype' <- renameLSigType ltype
+  return (ForeignImport noExtField lname' ltype' (renameForI x))
+renameForD (ForeignExport _ lname ltype x) = do
+  lname' <- renameNameL lname
+  ltype' <- renameLSigType ltype
+  return (ForeignExport noExtField lname' ltype' (renameForE x))
+
+renameForI :: ForeignImport GhcRn -> ForeignImport DocNameI
+renameForI (CImport _ cconv safety mHeader spec) = CImport noExtField cconv safety mHeader spec
+
+renameForE :: ForeignExport GhcRn -> ForeignExport DocNameI
+renameForE (CExport _ spec) = CExport noExtField spec
+
+renameInstD :: InstDecl GhcRn -> RnM (InstDecl DocNameI)
+renameInstD (ClsInstD{cid_inst = d}) = do
+  d' <- renameClsInstD d
+  return (ClsInstD{cid_d_ext = noExtField, cid_inst = d'})
+renameInstD (TyFamInstD{tfid_inst = d}) = do
+  d' <- renameTyFamInstD d
+  return (TyFamInstD{tfid_ext = noExtField, tfid_inst = d'})
+renameInstD (DataFamInstD{dfid_inst = d}) = do
+  d' <- renameDataFamInstD d
+  return (DataFamInstD{dfid_ext = noExtField, dfid_inst = d'})
+
+renameDerivD :: DerivDecl GhcRn -> RnM (DerivDecl DocNameI)
+renameDerivD
+  ( DerivDecl
+      { deriv_type = ty
+      , deriv_strategy = strat
+      , deriv_overlap_mode = omode
+      }
+    ) = do
+    ty' <- renameLSigWcType ty
+    strat' <- mapM (mapM renameDerivStrategy) strat
+    return
+      ( DerivDecl
+          { deriv_ext = noExtField
+          , deriv_type = ty'
+          , deriv_strategy = strat'
+          , deriv_overlap_mode = omode
+          }
+      )
+
+renameDerivStrategy :: DerivStrategy GhcRn -> RnM (DerivStrategy DocNameI)
+renameDerivStrategy (StockStrategy a) = pure (StockStrategy a)
+renameDerivStrategy (AnyclassStrategy a) = pure (AnyclassStrategy a)
+renameDerivStrategy (NewtypeStrategy a) = pure (NewtypeStrategy a)
+renameDerivStrategy (ViaStrategy ty) = ViaStrategy <$> renameLSigType ty
+
+renameClsInstD :: ClsInstDecl GhcRn -> RnM (ClsInstDecl DocNameI)
+renameClsInstD
+  ( ClsInstDecl
+      { cid_overlap_mode = omode
+      , cid_poly_ty = ltype
+      , cid_tyfam_insts = lATs
+      , cid_datafam_insts = lADTs
+      }
+    ) = do
+    ltype' <- renameLSigType ltype
+    lATs' <- mapM (mapM renameTyFamInstD) lATs
+    lADTs' <- mapM (mapM renameDataFamInstD) lADTs
+    return
+      ( ClsInstDecl
+          { cid_ext = noExtField
+          , cid_overlap_mode = omode
+          , cid_poly_ty = ltype'
+          , cid_binds = emptyBag
+          , cid_sigs = []
+          , cid_tyfam_insts = lATs'
+          , cid_datafam_insts = lADTs'
+          }
+      )
+
+renameTyFamInstD :: TyFamInstDecl GhcRn -> RnM (TyFamInstDecl DocNameI)
+renameTyFamInstD (TyFamInstDecl{tfid_eqn = eqn}) =
+  do
+    eqn' <- renameTyFamInstEqn eqn
+    return (TyFamInstDecl{tfid_xtn = noExtField, tfid_eqn = eqn'})
+
+renameTyFamInstEqn :: TyFamInstEqn GhcRn -> RnM (TyFamInstEqn DocNameI)
+renameTyFamInstEqn
+  ( FamEqn
+      { feqn_tycon = tc
+      , feqn_bndrs = bndrs
+      , feqn_pats = pats
+      , feqn_fixity = fixity
+      , feqn_rhs = rhs
+      }
+    ) =
+    do
+      tc' <- renameNameL tc
+      bndrs' <- renameOuterTyVarBndrs bndrs
+      pats' <- mapM renameLTypeArg pats
+      rhs' <- renameLType rhs
+      return
+        ( FamEqn
+            { feqn_ext = noExtField
+            , feqn_tycon = tc'
+            , feqn_bndrs = bndrs'
+            , feqn_pats = pats'
+            , feqn_fixity = fixity
+            , feqn_rhs = rhs'
+            }
+        )
+
+renameTyFamDefltD :: TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI)
+renameTyFamDefltD = renameTyFamInstD
+
+renameDataFamInstD :: DataFamInstDecl GhcRn -> RnM (DataFamInstDecl DocNameI)
+renameDataFamInstD (DataFamInstDecl{dfid_eqn = eqn}) =
+  do
+    eqn' <- rename_data_fam_eqn eqn
+    return (DataFamInstDecl{dfid_eqn = eqn'})
+  where
+    rename_data_fam_eqn
+      :: FamEqn GhcRn (HsDataDefn GhcRn)
+      -> RnM (FamEqn DocNameI (HsDataDefn DocNameI))
+    rename_data_fam_eqn
+      ( FamEqn
+          { feqn_tycon = tc
+          , feqn_bndrs = bndrs
+          , feqn_pats = pats
+          , feqn_fixity = fixity
+          , feqn_rhs = defn
+          }
+        ) =
+        do
+          tc' <- renameNameL tc
+          bndrs' <- renameOuterTyVarBndrs bndrs
+          pats' <- mapM renameLTypeArg pats
+          defn' <- renameDataDefn defn
+          return
+            ( FamEqn
+                { feqn_ext = noExtField
+                , feqn_tycon = tc'
+                , feqn_bndrs = bndrs'
+                , feqn_pats = pats'
+                , feqn_fixity = fixity
+                , feqn_rhs = defn'
+                }
+            )
+
+renameOuterTyVarBndrs
+  :: HsOuterTyVarBndrs flag GhcRn
+  -> RnM (HsOuterTyVarBndrs flag DocNameI)
+renameOuterTyVarBndrs (HsOuterImplicit{}) =
+  pure $ HsOuterImplicit{hso_ximplicit = noExtField}
+renameOuterTyVarBndrs (HsOuterExplicit{hso_bndrs = exp_bndrs}) =
+  HsOuterExplicit noExtField <$> mapM (renameLTyVarBndr return) exp_bndrs
+
+renameWc
+  :: (in_thing -> RnM out_thing)
+  -> HsWildCardBndrs GhcRn in_thing
+  -> RnM (HsWildCardBndrs DocNameI out_thing)
+renameWc rn_thing (HsWC{hswc_body = thing}) =
+  do
+    thing' <- rn_thing thing
+    return
+      ( HsWC
+          { hswc_body = thing'
+          , hswc_ext = noExtField
+          }
+      )
+
+renameDocInstance :: DocInstance GhcRn -> RnM (DocInstance DocNameI)
+renameDocInstance (inst, idoc, L l n, m) = do
+  inst' <- renameInstHead inst
+  n' <- renameName n
+  idoc' <- mapM renameDoc idoc
+  return (inst', idoc', L l n', m)
+
+renameSub :: (Name, DocForDecl Name) -> RnM (DocName, DocForDecl DocName)
+renameSub (n, doc) = do
+  n' <- renameName n
+  doc' <- renameDocForDecl doc
+  return (n', doc')
diff --git a/utils/haddock/haddock-api/src/Haddock/Interface/RenameType.hs b/utils/haddock/haddock-api/src/Haddock/Interface/RenameType.hs
new file mode 100644
index 0000000000000000000000000000000000000000..fb6905ce9e475ba66f0e92bcf4cea1d69b634d04
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Interface/RenameType.hs
@@ -0,0 +1,213 @@
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE Rank2Types #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeApplications #-}
+{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
+
+module Haddock.Interface.RenameType
+  ( rename
+  ) where
+
+import Haddock.Types
+
+import GHC
+import GHC.Data.FastString
+import GHC.Types.Name
+
+import Control.Monad.Trans.State
+
+import qualified Data.List as List
+import Data.Map.Strict (Map)
+import qualified Data.Map.Strict as Map
+import Data.Maybe
+import Data.Set (Set)
+import qualified Data.Set as Set
+
+-- | Haskell AST type representation.
+--
+-- This type is used for renaming (more below), essentially the ambiguous (!)
+-- version of 'Name'. So, why is this 'FastString' instead of 'OccName'? Well,
+-- it was 'OccName' before, but turned out that 'OccName' sometimes also
+-- contains namespace information, differentiating visually same types.
+--
+-- And 'FastString' is used because it is /visual/ part of 'OccName' - it is
+-- not converted to 'String' or alike to avoid new allocations. Additionally,
+-- since it is stored mostly in 'Set', fast comparison of 'FastString' is also
+-- quite nice.
+newtype NameRep
+  = NameRep FastString
+  deriving (Eq)
+
+instance Ord NameRep where
+  compare (NameRep fs1) (NameRep fs2) = uniqCompareFS fs1 fs2
+
+getNameRep :: NamedThing name => name -> NameRep
+getNameRep = NameRep . getOccFS
+
+nameRepString :: NameRep -> String
+nameRepString (NameRep fs) = unpackFS fs
+
+stringNameRep :: String -> NameRep
+stringNameRep = NameRep . mkFastString
+
+setInternalNameRep :: SetName name => NameRep -> name -> name
+setInternalNameRep (NameRep fs) = setInternalOccName (mkVarOccFS fs)
+
+setInternalOccName :: SetName name => OccName -> name -> name
+setInternalOccName occ name =
+  setName nname' name
+  where
+    nname = getName name
+    nname' = mkInternalName (nameUnique nname) occ (nameSrcSpan nname)
+
+-- | Make given type visually unambiguous.
+--
+-- After applying 'specialize' method, some free type variables may become
+-- visually ambiguous - for example, having @a -> b@ and specializing @a@ to
+-- @(a -> b)@ we get @(a -> b) -> b@ where first occurrence of @b@ refers to
+-- different type variable than latter one. Applying 'rename' function
+-- will fix that type to be visually unambiguous again (making it something
+-- like @(a -> b0) -> b@).
+rename :: [Name] -> LHsType GhcRn -> LHsType GhcRn
+rename [] typ = typ
+rename fv typ = evalState (traverse renameType typ) env
+  where
+    env =
+      RenameEnv
+        { rneHeadFVs = Map.fromList $ map mkPair fv
+        , rneCtx = Map.empty
+        }
+    mkPair name = (getNameRep name, name)
+
+-- | Renaming monad.
+type Rename name = State (RenameEnv name)
+
+data RenameEnv name = RenameEnv
+  { rneHeadFVs :: Map NameRep Name
+  , rneCtx :: Map Name name
+  }
+
+renameType :: HsType GhcRn -> Rename (IdP GhcRn) (HsType GhcRn)
+renameType (HsForAllTy x tele lt) =
+  HsForAllTy x
+    <$> renameForAllTelescope tele
+    <*> renameLType lt
+renameType (HsQualTy x lctxt lt) =
+  HsQualTy x
+    <$> renameLContext lctxt
+    <*> renameLType lt
+renameType (HsTyVar x ip name) = HsTyVar x ip <$> locatedN renameName name
+renameType t@(HsStarTy _ _) = pure t
+renameType (HsAppTy x lf la) = HsAppTy x <$> renameLType lf <*> renameLType la
+renameType (HsAppKindTy x lt lk) = HsAppKindTy x <$> renameLType lt <*> renameLKind lk
+renameType (HsFunTy x w la lr) = HsFunTy x <$> renameHsArrow w <*> renameLType la <*> renameLType lr
+renameType (HsListTy x lt) = HsListTy x <$> renameLType lt
+renameType (HsTupleTy x srt lt) = HsTupleTy x srt <$> mapM renameLType lt
+renameType (HsSumTy x lt) = HsSumTy x <$> mapM renameLType lt
+renameType (HsOpTy x f la lop lb) =
+  HsOpTy x <$> pure f <*> renameLType la <*> locatedN renameName lop <*> renameLType lb
+renameType (HsParTy x lt) = HsParTy x <$> renameLType lt
+renameType (HsIParamTy x ip lt) = HsIParamTy x ip <$> renameLType lt
+renameType (HsKindSig x lt lk) = HsKindSig x <$> renameLType lt <*> pure lk
+renameType t@(HsSpliceTy _ _) = pure t
+renameType (HsDocTy x lt doc) = HsDocTy x <$> renameLType lt <*> pure doc
+renameType (HsBangTy x bang lt) = HsBangTy x bang <$> renameLType lt
+renameType t@(HsRecTy _ _) = pure t
+renameType t@(XHsType _) = pure t
+renameType (HsExplicitListTy x ip ltys) =
+  HsExplicitListTy x ip <$> renameLTypes ltys
+renameType (HsExplicitTupleTy x ltys) =
+  HsExplicitTupleTy x <$> renameLTypes ltys
+renameType t@(HsTyLit _ _) = pure t
+renameType (HsWildCardTy wc) = pure (HsWildCardTy wc)
+
+renameHsArrow :: HsArrow GhcRn -> Rename (IdP GhcRn) (HsArrow GhcRn)
+renameHsArrow (HsExplicitMult x p) = HsExplicitMult x <$> renameLType p
+renameHsArrow mult = pure mult
+
+renameLType :: LHsType GhcRn -> Rename (IdP GhcRn) (LHsType GhcRn)
+renameLType = located renameType
+
+renameLKind :: LHsKind GhcRn -> Rename (IdP GhcRn) (LHsKind GhcRn)
+renameLKind = renameLType
+
+renameLTypes :: [LHsType GhcRn] -> Rename (IdP GhcRn) [LHsType GhcRn]
+renameLTypes = mapM renameLType
+
+renameLContext :: LHsContext GhcRn -> Rename (IdP GhcRn) (LHsContext GhcRn)
+renameLContext (L l ctxt) = do
+  ctxt' <- renameContext ctxt
+  return (L l ctxt')
+
+renameContext :: HsContext GhcRn -> Rename (IdP GhcRn) (HsContext GhcRn)
+renameContext = renameLTypes
+
+renameForAllTelescope
+  :: HsForAllTelescope GhcRn
+  -> Rename (IdP GhcRn) (HsForAllTelescope GhcRn)
+renameForAllTelescope (HsForAllVis x bndrs) =
+  HsForAllVis x <$> mapM renameLBinder bndrs
+renameForAllTelescope (HsForAllInvis x bndrs) =
+  HsForAllInvis x <$> mapM renameLBinder bndrs
+
+renameBinder :: HsTyVarBndr flag GhcRn -> Rename (IdP GhcRn) (HsTyVarBndr flag GhcRn)
+renameBinder (UserTyVar x fl lname) = UserTyVar x fl <$> locatedN renameName lname
+renameBinder (KindedTyVar x fl lname lkind) =
+  KindedTyVar x fl <$> locatedN renameName lname <*> located renameType lkind
+
+renameLBinder :: LHsTyVarBndr flag GhcRn -> Rename (IdP GhcRn) (LHsTyVarBndr flag GhcRn)
+renameLBinder = located renameBinder
+
+-- | Core renaming logic.
+renameName :: SetName name => name -> Rename name name
+renameName name = do
+  RenameEnv{..} <- get
+  case Map.lookup (getName name) rneCtx of
+    Nothing
+      | Just headTv <- Map.lookup (getNameRep name) rneHeadFVs
+      , headTv /= getName name ->
+          freshName name
+    Just name' -> return name'
+    _ -> return name
+
+-- | Generate fresh occurrence name, put it into context and return.
+freshName :: SetName name => name -> Rename name name
+freshName name = do
+  taken <- takenNames
+  let name' = setInternalNameRep (findFreshName taken rep) name
+  modify $ \rne ->
+    rne
+      { rneCtx = Map.insert (getName name) name' (rneCtx rne)
+      }
+  return name'
+  where
+    nname = getName name
+    rep = getNameRep nname
+
+takenNames :: NamedThing name => Rename name (Set NameRep)
+takenNames = do
+  RenameEnv{..} <- get
+  return $ Set.unions [headReps rneHeadFVs, ctxElems rneCtx]
+  where
+    headReps = Set.fromList . Map.keys
+    ctxElems = Set.fromList . map getNameRep . Map.elems
+
+findFreshName :: Set NameRep -> NameRep -> NameRep
+findFreshName taken =
+  fromJust . List.find isFresh . alternativeNames
+  where
+    isFresh = not . flip Set.member taken
+
+alternativeNames :: NameRep -> [NameRep]
+alternativeNames name =
+  [stringNameRep $ str ++ show i | i :: Int <- [0 ..]]
+  where
+    str = nameRepString name
+
+located :: Functor f => (a -> f b) -> GenLocated l a -> f (GenLocated l b)
+located f (L loc e) = L loc <$> f e
+
+locatedN :: Functor f => (a -> f b) -> LocatedN a -> f (LocatedN b)
+locatedN f (L loc e) = L loc <$> f e
diff --git a/utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs b/utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs
new file mode 100644
index 0000000000000000000000000000000000000000..fd90dcaf333108aa8e698a04767695ff6ca5ad1d
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs
@@ -0,0 +1,763 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE NamedFieldPuns #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeApplications #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.InterfaceFile
+-- Copyright   :  (c) David Waern       2006-2009,
+--                    Mateusz Kowalczyk 2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Reading and writing the .haddock interface file
+module Haddock.InterfaceFile
+  ( InterfaceFile (..)
+  , PackageInfo (..)
+  , ifUnitId
+  , ifModule
+  , PackageInterfaces (..)
+  , mkPackageInterfaces
+  , ppPackageInfo
+  , readInterfaceFile
+  , writeInterfaceFile
+  , freshNameCache
+  , binaryInterfaceVersion
+  , binaryInterfaceVersionCompatibility
+  ) where
+
+import Haddock.Types
+
+import Data.Function ((&))
+import Data.IORef
+import Data.Map (Map)
+import qualified Data.Map as Map
+import Data.Version
+import Data.Word
+import Text.ParserCombinators.ReadP (readP_to_S)
+
+import GHC hiding (NoLink)
+import GHC.Data.FastMutInt
+import GHC.Data.FastString
+import GHC.Iface.Binary (getWithUserData, putSymbolTable)
+import GHC.Types.Name.Cache
+import GHC.Types.Unique
+import GHC.Types.Unique.FM
+import GHC.Unit.State
+import GHC.Utils.Binary
+
+import GHC.Iface.Type (IfaceType, getIfaceType, putIfaceType)
+
+import Haddock.Options (Visibility (..))
+
+data InterfaceFile = InterfaceFile
+  { ifLinkEnv :: LinkEnv
+  , ifPackageInfo :: PackageInfo
+  -- ^ Package meta data.  Currently it only consist of a package name, which
+  -- is not read from the interface file, but inferred from its name.
+  --
+  -- issue #
+  , ifInstalledIfaces :: [InstalledInterface]
+  }
+
+data PackageInfo = PackageInfo
+  { piPackageName :: PackageName
+  , piPackageVersion :: Data.Version.Version
+  }
+
+ppPackageInfo :: PackageInfo -> String
+ppPackageInfo (PackageInfo name version)
+  | version == makeVersion [] =
+      unpackFS (unPackageName name)
+ppPackageInfo (PackageInfo name version) = unpackFS (unPackageName name) ++ "-" ++ showVersion version
+
+data PackageInterfaces = PackageInterfaces
+  { piPackageInfo :: PackageInfo
+  , piVisibility :: Visibility
+  , piInstalledInterfaces :: [InstalledInterface]
+  }
+
+mkPackageInterfaces :: Visibility -> InterfaceFile -> PackageInterfaces
+mkPackageInterfaces
+  piVisibility
+  InterfaceFile
+    { ifPackageInfo
+    , ifInstalledIfaces
+    } =
+    PackageInterfaces
+      { piPackageInfo = ifPackageInfo
+      , piVisibility
+      , piInstalledInterfaces = ifInstalledIfaces
+      }
+
+ifModule :: InterfaceFile -> Module
+ifModule if_ =
+  case ifInstalledIfaces if_ of
+    [] -> error "empty InterfaceFile"
+    iface : _ -> instMod iface
+
+ifUnitId :: InterfaceFile -> Unit
+ifUnitId if_ =
+  case ifInstalledIfaces if_ of
+    [] -> error "empty InterfaceFile"
+    iface : _ -> moduleUnit $ instMod iface
+
+binaryInterfaceMagic :: Word32
+binaryInterfaceMagic = 0xD0Cface
+
+-- Note [The DocModule story]
+--
+-- Breaking changes to the DocH type result in Haddock being unable to read
+-- existing interfaces. This is especially painful for interfaces shipped
+-- with GHC distributions since there is no easy way to regenerate them!
+--
+-- PR #1315 introduced a breaking change to the DocModule constructor. To
+-- maintain backward compatibility we
+--
+-- Parse the old DocModule constructor format (tag 5) and parse the contained
+-- string into a proper ModLink structure. When writing interfaces we exclusively
+-- use the new DocModule format (tag 24)
+
+-- IMPORTANT: Since datatypes in the GHC API might change between major
+-- versions, and because we store GHC datatypes in our interface files, we need
+-- to make sure we version our interface files accordingly.
+--
+-- If you change the interface file format or adapt Haddock to work with a new
+-- major version of GHC (so that the format changes indirectly) *you* need to
+-- follow these steps:
+--
+-- (1) increase `binaryInterfaceVersion`
+--
+-- (2) set `binaryInterfaceVersionCompatibility` to [binaryInterfaceVersion]
+--
+binaryInterfaceVersion :: Word16
+#if MIN_VERSION_ghc(9,9,0) && !MIN_VERSION_ghc(9,12,0)
+binaryInterfaceVersion = 44
+
+binaryInterfaceVersionCompatibility :: [Word16]
+binaryInterfaceVersionCompatibility = [binaryInterfaceVersion]
+#else
+#error Unsupported GHC version
+#endif
+
+initBinMemSize :: Int
+initBinMemSize = 1024 * 1024
+
+writeInterfaceFile :: FilePath -> InterfaceFile -> IO ()
+writeInterfaceFile filename iface = do
+  bh0 <- openBinMem initBinMemSize
+  put_ bh0 binaryInterfaceMagic
+  put_ bh0 binaryInterfaceVersion
+
+  -- remember where the dictionary pointer will go
+  dict_p_p <- tellBinWriter bh0
+  put_ bh0 dict_p_p
+
+  -- remember where the symbol table pointer will go
+  symtab_p_p <- tellBinWriter bh0
+  put_ bh0 symtab_p_p
+
+  -- remember where the iface type table pointer will go
+  ifacetype_p_p <- tellBinWriter bh0
+  put_ bh0 ifacetype_p_p
+
+  -- Make some intial state
+  symtab_next <- newFastMutInt 0
+  symtab_map <- newIORef emptyUFM
+  let bin_symtab =
+        BinSymbolTable
+          { bin_symtab_next = symtab_next
+          , bin_symtab_map = symtab_map
+          }
+  dict_next_ref <- newFastMutInt 0
+  dict_map_ref <- newIORef emptyUFM
+  let bin_dict =
+        BinDictionary
+          { bin_dict_next = dict_next_ref
+          , bin_dict_map = dict_map_ref
+          }
+
+  iface_type_dict <- initGenericSymbolTable @(Map IfaceType)
+
+  -- put the main thing
+  let bh =
+        bh0
+          & addWriterToUserData (mkWriter $ putName bin_symtab)
+          & addWriterToUserData (simpleBindingNameWriter $ mkWriter $ putName bin_symtab)
+          & addWriterToUserData (mkWriter $ putFastString bin_dict)
+          & addWriterToUserData (mkWriter $ putGenericSymTab iface_type_dict)
+  putInterfaceFile_ bh iface
+
+  -- write the iface type pointer at the front of the file
+  ifacetype_p <- tellBinWriter bh
+  putAt bh ifacetype_p_p ifacetype_p
+  seekBinWriter bh ifacetype_p
+
+  -- write the symbol table itself
+  _ <- putGenericSymbolTable iface_type_dict putIfaceType bh
+
+  -- write the symtab pointer at the front of the file
+  symtab_p <- tellBinWriter bh
+  putAt bh symtab_p_p symtab_p
+  seekBinWriter bh symtab_p
+
+  -- write the symbol table itself
+  symtab_next' <- readFastMutInt symtab_next
+  symtab_map' <- readIORef symtab_map
+  putSymbolTable bh symtab_next' symtab_map'
+
+  -- write the dictionary pointer at the fornt of the file
+  dict_p <- tellBinWriter bh
+  putAt bh dict_p_p dict_p
+  seekBinWriter bh dict_p
+
+  -- write the dictionary itself
+  dict_next <- readFastMutInt dict_next_ref
+  dict_map <- readIORef dict_map_ref
+  putDictionary bh dict_next dict_map
+
+  -- and send the result to the file
+  writeBinMem bh filename
+  return ()
+
+freshNameCache :: IO NameCache
+freshNameCache =
+  initNameCache
+    'a' -- ??
+    []
+
+-- | Read a Haddock (@.haddock@) interface file. Return either an
+-- 'InterfaceFile' or an error message.
+--
+-- This function can be called in two ways.  Within a GHC session it will
+-- update the use and update the session's name cache.  Outside a GHC session
+-- a new empty name cache is used.
+readInterfaceFile
+  :: NameCache
+  -> FilePath
+  -> Bool
+  -- ^ Disable version check. Can cause runtime crash.
+  -> IO (Either String InterfaceFile)
+readInterfaceFile name_cache filename bypass_checks = do
+  bh <- readBinMem filename
+  magic <- get bh
+  if magic /= binaryInterfaceMagic
+    then return . Left $ "Magic number mismatch: couldn't load interface file: " ++ filename
+    else do
+      version <- get bh
+      if not bypass_checks && (version `notElem` binaryInterfaceVersionCompatibility)
+        then return . Left $ "Interface file is of wrong version: " ++ filename
+        else Right <$> getWithUserData name_cache bh
+
+-------------------------------------------------------------------------------
+
+-- * Symbol table
+
+-------------------------------------------------------------------------------
+
+putName :: BinSymbolTable -> WriteBinHandle -> Name -> IO ()
+putName
+  BinSymbolTable
+    { bin_symtab_map = symtab_map_ref
+    , bin_symtab_next = symtab_next
+    }
+  bh
+  name =
+    do
+      symtab_map <- readIORef symtab_map_ref
+      case lookupUFM symtab_map name of
+        Just (off, _) -> put_ bh (fromIntegral off :: Word32)
+        Nothing -> do
+          off <- readFastMutInt symtab_next
+          writeFastMutInt symtab_next (off + 1)
+          writeIORef symtab_map_ref $!
+            addToUFM symtab_map name (off, name)
+          put_ bh (fromIntegral off :: Word32)
+
+data BinSymbolTable = BinSymbolTable
+  { bin_symtab_next :: !FastMutInt -- The next index to use
+  , bin_symtab_map :: !(IORef (UniqFM Name (Int, Name)))
+  -- indexed by Name
+  }
+
+putFastString :: BinDictionary -> WriteBinHandle -> FastString -> IO ()
+putFastString
+  BinDictionary
+    { bin_dict_next = j_r
+    , bin_dict_map = out_r
+    }
+  bh
+  f =
+    do
+      out <- readIORef out_r
+      let !unique = getUnique f
+      case lookupUFM_Directly out unique of
+        Just (j, _) -> put_ bh (fromIntegral j :: Word32)
+        Nothing -> do
+          j <- readFastMutInt j_r
+          put_ bh (fromIntegral j :: Word32)
+          writeFastMutInt j_r (j + 1)
+          writeIORef out_r $! addToUFM_Directly out unique (j, f)
+
+data BinDictionary = BinDictionary
+  { bin_dict_next :: !FastMutInt -- The next index to use
+  , bin_dict_map :: !(IORef (UniqFM FastString (Int, FastString)))
+  -- indexed by FastString
+  }
+
+-------------------------------------------------------------------------------
+
+-- * GhcBinary instances
+
+-------------------------------------------------------------------------------
+
+instance (Ord k, Binary k, Binary v) => Binary (Map k v) where
+  put_ bh m = put_ bh (Map.toList m)
+  get bh = fmap (Map.fromList) (get bh)
+
+instance Binary PackageInfo where
+  put_ bh PackageInfo{piPackageName, piPackageVersion} = do
+    put_ bh (unPackageName piPackageName)
+    put_ bh (showVersion piPackageVersion)
+  get bh = do
+    name <- PackageName <$> get bh
+    versionString <- get bh
+    let version = case readP_to_S parseVersion versionString of
+          [] -> makeVersion []
+          vs -> fst (last vs)
+    return $ PackageInfo name version
+
+instance Binary InterfaceFile where
+  put_ bh (InterfaceFile env info ifaces) = do
+    put_ bh env
+    put_ bh info
+    put_ bh ifaces
+
+  get bh = do
+    env <- get bh
+    info <- get bh
+    ifaces <- get bh
+    return (InterfaceFile env info ifaces)
+
+putInterfaceFile_ :: WriteBinHandle -> InterfaceFile -> IO ()
+putInterfaceFile_ bh (InterfaceFile env info ifaces) = do
+  put_ bh env
+  put_ bh info
+  put_ bh ifaces
+
+instance Binary InstalledInterface where
+  put_
+    bh
+    ( InstalledInterface
+        modu
+        is_sig
+        info
+        docMap
+        argMap
+        defMeths
+        exps
+        visExps
+        opts
+        fixMap
+      ) = do
+      put_ bh modu
+      put_ bh is_sig
+      put_ bh info
+      lazyPut bh (docMap, argMap)
+      put_ bh defMeths
+      put_ bh exps
+      put_ bh visExps
+      put_ bh opts
+      put_ bh fixMap
+
+  get bh = do
+    modu <- get bh
+    is_sig <- get bh
+    info <- get bh
+    ~(docMap, argMap) <- lazyGet bh
+    defMeths <- get bh
+    exps <- get bh
+    visExps <- get bh
+    opts <- get bh
+    fixMap <- get bh
+    return
+      ( InstalledInterface
+          modu
+          is_sig
+          info
+          docMap
+          argMap
+          defMeths
+          exps
+          visExps
+          opts
+          fixMap
+      )
+
+instance Binary DocOption where
+  put_ bh OptHide = do
+    putByte bh 0
+  put_ bh OptPrune = do
+    putByte bh 1
+  put_ bh OptIgnoreExports = do
+    putByte bh 2
+  put_ bh OptNotHome = do
+    putByte bh 3
+  put_ bh OptShowExtensions = do
+    putByte bh 4
+  put_ bh OptPrintRuntimeRep = do
+    putByte bh 5
+  get bh = do
+    h <- getByte bh
+    case h of
+      0 -> do
+        return OptHide
+      1 -> do
+        return OptPrune
+      2 -> do
+        return OptIgnoreExports
+      3 -> do
+        return OptNotHome
+      4 -> do
+        return OptShowExtensions
+      5 -> do
+        return OptPrintRuntimeRep
+      n -> fail $ "invalid binary data found: " <> show n
+
+instance Binary Example where
+  put_ bh (Example expression result) = do
+    put_ bh expression
+    put_ bh result
+  get bh = do
+    expression <- get bh
+    result <- get bh
+    return (Example expression result)
+
+instance Binary a => Binary (Hyperlink a) where
+  put_ bh (Hyperlink url label) = do
+    put_ bh url
+    put_ bh label
+  get bh = do
+    url <- get bh
+    label <- get bh
+    return (Hyperlink url label)
+
+instance Binary a => Binary (ModLink a) where
+  put_ bh (ModLink m label) = do
+    put_ bh m
+    put_ bh label
+  get bh = do
+    m <- get bh
+    label <- get bh
+    return (ModLink m label)
+
+instance Binary Picture where
+  put_ bh (Picture uri title) = do
+    put_ bh uri
+    put_ bh title
+  get bh = do
+    uri <- get bh
+    title <- get bh
+    return (Picture uri title)
+
+instance Binary a => Binary (Header a) where
+  put_ bh (Header l t) = do
+    put_ bh l
+    put_ bh t
+  get bh = do
+    l <- get bh
+    t <- get bh
+    return (Header l t)
+
+instance Binary a => Binary (Table a) where
+  put_ bh (Table h b) = do
+    put_ bh h
+    put_ bh b
+  get bh = do
+    h <- get bh
+    b <- get bh
+    return (Table h b)
+
+instance Binary a => Binary (TableRow a) where
+  put_ bh (TableRow cs) = put_ bh cs
+  get bh = do
+    cs <- get bh
+    return (TableRow cs)
+
+instance Binary a => Binary (TableCell a) where
+  put_ bh (TableCell i j c) = do
+    put_ bh i
+    put_ bh j
+    put_ bh c
+  get bh = do
+    i <- get bh
+    j <- get bh
+    c <- get bh
+    return (TableCell i j c)
+
+instance Binary Meta where
+  put_ bh (Meta since) = do
+    put_ bh since
+  get bh = do
+    since <- get bh
+    return (Meta since)
+
+instance Binary MetaSince where
+  put_ bh (MetaSince v p) = do
+    put_ bh v
+    put_ bh p
+  get bh = do
+    v <- get bh
+    p <- get bh
+    return (MetaSince v p)
+
+instance (Binary mod, Binary id) => Binary (MetaDoc mod id) where
+  put_ bh MetaDoc{_meta = m, _doc = d} = do
+    put_ bh m
+    put_ bh d
+  get bh = do
+    m <- get bh
+    d <- get bh
+    return $ MetaDoc{_meta = m, _doc = d}
+
+instance (Binary mod, Binary id) => Binary (DocH mod id) where
+  put_ bh DocEmpty = do
+    putByte bh 0
+  put_ bh (DocAppend aa ab) = do
+    putByte bh 1
+    put_ bh aa
+    put_ bh ab
+  put_ bh (DocString ac) = do
+    putByte bh 2
+    put_ bh ac
+  put_ bh (DocParagraph ad) = do
+    putByte bh 3
+    put_ bh ad
+  put_ bh (DocIdentifier ae) = do
+    putByte bh 4
+    put_ bh ae
+  put_ bh (DocEmphasis ag) = do
+    putByte bh 6
+    put_ bh ag
+  put_ bh (DocMonospaced ah) = do
+    putByte bh 7
+    put_ bh ah
+  put_ bh (DocUnorderedList ai) = do
+    putByte bh 8
+    put_ bh ai
+  put_ bh (DocOrderedList aj) = do
+    putByte bh 9
+    put_ bh aj
+  put_ bh (DocDefList ak) = do
+    putByte bh 10
+    put_ bh ak
+  put_ bh (DocCodeBlock al) = do
+    putByte bh 11
+    put_ bh al
+  put_ bh (DocHyperlink am) = do
+    putByte bh 12
+    put_ bh am
+  put_ bh (DocPic x) = do
+    putByte bh 13
+    put_ bh x
+  put_ bh (DocAName an) = do
+    putByte bh 14
+    put_ bh an
+  put_ bh (DocExamples ao) = do
+    putByte bh 15
+    put_ bh ao
+  put_ bh (DocIdentifierUnchecked x) = do
+    putByte bh 16
+    put_ bh x
+  put_ bh (DocWarning ag) = do
+    putByte bh 17
+    put_ bh ag
+  put_ bh (DocProperty x) = do
+    putByte bh 18
+    put_ bh x
+  put_ bh (DocBold x) = do
+    putByte bh 19
+    put_ bh x
+  put_ bh (DocHeader aa) = do
+    putByte bh 20
+    put_ bh aa
+  put_ bh (DocMathInline x) = do
+    putByte bh 21
+    put_ bh x
+  put_ bh (DocMathDisplay x) = do
+    putByte bh 22
+    put_ bh x
+  put_ bh (DocTable x) = do
+    putByte bh 23
+    put_ bh x
+  -- See note [The DocModule story]
+  put_ bh (DocModule af) = do
+    putByte bh 24
+    put_ bh af
+
+  get bh = do
+    h <- getByte bh
+    case h of
+      0 -> do
+        return DocEmpty
+      1 -> do
+        aa <- get bh
+        ab <- get bh
+        return (DocAppend aa ab)
+      2 -> do
+        ac <- get bh
+        return (DocString ac)
+      3 -> do
+        ad <- get bh
+        return (DocParagraph ad)
+      4 -> do
+        ae <- get bh
+        return (DocIdentifier ae)
+      -- See note [The DocModule story]
+      5 -> do
+        af <- get bh
+        return $
+          DocModule
+            ModLink
+              { modLinkName = af
+              , modLinkLabel = Nothing
+              }
+      6 -> do
+        ag <- get bh
+        return (DocEmphasis ag)
+      7 -> do
+        ah <- get bh
+        return (DocMonospaced ah)
+      8 -> do
+        ai <- get bh
+        return (DocUnorderedList ai)
+      9 -> do
+        aj <- get bh
+        return (DocOrderedList aj)
+      10 -> do
+        ak <- get bh
+        return (DocDefList ak)
+      11 -> do
+        al <- get bh
+        return (DocCodeBlock al)
+      12 -> do
+        am <- get bh
+        return (DocHyperlink am)
+      13 -> do
+        x <- get bh
+        return (DocPic x)
+      14 -> do
+        an <- get bh
+        return (DocAName an)
+      15 -> do
+        ao <- get bh
+        return (DocExamples ao)
+      16 -> do
+        x <- get bh
+        return (DocIdentifierUnchecked x)
+      17 -> do
+        ag <- get bh
+        return (DocWarning ag)
+      18 -> do
+        x <- get bh
+        return (DocProperty x)
+      19 -> do
+        x <- get bh
+        return (DocBold x)
+      20 -> do
+        aa <- get bh
+        return (DocHeader aa)
+      21 -> do
+        x <- get bh
+        return (DocMathInline x)
+      22 -> do
+        x <- get bh
+        return (DocMathDisplay x)
+      23 -> do
+        x <- get bh
+        return (DocTable x)
+      -- See note [The DocModule story]
+      24 -> do
+        af <- get bh
+        return (DocModule af)
+      _ -> error "invalid binary data found in the interface file"
+
+instance Binary name => Binary (HaddockModInfo name) where
+  put_ bh hmi = do
+    put_ bh (hmi_description hmi)
+    put_ bh (hmi_copyright hmi)
+    put_ bh (hmi_license hmi)
+    put_ bh (hmi_maintainer hmi)
+    put_ bh (hmi_stability hmi)
+    put_ bh (hmi_portability hmi)
+    put_ bh (hmi_safety hmi)
+    put_ bh (fromEnum <$> hmi_language hmi)
+    put_ bh (map fromEnum $ hmi_extensions hmi)
+
+  get bh = do
+    descr <- get bh
+    copyr <- get bh
+    licen <- get bh
+    maint <- get bh
+    stabi <- get bh
+    porta <- get bh
+    safet <- get bh
+    langu <- fmap toEnum <$> get bh
+    exten <- map toEnum <$> get bh
+    return (HaddockModInfo descr copyr licen maint stabi porta safet langu exten)
+
+instance Binary DocName where
+  put_ bh (Documented name modu) = do
+    putByte bh 0
+    put_ bh name
+    put_ bh modu
+  put_ bh (Undocumented name) = do
+    putByte bh 1
+    put_ bh name
+
+  get bh = do
+    h <- getByte bh
+    case h of
+      0 -> do
+        name <- get bh
+        modu <- get bh
+        return (Documented name modu)
+      1 -> do
+        name <- get bh
+        return (Undocumented name)
+      _ -> error "get DocName: Bad h"
+
+instance Binary n => Binary (Wrap n) where
+  put_ bh (Unadorned n) = do
+    putByte bh 0
+    put_ bh n
+  put_ bh (Parenthesized n) = do
+    putByte bh 1
+    put_ bh n
+  put_ bh (Backticked n) = do
+    putByte bh 2
+    put_ bh n
+
+  get bh = do
+    h <- getByte bh
+    case h of
+      0 -> do
+        name <- get bh
+        return (Unadorned name)
+      1 -> do
+        name <- get bh
+        return (Parenthesized name)
+      2 -> do
+        name <- get bh
+        return (Backticked name)
+      _ -> error "get Wrap: Bad h"
diff --git a/utils/haddock/haddock-api/src/Haddock/ModuleTree.hs b/utils/haddock/haddock-api/src/Haddock/ModuleTree.hs
new file mode 100644
index 0000000000000000000000000000000000000000..2bcbaefefbb2c25e941e2bc7d8d6f2393d6061d5
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/ModuleTree.hs
@@ -0,0 +1,63 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.ModuleTree
+-- Copyright   :  (c) Simon Marlow 2003-2006,
+--                    David Waern  2006
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.ModuleTree (ModuleTree (..), mkModuleTree) where
+
+import Haddock.Types (MDoc)
+
+import GHC (Name)
+import GHC.Unit.Module (Module, moduleName, moduleNameString, moduleUnit, unitString)
+import GHC.Unit.State (UnitState, lookupUnit, unitPackageIdString)
+
+import qualified Control.Applicative as A
+
+data ModuleTree = Node String (Maybe Module) (Maybe String) (Maybe String) (Maybe (MDoc Name)) [ModuleTree]
+
+mkModuleTree :: UnitState -> Bool -> [(Module, Maybe (MDoc Name))] -> [ModuleTree]
+mkModuleTree state showPkgs mods =
+  foldr fn [] [(mdl, splitModule mdl, modPkg mdl, modSrcPkg mdl, short) | (mdl, short) <- mods]
+  where
+    modPkg mod_
+      | showPkgs = Just (unitString (moduleUnit mod_))
+      | otherwise = Nothing
+    modSrcPkg mod_
+      | showPkgs =
+          fmap
+            unitPackageIdString
+            (lookupUnit state (moduleUnit mod_))
+      | otherwise = Nothing
+    fn (m, mod_, pkg, srcPkg, short) = addToTrees mod_ m pkg srcPkg short
+
+addToTrees :: [String] -> Module -> Maybe String -> Maybe String -> Maybe (MDoc Name) -> [ModuleTree] -> [ModuleTree]
+addToTrees [] _ _ _ _ ts = ts
+addToTrees ss m pkg srcPkg short [] = mkSubTree ss m pkg srcPkg short
+addToTrees (s1 : ss) m pkg srcPkg short (t@(Node s2 leaf node_pkg node_srcPkg node_short subs) : ts)
+  | s1 > s2 = t : addToTrees (s1 : ss) m pkg srcPkg short ts
+  | s1 == s2 = Node s2 (leaf A.<|> (if null ss then Just m else Nothing)) this_pkg this_srcPkg this_short (addToTrees ss m pkg srcPkg short subs) : ts
+  | otherwise = mkSubTree (s1 : ss) m pkg srcPkg short ++ t : ts
+  where
+    this_pkg = if null ss then pkg else node_pkg
+    this_srcPkg = if null ss then srcPkg else node_srcPkg
+    this_short = if null ss then short else node_short
+
+mkSubTree :: [String] -> Module -> Maybe String -> Maybe String -> Maybe (MDoc Name) -> [ModuleTree]
+mkSubTree [] _ _ _ _ = []
+mkSubTree [s] m pkg srcPkg short = [Node s (Just m) pkg srcPkg short []]
+mkSubTree (s : s' : ss) m pkg srcPkg short = [Node s Nothing Nothing Nothing Nothing (mkSubTree (s' : ss) m pkg srcPkg short)]
+
+splitModule :: Module -> [String]
+splitModule mdl = split (moduleNameString (moduleName mdl))
+  where
+    split mod0 = case break (== '.') mod0 of
+      (s1, '.' : s2) -> s1 : split s2
+      (s1, _) -> [s1]
diff --git a/utils/haddock/haddock-api/src/Haddock/Options.hs b/utils/haddock/haddock-api/src/Haddock/Options.hs
new file mode 100644
index 0000000000000000000000000000000000000000..cae032a8a9cb75d95e691270398fc9b79c1600be
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Options.hs
@@ -0,0 +1,603 @@
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Options
+-- Copyright   :  (c) Simon Marlow      2003-2006,
+--                    David Waern       2006-2009,
+--                    Mateusz Kowalczyk 2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Definition of the command line interface of Haddock.
+module Haddock.Options
+  ( parseHaddockOpts
+  , Flag (..)
+  , Visibility (..)
+  , getUsage
+  , optTitle
+  , outputDir
+  , optContentsUrl
+  , optIndexUrl
+  , optCssFile
+  , optSourceCssFile
+  , sourceUrls
+  , wikiUrls
+  , baseUrl
+  , optParCount
+  , optDumpInterfaceFile
+  , optShowInterfaceFile
+  , optLaTeXStyle
+  , optMathjax
+  , qualification
+  , sinceQualification
+  , verbosity
+  , ghcFlags
+  , reexportFlags
+  , readIfaceArgs
+  , optPackageName
+  , optPackageVersion
+  , modulePackageInfo
+  , ignoredSymbols
+  ) where
+
+import Control.Applicative
+import qualified Data.Char as Char
+import Data.List (dropWhileEnd)
+import Data.Map (Map)
+import qualified Data.Map as Map
+import Data.Set (Set)
+import qualified Data.Set as Set
+import Data.Version
+import GHC (Module, moduleUnit)
+import GHC.Data.FastString
+import GHC.Unit.State
+import Haddock.Types
+import Haddock.Utils
+import System.Console.GetOpt
+import qualified Text.ParserCombinators.ReadP as RP
+
+data Flag
+  = Flag_BuiltInThemes
+  | Flag_CSS String
+  | --  | Flag_DocBook
+    Flag_ReadInterface String
+  | Flag_DumpInterface String
+  | Flag_ShowInterface String
+  | Flag_Heading String
+  | Flag_Html
+  | Flag_Hoogle
+  | Flag_Lib String
+  | Flag_OutputDir FilePath
+  | Flag_Prologue FilePath
+  | Flag_SourceBaseURL String
+  | Flag_SourceModuleURL String
+  | Flag_SourceEntityURL String
+  | Flag_SourceLEntityURL String
+  | Flag_WikiBaseURL String
+  | Flag_BaseURL String
+  | Flag_WikiModuleURL String
+  | Flag_WikiEntityURL String
+  | Flag_LaTeX
+  | Flag_LaTeXStyle String
+  | Flag_QuickJumpIndex
+  | Flag_HyperlinkedSource
+  | Flag_SourceCss String
+  | Flag_Mathjax String
+  | Flag_Help
+  | Flag_Verbosity String
+  | Flag_Version
+  | Flag_CompatibleInterfaceVersions
+  | Flag_InterfaceVersion
+  | Flag_BypassInterfaceVersonCheck
+  | Flag_UseContents String
+  | Flag_GenContents
+  | Flag_UseIndex String
+  | Flag_GenIndex
+  | Flag_IgnoreAllExports
+  | Flag_HideModule String
+  | Flag_ShowModule String
+  | Flag_ShowAllModules
+  | Flag_ShowExtensions String
+  | Flag_OptGhc String
+  | Flag_GhcLibDir String
+  | Flag_GhcVersion
+  | Flag_PrintGhcPath
+  | Flag_PrintGhcLibDir
+  | Flag_NoWarnings
+  | Flag_UseUnicode
+  | Flag_NoTmpCompDir
+  | Flag_Qualification String
+  | Flag_PrettyHtml
+  | Flag_NoPrintMissingDocs
+  | Flag_PackageName String
+  | Flag_PackageVersion String
+  | Flag_Reexport String
+  | Flag_SinceQualification String
+  | Flag_IgnoreLinkSymbol String
+  | Flag_ParCount (Maybe Int)
+  | Flag_TraceArgs
+  deriving (Eq, Show)
+
+options :: Bool -> [OptDescr Flag]
+options backwardsCompat =
+  [ Option
+      ['B']
+      []
+      (ReqArg Flag_GhcLibDir "DIR")
+      "path to a GHC lib dir, to override the default path"
+  , Option
+      ['o']
+      ["odir"]
+      (ReqArg Flag_OutputDir "DIR")
+      "directory in which to put the output files"
+  , Option
+      ['l']
+      ["lib"]
+      (ReqArg Flag_Lib "DIR")
+      "location of Haddock's auxiliary files"
+  , Option
+      ['i']
+      ["read-interface"]
+      (ReqArg Flag_ReadInterface "FILE")
+      "read an interface from FILE"
+  , Option
+      ['D']
+      ["dump-interface"]
+      (ReqArg Flag_DumpInterface "FILE")
+      "write the resulting interface to FILE"
+  , Option
+      []
+      ["show-interface"]
+      (ReqArg Flag_ShowInterface "FILE")
+      "print the interface in a human readable form"
+  , --    Option ['S']  ["docbook"]  (NoArg Flag_DocBook)
+    --  "output in DocBook XML",
+    Option
+      ['h']
+      ["html"]
+      (NoArg Flag_Html)
+      "output in HTML (XHTML 1.0)"
+  , Option [] ["latex"] (NoArg Flag_LaTeX) "use experimental LaTeX rendering"
+  , Option [] ["latex-style"] (ReqArg Flag_LaTeXStyle "FILE") "provide your own LaTeX style in FILE"
+  , Option [] ["mathjax"] (ReqArg Flag_Mathjax "URL") "URL FOR mathjax"
+  , Option ['U'] ["use-unicode"] (NoArg Flag_UseUnicode) "use Unicode in HTML output"
+  , Option
+      []
+      ["hoogle"]
+      (NoArg Flag_Hoogle)
+      "output for Hoogle; you may want --package-name and --package-version too"
+  , Option
+      []
+      ["quickjump"]
+      (NoArg Flag_QuickJumpIndex)
+      "generate an index for interactive documentation navigation"
+  , Option
+      []
+      ["hyperlinked-source"]
+      (NoArg Flag_HyperlinkedSource)
+      "generate highlighted and hyperlinked source code (for use with --html)"
+  , Option
+      []
+      ["source-css"]
+      (ReqArg Flag_SourceCss "FILE")
+      "use custom CSS file instead of default one in hyperlinked source"
+  , Option
+      []
+      ["source-base"]
+      (ReqArg Flag_SourceBaseURL "URL")
+      "URL for a source code link on the contents\nand index pages"
+  , Option
+      ['s']
+      (if backwardsCompat then ["source", "source-module"] else ["source-module"])
+      (ReqArg Flag_SourceModuleURL "URL")
+      "URL for a source code link for each module\n(using the %{FILE} or %{MODULE} vars)"
+  , Option
+      []
+      ["source-entity"]
+      (ReqArg Flag_SourceEntityURL "URL")
+      "URL for a source code link for each entity\n(using the %{FILE}, %{MODULE}, %{NAME},\n%{KIND} or %{LINE} vars)"
+  , Option
+      []
+      ["source-entity-line"]
+      (ReqArg Flag_SourceLEntityURL "URL")
+      "URL for a source code link for each entity.\nUsed if name links are unavailable, eg. for TH splices."
+  , Option
+      []
+      ["comments-base"]
+      (ReqArg Flag_WikiBaseURL "URL")
+      "URL for a comments link on the contents\nand index pages"
+  , Option
+      []
+      ["base-url"]
+      (ReqArg Flag_BaseURL "URL")
+      "Base URL for static assets (eg. css, javascript, json files etc.).\nWhen given statis assets will not be copied."
+  , Option
+      []
+      ["comments-module"]
+      (ReqArg Flag_WikiModuleURL "URL")
+      "URL for a comments link for each module\n(using the %{MODULE} var)"
+  , Option
+      []
+      ["comments-entity"]
+      (ReqArg Flag_WikiEntityURL "URL")
+      "URL for a comments link for each entity\n(using the %{FILE}, %{MODULE}, %{NAME},\n%{KIND} or %{LINE} vars)"
+  , Option
+      ['c']
+      ["css", "theme"]
+      (ReqArg Flag_CSS "PATH")
+      "the CSS file or theme directory to use for HTML output"
+  , Option
+      []
+      ["built-in-themes"]
+      (NoArg Flag_BuiltInThemes)
+      "include all the built-in haddock themes"
+  , Option
+      ['p']
+      ["prologue"]
+      (ReqArg Flag_Prologue "FILE")
+      "file containing prologue text"
+  , Option
+      ['t']
+      ["title"]
+      (ReqArg Flag_Heading "TITLE")
+      "page heading"
+  , Option
+      ['q']
+      ["qual"]
+      (ReqArg Flag_Qualification "QUAL")
+      "qualification of names, one of \n'none' (default), 'full', 'local'\n'relative' or 'aliased'"
+  , Option
+      ['?']
+      ["help"]
+      (NoArg Flag_Help)
+      "display this help and exit"
+  , Option
+      ['V']
+      ["version"]
+      (NoArg Flag_Version)
+      "output version information and exit"
+  , Option
+      []
+      ["compatible-interface-versions"]
+      (NoArg Flag_CompatibleInterfaceVersions)
+      "output compatible interface file versions and exit"
+  , Option
+      []
+      ["interface-version"]
+      (NoArg Flag_InterfaceVersion)
+      "output interface file version and exit"
+  , Option
+      []
+      ["bypass-interface-version-check"]
+      (NoArg Flag_BypassInterfaceVersonCheck)
+      "bypass the interface file version check (dangerous)"
+  , Option
+      ['v']
+      ["verbosity"]
+      (ReqArg Flag_Verbosity "VERBOSITY")
+      "set verbosity level"
+  , Option
+      []
+      ["use-contents"]
+      (ReqArg Flag_UseContents "URL")
+      "use a separately-generated HTML contents page"
+  , Option
+      []
+      ["gen-contents"]
+      (NoArg Flag_GenContents)
+      "generate an HTML contents from specified\ninterfaces"
+  , Option
+      []
+      ["use-index"]
+      (ReqArg Flag_UseIndex "URL")
+      "use a separately-generated HTML index"
+  , Option
+      []
+      ["gen-index"]
+      (NoArg Flag_GenIndex)
+      "generate an HTML index from specified\ninterfaces"
+  , Option
+      []
+      ["ignore-all-exports"]
+      (NoArg Flag_IgnoreAllExports)
+      "behave as if all modules have the\nignore-exports attribute"
+  , Option
+      []
+      ["hide"]
+      (ReqArg Flag_HideModule "MODULE")
+      "behave as if MODULE has the hide attribute"
+  , Option
+      []
+      ["show"]
+      (ReqArg Flag_ShowModule "MODULE")
+      "behave as if MODULE does not have the hide attribute"
+  , Option
+      []
+      ["show-all"]
+      (NoArg Flag_ShowAllModules)
+      "behave as if not modules have the hide attribute"
+  , Option
+      []
+      ["show-extensions"]
+      (ReqArg Flag_ShowExtensions "MODULE")
+      "behave as if MODULE has the show-extensions attribute"
+  , Option
+      []
+      ["optghc"]
+      (ReqArg Flag_OptGhc "OPTION")
+      "option to be forwarded to GHC"
+  , Option
+      []
+      ["ghc-version"]
+      (NoArg Flag_GhcVersion)
+      "output GHC version in numeric format"
+  , Option
+      []
+      ["print-ghc-path"]
+      (NoArg Flag_PrintGhcPath)
+      "output path to GHC binary"
+  , Option
+      []
+      ["print-ghc-libdir"]
+      (NoArg Flag_PrintGhcLibDir)
+      "output GHC lib dir"
+  , Option ['w'] ["no-warnings"] (NoArg Flag_NoWarnings) "turn off all warnings"
+  , Option
+      []
+      ["no-tmp-comp-dir"]
+      (NoArg Flag_NoTmpCompDir)
+      "do not re-direct compilation output to a temporary directory"
+  , Option
+      []
+      ["pretty-html"]
+      (NoArg Flag_PrettyHtml)
+      "generate html with newlines and indenting (for use with --html)"
+  , Option
+      []
+      ["no-print-missing-docs"]
+      (NoArg Flag_NoPrintMissingDocs)
+      "don't print information about any undocumented entities"
+  , Option
+      []
+      ["reexport"]
+      (ReqArg Flag_Reexport "MOD")
+      "reexport the module MOD, adding it to the index"
+  , Option
+      []
+      ["package-name"]
+      (ReqArg Flag_PackageName "NAME")
+      "name of the package being documented"
+  , Option
+      []
+      ["package-version"]
+      (ReqArg Flag_PackageVersion "VERSION")
+      "version of the package being documented in usual x.y.z.w format"
+  , Option
+      []
+      ["since-qual"]
+      (ReqArg Flag_SinceQualification "QUAL")
+      "package qualification of @since, one of\n'always' (default) or 'only-external'"
+  , Option
+      []
+      ["ignore-link-symbol"]
+      (ReqArg Flag_IgnoreLinkSymbol "SYMBOL")
+      "name of a symbol which does not trigger a warning in case of link issue"
+  , Option
+      ['j']
+      []
+      (OptArg (\count -> Flag_ParCount (fmap read count)) "n")
+      "load modules in parallel"
+  , Option
+      []
+      ["trace-args"]
+      (NoArg Flag_TraceArgs)
+      "print the arguments provided for this invocation to stdout"
+  ]
+
+getUsage :: IO String
+getUsage = do
+  prog <- getProgramName
+  return $ usageInfo (usageHeader prog) (options False)
+  where
+    usageHeader :: String -> String
+    usageHeader prog = "Usage: " ++ prog ++ " [OPTION...] file...\n"
+
+parseHaddockOpts :: [String] -> IO ([Flag], [String])
+parseHaddockOpts params =
+  case getOpt Permute (options True) params of
+    (flags, args, []) -> return (flags, args)
+    (_, _, errors) -> do
+      usage <- getUsage
+      throwE (concat errors ++ usage)
+
+optPackageVersion :: [Flag] -> Maybe Data.Version.Version
+optPackageVersion flags =
+  let ver = optLast [v | Flag_PackageVersion v <- flags]
+   in ver >>= fmap fst . optLast . RP.readP_to_S parseVersion
+
+optPackageName :: [Flag] -> Maybe PackageName
+optPackageName flags =
+  optLast [PackageName $ mkFastString n | Flag_PackageName n <- flags]
+
+optTitle :: [Flag] -> Maybe String
+optTitle flags =
+  case [str | Flag_Heading str <- flags] of
+    [] -> Nothing
+    (t : _) -> Just t
+
+outputDir :: [Flag] -> FilePath
+outputDir flags =
+  case [path | Flag_OutputDir path <- flags] of
+    [] -> "."
+    paths -> last paths
+
+optContentsUrl :: [Flag] -> Maybe String
+optContentsUrl flags = optLast [url | Flag_UseContents url <- flags]
+
+optIndexUrl :: [Flag] -> Maybe String
+optIndexUrl flags = optLast [url | Flag_UseIndex url <- flags]
+
+optCssFile :: [Flag] -> Maybe FilePath
+optCssFile flags = optLast [str | Flag_CSS str <- flags]
+
+optSourceCssFile :: [Flag] -> Maybe FilePath
+optSourceCssFile flags = optLast [str | Flag_SourceCss str <- flags]
+
+sourceUrls :: [Flag] -> (Maybe String, Maybe String, Maybe String, Maybe String)
+sourceUrls flags =
+  ( optLast [str | Flag_SourceBaseURL str <- flags]
+  , optLast [str | Flag_SourceModuleURL str <- flags]
+  , optLast [str | Flag_SourceEntityURL str <- flags]
+  , optLast [str | Flag_SourceLEntityURL str <- flags]
+  )
+
+wikiUrls :: [Flag] -> (Maybe String, Maybe String, Maybe String)
+wikiUrls flags =
+  ( optLast [str | Flag_WikiBaseURL str <- flags]
+  , optLast [str | Flag_WikiModuleURL str <- flags]
+  , optLast [str | Flag_WikiEntityURL str <- flags]
+  )
+
+baseUrl :: [Flag] -> Maybe String
+baseUrl flags = optLast [str | Flag_BaseURL str <- flags]
+
+optDumpInterfaceFile :: [Flag] -> Maybe FilePath
+optDumpInterfaceFile flags = optLast [str | Flag_DumpInterface str <- flags]
+
+optShowInterfaceFile :: [Flag] -> Maybe FilePath
+optShowInterfaceFile flags = optLast [str | Flag_ShowInterface str <- flags]
+
+optLaTeXStyle :: [Flag] -> Maybe String
+optLaTeXStyle flags = optLast [str | Flag_LaTeXStyle str <- flags]
+
+optMathjax :: [Flag] -> Maybe String
+optMathjax flags = optLast [str | Flag_Mathjax str <- flags]
+
+optParCount :: [Flag] -> Maybe (Maybe Int)
+optParCount flags = optLast [n | Flag_ParCount n <- flags]
+
+qualification :: [Flag] -> Either String QualOption
+qualification flags =
+  case map (map Char.toLower) [str | Flag_Qualification str <- flags] of
+    [] -> Right OptNoQual
+    ["none"] -> Right OptNoQual
+    ["full"] -> Right OptFullQual
+    ["local"] -> Right OptLocalQual
+    ["relative"] -> Right OptRelativeQual
+    [arg] -> Left $ "unknown qualification type " ++ show arg
+    _ : _ -> Left "qualification option given multiple times"
+
+sinceQualification :: [Flag] -> Either String SinceQual
+sinceQualification flags =
+  case map (map Char.toLower) [str | Flag_SinceQualification str <- flags] of
+    [] -> Right Always
+    ["always"] -> Right Always
+    ["external"] -> Right External
+    [arg] -> Left $ "unknown since-qualification type " ++ show arg
+    _ : _ -> Left "since-qualification option given multiple times"
+
+verbosity :: [Flag] -> Verbosity
+verbosity flags =
+  case [str | Flag_Verbosity str <- flags] of
+    [] -> Normal
+    x : _ -> case parseVerbosity x of
+      Left e -> throwE e
+      Right v -> v
+
+-- | Get the ignored symbols from the given flags. These are the symbols for
+-- which no link warnings will be generated if their link destinations cannot be
+-- determined.
+--
+-- Symbols may be provided as qualified or unqualified names (e.g.
+-- 'Data.Map.dropWhileEnd' or 'dropWhileEnd', resp). If qualified, no link
+-- warnings will be produced for occurances of that name when it is imported
+-- from that module. If unqualified, no link warnings will be produced for any
+-- occurances of that name from any module.
+ignoredSymbols :: [Flag] -> Map (Maybe String) (Set String)
+ignoredSymbols flags =
+  foldr addToMap Map.empty [splitSymbol symbol | Flag_IgnoreLinkSymbol symbol <- flags]
+  where
+    -- Split a symbol into its module name and unqualified name, producing
+    -- 'Nothing' for the module name if the given symbol is already unqualified
+    splitSymbol :: String -> (Maybe String, String)
+    splitSymbol s =
+      -- Drop the longest suffix not containing a '.' character
+      case dropWhileEnd (/= '.') s of
+        -- If the longest suffix is empty, there was no '.'.
+        -- Assume it is an unqualified name (no module string).
+        "" -> (Nothing, s)
+        -- If the longest suffix is not empty, there was a '.'.
+        -- Assume it is a qualified name. `s'` will be the module string followed
+        -- by the last '.', e.g. "Data.List.", so take `init s'` as the module
+        -- string. Drop the length of `s'` from the original string `s` to
+        -- obtain to the unqualified name.
+        s' -> (Just $ init s', drop (length s') s)
+
+    -- Add a (module name, name) pair to the map from modules to their ignored
+    -- symbols
+    addToMap :: (Maybe String, String) -> Map (Maybe String) (Set String) -> Map (Maybe String) (Set String)
+    addToMap (m, name) symbs = Map.insertWith (Set.union) m (Set.singleton name) symbs
+
+ghcFlags :: [Flag] -> [String]
+ghcFlags flags = [option | Flag_OptGhc option <- flags]
+
+reexportFlags :: [Flag] -> [String]
+reexportFlags flags = [option | Flag_Reexport option <- flags]
+
+data Visibility = Visible | Hidden
+  deriving (Eq, Show)
+
+readIfaceArgs :: [Flag] -> [(DocPaths, Visibility, FilePath)]
+readIfaceArgs flags = [parseIfaceOption s | Flag_ReadInterface s <- flags]
+  where
+    parseIfaceOption :: String -> (DocPaths, Visibility, FilePath)
+    parseIfaceOption str =
+      case break (== ',') str of
+        (fpath, ',' : rest) ->
+          case break (== ',') rest of
+            (src, ',' : rest') ->
+              let src' = case src of
+                    "" -> Nothing
+                    _ -> Just src
+               in case break (== ',') rest' of
+                    (visibility, ',' : file)
+                      | visibility == "hidden" ->
+                          ((fpath, src'), Hidden, file)
+                      | otherwise ->
+                          ((fpath, src'), Visible, file)
+                    (file, _) ->
+                      ((fpath, src'), Visible, file)
+            (file, _) -> ((fpath, Nothing), Visible, file)
+        (file, _) -> (("", Nothing), Visible, file)
+
+-- | Like 'listToMaybe' but returns the last element instead of the first.
+optLast :: [a] -> Maybe a
+optLast [] = Nothing
+optLast xs = Just (last xs)
+
+-- | This function has a potential to return 'Nothing' because package name and
+-- versions can no longer reliably be extracted in all cases: if the package is
+-- not installed yet then this info is no longer available.
+--
+-- The @--package-name@ and @--package-version@ Haddock flags allow the user to
+-- specify this information manually and it is returned here if present.
+modulePackageInfo
+  :: UnitState
+  -> [Flag]
+  -- ^ Haddock flags are checked as they may contain
+  -- the package name or version provided by the user
+  -- which we prioritise
+  -> Maybe Module
+  -> (Maybe PackageName, Maybe Data.Version.Version)
+modulePackageInfo _unit_state _flags Nothing = (Nothing, Nothing)
+modulePackageInfo unit_state flags (Just modu) =
+  ( optPackageName flags <|> fmap unitPackageName pkgDb
+  , optPackageVersion flags <|> fmap unitPackageVersion pkgDb
+  )
+  where
+    pkgDb = lookupUnit unit_state (moduleUnit modu)
diff --git a/utils/haddock/haddock-api/src/Haddock/Parser.hs b/utils/haddock/haddock-api/src/Haddock/Parser.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e3edfc224607f331e8e318f2a3b43e0800476201
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Parser.hs
@@ -0,0 +1,57 @@
+-- |
+-- Module      :  Haddock.Parser
+-- Copyright   :  (c) Mateusz Kowalczyk 2013,
+--                    Simon Hengel      2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Parser
+  ( parseParas
+  , parseString
+  , parseIdent
+  ) where
+
+import qualified Documentation.Haddock.Parser as P
+import Documentation.Haddock.Types
+import Haddock.Types
+
+import GHC.Data.FastString (fsLit)
+import GHC.Data.StringBuffer (stringToStringBuffer)
+import GHC.Driver.Config.Parser (initParserOpts)
+import GHC.Driver.Session (DynFlags)
+import GHC.Parser (parseIdentifier)
+import GHC.Parser.Lexer (ParseResult (PFailed, POk), initParserState, unP)
+import GHC.Types.Name.Occurrence (occNameString)
+import GHC.Types.Name.Reader (RdrName (..))
+import GHC.Types.SrcLoc (GenLocated (..), mkRealSrcLoc)
+
+parseParas :: DynFlags -> Maybe Package -> String -> MetaDoc mod (Wrap NsRdrName)
+parseParas d p = overDoc (P.overIdentifier (parseIdent d)) . P.parseParas p
+
+parseString :: DynFlags -> String -> DocH mod (Wrap NsRdrName)
+parseString d = P.overIdentifier (parseIdent d) . P.parseString
+
+parseIdent :: DynFlags -> Namespace -> String -> Maybe (Wrap NsRdrName)
+parseIdent dflags ns str0 =
+  case unP parseIdentifier (pstate str1) of
+    POk _ (L _ name)
+      -- Guards against things like 'Q.--', 'Q.case', etc.
+      -- See https://github.com/haskell/haddock/issues/952 and Trac #14109
+      | Qual _ occ <- name
+      , PFailed{} <- unP parseIdentifier (pstate (occNameString occ)) ->
+          Nothing
+      | otherwise ->
+          Just (wrap (NsRdrName ns name))
+    PFailed{} -> Nothing
+  where
+    realSrcLc = mkRealSrcLoc (fsLit "<unknown file>") 0 0
+    pstate str = initParserState (initParserOpts dflags) (stringToStringBuffer str) realSrcLc
+    (wrap, str1) = case str0 of
+      '(' : s@(c : _)
+        | c /= ','
+        , c /= ')' -> -- rule out tuple names
+            (Parenthesized, init s)
+      '`' : s@(_ : _) -> (Backticked, init s)
+      _ -> (Unadorned, str0)
diff --git a/utils/haddock/haddock-api/src/Haddock/Types.hs b/utils/haddock/haddock-api/src/Haddock/Types.hs
new file mode 100644
index 0000000000000000000000000000000000000000..91795b908b4c6b2c582b46297c383bd7c7d87774
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Types.hs
@@ -0,0 +1,1074 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE ConstraintKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE DeriveTraversable #-}
+{-# LANGUAGE DerivingStrategies #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedRecordDot #-}
+{-# LANGUAGE PartialTypeSignatures #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeOperators #-}
+-- Note [Pass sensitive types]
+{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Types
+-- Copyright   :  (c) Simon Marlow      2003-2006,
+--                    David Waern       2006-2009,
+--                    Mateusz Kowalczyk 2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskellorg
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Types that are commonly used through-out Haddock. Some of the most
+-- important types are defined here, like 'Interface' and 'DocName'.
+module Haddock.Types
+  ( module Haddock.Types
+  , HsDocString
+  , LHsDocString
+  , Fixity (..)
+  , module Documentation.Haddock.Types
+  ) where
+
+import Control.DeepSeq
+import Control.Exception (throw)
+import Control.Monad.Catch
+import Control.Monad.State.Strict
+import Data.Data (Data)
+import Data.Map (Map)
+import qualified Data.Set as Set
+import Data.Typeable (Typeable)
+import Documentation.Haddock.Types
+import qualified GHC.Data.Strict as Strict
+import GHC.Types.Fixity (Fixity (..))
+import GHC.Types.Name (stableNameCmp)
+import GHC.Types.Name.Reader (RdrName (..))
+import GHC.Types.SrcLoc (BufPos (..), BufSpan (..))
+import GHC.Types.Var (Specificity)
+
+import GHC
+import GHC.Driver.Session (Language)
+import qualified GHC.LanguageExtensions as LangExt
+import GHC.Types.Name.Occurrence
+import GHC.Utils.Outputable
+
+-----------------------------------------------------------------------------
+
+-- * Convenient synonyms
+
+-----------------------------------------------------------------------------
+
+type IfaceMap = Map Module Interface
+type InstIfaceMap = Map Module InstalledInterface -- TODO: rename
+type DocMap a = Map Name (MDoc a)
+type ArgMap a = Map Name (Map Int (MDoc a))
+type SubMap = Map Name [Name]
+type DeclMap = Map Name DeclMapEntry
+type InstMap = Map RealSrcSpan Name
+type FixMap = Map Name Fixity
+type DocPaths = (FilePath, Maybe FilePath) -- paths to HTML and sources
+type WarningMap = Map Name (Doc Name)
+
+-----------------------------------------------------------------------------
+
+-- * Interfaces and Interface creation
+
+-----------------------------------------------------------------------------
+
+-- | 'Interface' holds all information used to render a single Haddock page.
+-- It represents the /interface/ of a module. The core business of Haddock
+-- lies in creating this structure. Note that the record contains some fields
+-- that are only used to create the final record, and that are not used by the
+-- backends.
+data Interface = Interface
+  { ifaceMod :: !Module
+  -- ^ The module behind this interface.
+  , ifaceIsSig :: !Bool
+  -- ^ Is this a signature?
+  , ifaceInfo :: !(HaddockModInfo Name)
+  -- ^ Textual information about the module.
+  , ifaceDoc :: !(Documentation Name)
+  -- ^ Documentation header.
+  , ifaceRnDoc :: !(Documentation DocName)
+  -- ^ Documentation header with cross-reference information.
+  , ifaceOptions :: [DocOption]
+  -- ^ Haddock options for this module (prune, ignore-exports, etc).
+  , ifaceDocMap :: !(DocMap Name)
+  -- ^ Documentation of declarations originating from the module (including
+  -- subordinates).
+  , ifaceArgMap :: !(ArgMap Name)
+  , ifaceDefMeths :: !([(OccName, Name)])
+  -- ^ The names of all the default methods for classes defined in this module
+  , ifaceFixMap :: !(Map Name Fixity)
+  , ifaceExportItems :: [ExportItem GhcRn]
+  , ifaceRnExportItems :: [ExportItem DocNameI]
+  , ifaceExports :: [Name]
+  -- ^ All names exported by the module.
+  , ifaceVisibleExports :: [Name]
+  -- ^ All \"visible\" names exported by the module.
+  -- A visible name is a name that will show up in the documentation of the
+  -- module.
+  --
+  -- Names from modules that are entirely re-exported don't count as visible.
+  , ifaceInstances :: [ClsInst]
+  -- ^ Instances exported by the module.
+  , ifaceOrphanInstances :: [DocInstance GhcRn]
+  -- ^ Orphan instances
+  , ifaceRnOrphanInstances :: [DocInstance DocNameI]
+  , ifaceHaddockCoverage :: (Int, Int)
+  -- ^ The number of haddockable and haddocked items in the module, as a
+  -- tuple. Haddockable items are the exports and the module itself.
+  , ifaceWarningMap :: WarningMap
+  -- ^ Warnings for things defined in this module.
+  , ifaceHieFile :: !FilePath
+  -- ^ Tokenized source code of module (available if Haddock is invoked with
+  -- source generation flag).
+  , ifaceDynFlags :: !DynFlags
+  }
+
+-- | A subset of the fields of 'Interface' that we store in the interface
+-- files.
+data InstalledInterface = InstalledInterface
+  { instMod :: Module
+  -- ^ The module represented by this interface.
+  , instIsSig :: Bool
+  -- ^ Is this a signature?
+  , instInfo :: HaddockModInfo Name
+  -- ^ Textual information about the module.
+  , instDocMap :: DocMap Name
+  -- ^ Documentation of declarations originating from the module (including
+  -- subordinates).
+  , instArgMap :: ArgMap Name
+  , instDefMeths :: [(OccName, Name)]
+  -- ^ The names of all the default methods for classes defined in this module
+  , instExports :: [Name]
+  -- ^ All names exported by this module.
+  , instVisibleExports :: [Name]
+  -- ^ All \"visible\" names exported by the module.
+  -- A visible name is a name that will show up in the documentation of the
+  -- module.
+  , instOptions :: [DocOption]
+  -- ^ Haddock options for this module (prune, ignore-exports, etc).
+  , instFixMap :: Map Name Fixity
+  }
+
+-- | Convert an 'Interface' to an 'InstalledInterface'
+toInstalledIface :: Interface -> InstalledInterface
+toInstalledIface interface =
+  InstalledInterface
+    { instMod = interface.ifaceMod
+    , instIsSig = interface.ifaceIsSig
+    , instInfo = interface.ifaceInfo
+    , instDocMap = interface.ifaceDocMap
+    , instArgMap = interface.ifaceArgMap
+    , instExports = interface.ifaceExports
+    , instVisibleExports = interface.ifaceVisibleExports
+    , instOptions = interface.ifaceOptions
+    , instFixMap = interface.ifaceFixMap
+    , instDefMeths = interface.ifaceDefMeths
+    }
+
+-- | A monad in which we create Haddock interfaces. Not to be confused with
+-- `GHC.Tc.Types.IfM` which is used to write GHC interfaces.
+--
+-- In the past `createInterface` was running in the `Ghc` monad but proved hard
+-- to sustain as soon as we moved over for Haddock to be a plugin. Also abstracting
+-- over the Ghc specific clarifies where side effects happen.
+newtype IfM m a = IfM {unIfM :: StateT (IfEnv m) m a}
+
+deriving newtype instance Functor m => Functor (IfM m)
+deriving newtype instance (Monad m, Applicative m) => Applicative (IfM m)
+deriving newtype instance Monad m => Monad (IfM m)
+deriving newtype instance MonadIO m => MonadIO (IfM m)
+deriving newtype instance Monad m => MonadState (IfEnv m) (IfM m)
+
+-- | Interface creation environment. The name sets are used primarily during
+-- processing of doc strings to avoid emitting the same type of warning for the
+-- same name twice. This was previously done using a Writer monad and then
+-- nubbing the list of warning messages after accumulation. This new approach
+-- was implemented to avoid the nubbing of potentially large lists of strings.
+data IfEnv m = IfEnv
+  { ifeLookupName :: Name -> m (Maybe TyThing)
+  -- ^ Lookup names in the environment.
+  , ifeOutOfScopeNames :: !(Set.Set String)
+  -- ^ Names which we have warned about for being out of scope
+  , ifeAmbiguousNames :: !(Set.Set String)
+  -- ^ Names which we have warned about for being ambiguous
+  }
+
+-- | Run an `IfM` action.
+runIfM
+  :: Monad m
+  => (Name -> m (Maybe TyThing))
+  -- ^ Lookup a global name in the current session. Used in cases
+  -- where declarations don't
+  -> IfM m a
+  -- ^ The action to run.
+  -> m a
+  -- ^ Result and accumulated error/warning messages.
+runIfM lookup_name action = do
+  let
+    if_env =
+      IfEnv
+        { ifeLookupName = lookup_name
+        , ifeOutOfScopeNames = Set.empty
+        , ifeAmbiguousNames = Set.empty
+        }
+  evalStateT (unIfM action) if_env
+
+-- | Look up a name in the current environment
+lookupName :: Monad m => Name -> IfM m (Maybe TyThing)
+lookupName name = IfM $ do
+  lookup_name <- gets ifeLookupName
+  lift (lookup_name name)
+
+-- | Very basic logging function that simply prints to stdout
+warn :: MonadIO m => String -> IfM m ()
+warn msg = liftIO $ putStrLn msg
+
+-----------------------------------------------------------------------------
+
+-- * Export items & declarations
+
+-----------------------------------------------------------------------------
+
+data ExportItem name
+  = -- | An exported declaration.
+    ExportDecl (XExportDecl name)
+  | -- | An exported entity for which we have no documentation (perhaps because it
+    -- resides in another package).
+    ExportNoDecl
+      { expItemName :: !(IdP name)
+      , expItemSubs :: [IdP name]
+      -- ^ Subordinate names.
+      }
+  | -- | A section heading.
+    ExportGroup
+      { expItemSectionLevel :: !Int
+      -- ^ Section level (1, 2, 3, ...).
+      , expItemSectionId :: !String
+      -- ^ Section id (for hyperlinks).
+      , expItemSectionText :: !(Doc (IdP name))
+      -- ^ Section heading text.
+      }
+  | -- | Some documentation.
+    ExportDoc !(MDoc (IdP name))
+  | -- | A cross-reference to another module.
+    ExportModule !Module
+
+-- | A type family mapping a name type index to types of export declarations.
+-- The pre-renaming type index ('GhcRn') is mapped to the type of export
+-- declarations which do not include Hoogle output ('ExportD'), since Hoogle output is
+-- generated during the Haddock renaming step. The post-renaming type index
+-- ('DocNameI') is mapped to the type of export declarations which do include
+-- Hoogle output ('RnExportD').
+type family XExportDecl x where
+  XExportDecl GhcRn = ExportD GhcRn
+  XExportDecl DocNameI = RnExportD
+
+-- | Represents an export declaration that Haddock has discovered to be exported
+-- from a module. The @name@ index indicated whether the declaration has been
+-- renamed such that each 'Name' points to it's optimal link destination.
+data ExportD name = ExportD
+  { expDDecl :: !(LHsDecl name)
+  -- ^ A declaration.
+  , expDPats :: [(HsDecl name, DocForDecl (IdP name))]
+  -- ^ Bundled patterns for a data type declaration
+  , expDMbDoc :: !(DocForDecl (IdP name))
+  -- ^ Maybe a doc comment, and possibly docs for arguments (if this
+  -- decl is a function or type-synonym).
+  , expDSubDocs :: [(IdP name, DocForDecl (IdP name))]
+  -- ^ Subordinate names, possibly with documentation.
+  , expDInstances :: [DocInstance name]
+  -- ^ Instances relevant to this declaration, possibly with
+  -- documentation.
+  , expDFixities :: [(IdP name, Fixity)]
+  -- ^ Fixity decls relevant to this declaration (including subordinates).
+  , expDSpliced :: !Bool
+  -- ^ Whether the ExportD is from a TH splice or not, for generating
+  -- the appropriate type of Source link.
+  }
+
+-- | Represents export declarations that have undergone renaming such that every
+-- 'Name' in the declaration points to an optimal link destination. Since Hoogle
+-- output is also generated during the renaming step, each declaration is also
+-- attached to its Hoogle textual database entries, /if/ Hoogle output is
+-- enabled and the module is not hidden in the generated documentation using the
+-- @{-# OPTIONS_HADDOCK hide #-}@ pragma.
+data RnExportD = RnExportD
+  { rnExpDExpD :: !(ExportD DocNameI)
+  -- ^ The renamed export declaration
+  , rnExpDHoogle :: [String]
+  -- ^ If Hoogle textbase (textual database) output is enabled, the text
+  -- output lines for this declaration. If Hoogle output is not enabled, the
+  -- list will be empty.
+  }
+
+data Documentation name = Documentation
+  { documentationDoc :: Maybe (MDoc name)
+  , documentationWarning :: Maybe (Doc name)
+  }
+  deriving (Functor)
+
+instance NFData name => NFData (Documentation name) where
+  rnf (Documentation d w) = d `deepseq` w `deepseq` ()
+
+-- | Arguments and result are indexed by Int, zero-based from the left,
+-- because that's the easiest to use when recursing over types.
+type FnArgsDoc name = Map Int (MDoc name)
+
+type DocForDecl name = (Documentation name, FnArgsDoc name)
+
+noDocForDecl :: DocForDecl name
+noDocForDecl = (Documentation Nothing Nothing, mempty)
+
+-- | As we build the declaration map, we really only care to track whether we
+-- have only seen a value declaration for a 'Name', or anything else. This type
+-- is used to represent those cases. If the only declaration attached to a
+-- 'Name' is a 'ValD', we will consult the GHC interface file to determine the
+-- type of the value, and attach the 'SrcSpan' from the 'EValD' constructor to
+-- it. If we see any other type of declaration for the 'Name', we can just use
+-- it.
+--
+-- This type saves us from storing /every/ declaration we see for a given 'Name'
+-- in the map, which is unnecessary and very problematic for overall memory
+-- usage.
+data DeclMapEntry
+  = EValD !SrcSpan
+  | EOther (LHsDecl GhcRn)
+
+instance Semigroup DeclMapEntry where
+  (EValD _) <> e = e
+  e <> _ = e
+
+-- | Transform a declaration into a 'DeclMapEntry'. If it is a 'ValD'
+-- declaration, only the source location will be noted (since that is all we
+-- care to store in the 'DeclMap' due to the way top-level bindings with no type
+-- signatures are handled). Otherwise, the entire declaration will be kept.
+toDeclMapEntry :: LHsDecl GhcRn -> DeclMapEntry
+toDeclMapEntry (L l (ValD _ _)) = EValD (locA l)
+toDeclMapEntry d = EOther d
+
+-----------------------------------------------------------------------------
+
+-- * Cross-referencing
+
+-----------------------------------------------------------------------------
+
+-- | Type of environment used to cross-reference identifiers in the syntax.
+type LinkEnv = Map Name Module
+
+-- | An 'RdrName' tagged with some type/value namespace information.
+data NsRdrName = NsRdrName
+  { namespace :: !Namespace
+  , rdrName :: !RdrName
+  }
+
+instance NFData NsRdrName where
+  rnf (NsRdrName ns rdrN) = ns `seq` rdrN `deepseq` ()
+
+-- | Extends 'Name' with cross-reference information.
+data DocName
+  = -- | This thing is part of the (existing or resulting)
+    -- documentation. The 'Module' is the preferred place
+    -- in the documentation to refer to.
+    Documented Name Module
+  | -- | This thing is not part of the (existing or resulting)
+    -- documentation, as far as Haddock knows.
+    Undocumented Name
+  deriving (Eq, Data)
+
+data DocNameI
+
+type instance NoGhcTc DocNameI = DocNameI
+
+type instance IdP DocNameI = DocName
+
+instance CollectPass DocNameI where
+  collectXXPat _ ext = dataConCantHappen ext
+  collectXXHsBindsLR ext = dataConCantHappen ext
+  collectXSplicePat _ ext = dataConCantHappen ext
+
+instance NamedThing DocName where
+  getName (Documented name _) = name
+  getName (Undocumented name) = name
+
+-- | Useful for debugging
+instance Outputable DocName where
+  ppr = ppr . getName
+
+instance OutputableBndr DocName where
+  pprBndr _ = ppr . getName
+  pprPrefixOcc = pprPrefixOcc . getName
+  pprInfixOcc = pprInfixOcc . getName
+
+class NamedThing name => SetName name where
+  setName :: Name -> name -> name
+
+instance SetName Name where
+  setName name' _ = name'
+
+instance SetName DocName where
+  setName name' (Documented _ mdl) = Documented name' mdl
+  setName name' (Undocumented _) = Undocumented name'
+
+-- | Adds extra "wrapper" information to a name.
+--
+-- This is to work around the fact that most name types in GHC ('Name', 'RdrName',
+-- 'OccName', ...) don't include backticks or parens.
+data Wrap n
+  = -- | don't do anything to the name
+    Unadorned {unwrap :: n}
+  | -- | add parentheses around the name
+    Parenthesized {unwrap :: n}
+  | -- | add backticks around the name
+    Backticked {unwrap :: n}
+  deriving (Show, Functor, Foldable, Traversable)
+
+instance NFData n => NFData (Wrap n) where
+  rnf w = case w of
+    Unadorned n -> rnf n
+    Parenthesized n -> rnf n
+    Backticked n -> rnf n
+
+-- | Useful for debugging
+instance Outputable n => Outputable (Wrap n) where
+  ppr (Unadorned n) = ppr n
+  ppr (Parenthesized n) = hcat [char '(', ppr n, char ')']
+  ppr (Backticked n) = hcat [char '`', ppr n, char '`']
+
+showWrapped :: (a -> String) -> Wrap a -> String
+showWrapped f (Unadorned n) = f n
+showWrapped f (Parenthesized n) = "(" ++ f n ++ ")"
+showWrapped f (Backticked n) = "`" ++ f n ++ "`"
+
+instance HasOccName DocName where
+  occName = occName . getName
+
+-----------------------------------------------------------------------------
+
+-- * Instances
+
+-----------------------------------------------------------------------------
+
+-- | Stable name for stable comparisons. GHC's `Name` uses unstable
+-- ordering based on their `Unique`'s.
+newtype SName = SName Name
+  deriving newtype (NFData)
+
+instance Eq SName where
+  SName n1 == SName n2 = n1 `stableNameCmp` n2 == EQ
+
+instance Ord SName where
+  SName n1 `compare` SName n2 = n1 `stableNameCmp` n2
+
+-- | Simplified type for sorting types, ignoring qualification (not visible
+-- in Haddock output) and unifying special tycons with normal ones.
+-- For the benefit of the user (looks nice and predictable) and the
+-- tests (which prefer output to be deterministic).
+data SimpleType
+  = SimpleType SName [SimpleType]
+  | SimpleIntTyLit Integer
+  | SimpleStringTyLit String
+  | SimpleCharTyLit Char
+  deriving (Eq, Ord)
+
+instance NFData SimpleType where
+  rnf st =
+    case st of
+      SimpleType sn sts -> sn `deepseq` sts `deepseq` ()
+      SimpleIntTyLit i -> rnf i
+      SimpleStringTyLit s -> rnf s
+      SimpleCharTyLit c -> rnf c
+
+-- | The three types of instances
+data InstType name
+  = ClassInst
+      { clsiCtx :: [HsType name]
+      , clsiTyVars :: LHsQTyVars name
+      , clsiSigs :: [Sig name]
+      , clsiAssocTys :: [DocInstance name]
+      }
+  | -- | Body (right-hand side)
+    TypeInst (Maybe (HsType name))
+  | -- | Data constructors
+    DataInst (TyClDecl name)
+
+instance
+  OutputableBndrId p
+  => Outputable (InstType (GhcPass p))
+  where
+  ppr (ClassInst{..}) =
+    text "ClassInst"
+      <+> ppr clsiCtx
+      <+> ppr clsiTyVars
+      <+> ppr clsiSigs
+  ppr (TypeInst a) = text "TypeInst" <+> ppr a
+  ppr (DataInst a) = text "DataInst" <+> ppr a
+
+-- | An instance head that may have documentation and a source location.
+type DocInstance name = (InstHead name, Maybe (MDoc (IdP name)), Located (IdP name), Maybe Module)
+
+-- | The head of an instance. Consists of a class name, a list of type
+-- parameters (which may be annotated with kinds), and an instance type
+data InstHead name = InstHead
+  { ihdClsName :: IdP name
+  , ihdTypes :: [HsType name]
+  , ihdInstType :: InstType name
+  }
+
+-- | An instance origin information.
+--
+-- This is used primarily in HTML backend to generate unique instance
+-- identifiers (for expandable sections).
+data InstOrigin name
+  = OriginClass name
+  | OriginData name
+  | OriginFamily name
+
+instance NamedThing name => NamedThing (InstOrigin name) where
+  getName (OriginClass name) = getName name
+  getName (OriginData name) = getName name
+  getName (OriginFamily name) = getName name
+
+-----------------------------------------------------------------------------
+
+-- * Documentation comments
+
+-----------------------------------------------------------------------------
+
+type LDoc id = Located (Doc id)
+
+type Doc id = DocH (Wrap (ModuleName, OccName)) (Wrap id)
+type MDoc id = MetaDoc (Wrap (ModuleName, OccName)) (Wrap id)
+
+type DocMarkup id a = DocMarkupH (Wrap (ModuleName, OccName)) id a
+
+instance NFData MetaSince where
+  rnf (MetaSince v p) = v `deepseq` p `deepseq` ()
+
+instance NFData Meta where
+  rnf (Meta since) = since `deepseq` ()
+
+instance NFData id => NFData (MDoc id) where
+  rnf (MetaDoc m d) = m `deepseq` d `deepseq` ()
+
+instance
+  (NFData a, NFData mod)
+  => NFData (DocH mod a)
+  where
+  rnf doc = case doc of
+    DocEmpty -> ()
+    DocAppend a b -> a `deepseq` b `deepseq` ()
+    DocString a -> a `deepseq` ()
+    DocParagraph a -> a `deepseq` ()
+    DocIdentifier a -> a `deepseq` ()
+    DocIdentifierUnchecked a -> a `deepseq` ()
+    DocModule a -> a `deepseq` ()
+    DocWarning a -> a `deepseq` ()
+    DocEmphasis a -> a `deepseq` ()
+    DocBold a -> a `deepseq` ()
+    DocMonospaced a -> a `deepseq` ()
+    DocUnorderedList a -> a `deepseq` ()
+    DocOrderedList a -> a `deepseq` ()
+    DocDefList a -> a `deepseq` ()
+    DocCodeBlock a -> a `deepseq` ()
+    DocHyperlink a -> a `deepseq` ()
+    DocPic a -> a `deepseq` ()
+    DocMathInline a -> a `deepseq` ()
+    DocMathDisplay a -> a `deepseq` ()
+    DocAName a -> a `deepseq` ()
+    DocProperty a -> a `deepseq` ()
+    DocExamples a -> a `deepseq` ()
+    DocHeader a -> a `deepseq` ()
+    DocTable a -> a `deepseq` ()
+
+#if !MIN_VERSION_ghc(8,0,2)
+-- These were added to GHC itself in 8.0.2
+instance NFData Name where rnf x = seq x ()
+instance NFData OccName where rnf x = seq x ()
+instance NFData ModuleName where rnf x = seq x ()
+#endif
+
+instance NFData id => NFData (Header id) where
+  rnf (Header a b) = a `deepseq` b `deepseq` ()
+
+instance NFData id => NFData (Hyperlink id) where
+  rnf (Hyperlink a b) = a `deepseq` b `deepseq` ()
+
+instance NFData id => NFData (ModLink id) where
+  rnf (ModLink a b) = a `deepseq` b `deepseq` ()
+
+instance NFData Picture where
+  rnf (Picture a b) = a `deepseq` b `deepseq` ()
+
+instance NFData Example where
+  rnf (Example a b) = a `deepseq` b `deepseq` ()
+
+instance NFData id => NFData (Table id) where
+  rnf (Table h b) = h `deepseq` b `deepseq` ()
+
+instance NFData id => NFData (TableRow id) where
+  rnf (TableRow cs) = cs `deepseq` ()
+
+instance NFData id => NFData (TableCell id) where
+  rnf (TableCell i j c) = i `deepseq` j `deepseq` c `deepseq` ()
+
+exampleToString :: Example -> String
+exampleToString (Example expression result) =
+  ">>> " ++ expression ++ "\n" ++ unlines result
+
+instance NFData name => NFData (HaddockModInfo name) where
+  rnf (HaddockModInfo{..}) =
+    hmi_description `deepseq`
+      hmi_copyright `deepseq`
+        hmi_license `deepseq`
+          hmi_maintainer `deepseq`
+            hmi_stability `deepseq`
+              hmi_portability `deepseq`
+                hmi_safety `deepseq`
+                  hmi_language `deepseq`
+                    hmi_extensions `deepseq`
+                      ()
+
+instance NFData LangExt.Extension
+
+data HaddockModInfo name = HaddockModInfo
+  { hmi_description :: Maybe (Doc name)
+  , hmi_copyright :: Maybe String
+  , hmi_license :: Maybe String
+  , hmi_maintainer :: Maybe String
+  , hmi_stability :: Maybe String
+  , hmi_portability :: Maybe String
+  , hmi_safety :: Maybe String
+  , hmi_language :: Maybe Language
+  , hmi_extensions :: [LangExt.Extension]
+  }
+
+emptyHaddockModInfo :: HaddockModInfo a
+emptyHaddockModInfo =
+  HaddockModInfo
+    { hmi_description = Nothing
+    , hmi_copyright = Nothing
+    , hmi_license = Nothing
+    , hmi_maintainer = Nothing
+    , hmi_stability = Nothing
+    , hmi_portability = Nothing
+    , hmi_safety = Nothing
+    , hmi_language = Nothing
+    , hmi_extensions = []
+    }
+
+-----------------------------------------------------------------------------
+
+-- * Options
+
+-----------------------------------------------------------------------------
+
+-- | Source-level options for controlling the documentation.
+data DocOption
+  = -- | This module should not appear in the docs.
+    OptHide
+  | OptPrune
+  | -- | Pretend everything is exported.
+    OptIgnoreExports
+  | -- | Not the best place to get docs for things
+    -- exported by this module.
+    OptNotHome
+  | -- | Render enabled extensions for this module.
+    OptShowExtensions
+  | -- | Render runtime reps for this module (see
+    -- the GHC @-fprint-explicit-runtime-reps@ flag)
+    OptPrintRuntimeRep
+  deriving (Eq, Show)
+
+-- | Option controlling how to qualify names
+data QualOption
+  = -- | Never qualify any names.
+    OptNoQual
+  | -- | Qualify all names fully.
+    OptFullQual
+  | -- | Qualify all imported names fully.
+    OptLocalQual
+  | -- | Like local, but strip module prefix
+    --   from modules in the same hierarchy.
+    OptRelativeQual
+
+data Qualification
+  = NoQual
+  | FullQual
+  | LocalQual Module
+  | RelativeQual Module
+
+makeContentsQual :: QualOption -> Qualification
+makeContentsQual qual =
+  case qual of
+    OptNoQual -> NoQual
+    _ -> FullQual
+
+makeModuleQual :: QualOption -> Module -> Qualification
+makeModuleQual qual mdl =
+  case qual of
+    OptLocalQual -> LocalQual mdl
+    OptRelativeQual -> RelativeQual mdl
+    OptFullQual -> FullQual
+    OptNoQual -> NoQual
+
+-- | Whether to hide empty contexts
+-- Since pattern synonyms have two contexts with different semantics, it is
+-- important to all of them, even if one of them is empty.
+data HideEmptyContexts
+  = HideEmptyContexts
+  | ShowEmptyToplevelContexts
+
+-- | When to qualify @since@ annotations with their package
+data SinceQual
+  = Always
+  | -- | only qualify when the thing being annotated is from
+    -- an external package
+    External
+
+-----------------------------------------------------------------------------
+
+-- * Renaming
+
+-----------------------------------------------------------------------------
+
+-- | Renames an identifier.
+-- The first input is the identifier as it occurred in the comment
+-- The second input is the possible namespaces of the identifier
+type Renamer = String -> (NameSpace -> Bool) -> [Name]
+
+-----------------------------------------------------------------------------
+
+-- * Error handling
+
+-----------------------------------------------------------------------------
+
+-- | Haddock's own exception type.
+data HaddockException
+  = HaddockException String
+  | WithContext [String] SomeException
+  deriving (Typeable)
+
+instance Show HaddockException where
+  show (HaddockException str) = str
+  show (WithContext ctxts se) = unlines $ ["While " ++ ctxt ++ ":\n" | ctxt <- reverse ctxts] ++ [show se]
+
+throwE :: String -> a
+instance Exception HaddockException
+throwE str = throw (HaddockException str)
+
+withExceptionContext :: MonadCatch m => String -> m a -> m a
+withExceptionContext ctxt =
+  handle
+    ( \ex ->
+        case ex of
+          HaddockException _ -> throwM $ WithContext [ctxt] (toException ex)
+          WithContext ctxts se -> throwM $ WithContext (ctxt : ctxts) se
+    )
+    . handle (throwM . WithContext [ctxt])
+
+-----------------------------------------------------------------------------
+
+-- * Pass sensitive types
+
+-----------------------------------------------------------------------------
+
+type instance XRec DocNameI a = GenLocated (Anno a) a
+instance UnXRec DocNameI where
+  unXRec = unLoc
+instance MapXRec DocNameI where
+  mapXRec = fmap
+instance WrapXRec DocNameI (HsType DocNameI) where
+  wrapXRec = noLocA
+
+type instance Anno DocName = SrcSpanAnnN
+type instance Anno (HsTyVarBndr flag DocNameI) = SrcSpanAnnA
+type instance Anno [LocatedA (HsType DocNameI)] = SrcSpanAnnC
+type instance Anno (HsType DocNameI) = SrcSpanAnnA
+type instance Anno (DataFamInstDecl DocNameI) = SrcSpanAnnA
+type instance Anno (DerivStrategy DocNameI) = EpAnn NoEpAnns
+type instance Anno (FieldOcc DocNameI) = SrcSpanAnnA
+type instance Anno (ConDeclField DocNameI) = SrcSpan
+type instance Anno (Located (ConDeclField DocNameI)) = SrcSpan
+type instance Anno [Located (ConDeclField DocNameI)] = SrcSpan
+type instance Anno (ConDecl DocNameI) = SrcSpan
+type instance Anno (FunDep DocNameI) = SrcSpan
+type instance Anno (TyFamInstDecl DocNameI) = SrcSpanAnnA
+type instance Anno [LocatedA (TyFamInstDecl DocNameI)] = SrcSpanAnnL
+type instance Anno (FamilyDecl DocNameI) = SrcSpan
+type instance Anno (Sig DocNameI) = SrcSpan
+type instance Anno (InjectivityAnn DocNameI) = EpAnn NoEpAnns
+type instance Anno (HsDecl DocNameI) = SrcSpanAnnA
+type instance Anno (FamilyResultSig DocNameI) = EpAnn NoEpAnns
+type instance Anno (HsOuterTyVarBndrs Specificity DocNameI) = SrcSpanAnnA
+type instance Anno (HsSigType DocNameI) = SrcSpanAnnA
+
+type XRecCond a =
+  ( XParTy a ~ AnnParen
+  , NoGhcTc a ~ a
+  , MapXRec a
+  , UnXRec a
+  , WrapXRec a (HsType a)
+  )
+
+type instance XValArg DocNameI = NoExtField
+type instance XTypeArg DocNameI = NoExtField
+type instance XArgPar DocNameI = NoExtField
+type instance XXArg DocNameI = DataConCantHappen
+
+type instance XBndrRequired DocNameI = NoExtField
+type instance XBndrInvisible DocNameI = NoExtField
+type instance XXBndrVis DocNameI = DataConCantHappen
+
+type instance XUnrestrictedArrow DocNameI = NoExtField
+type instance XLinearArrow DocNameI = NoExtField
+type instance XExplicitMult DocNameI = NoExtField
+type instance XXArrow DocNameI = DataConCantHappen
+
+type instance XForAllTy DocNameI = EpAnn [AddEpAnn]
+type instance XQualTy DocNameI = EpAnn [AddEpAnn]
+type instance XTyVar DocNameI = EpAnn [AddEpAnn]
+type instance XStarTy DocNameI = EpAnn [AddEpAnn]
+type instance XAppTy DocNameI = EpAnn [AddEpAnn]
+type instance XAppKindTy DocNameI = EpAnn [AddEpAnn]
+type instance XFunTy DocNameI = EpAnn [AddEpAnn]
+type instance XListTy DocNameI = EpAnn AnnParen
+type instance XTupleTy DocNameI = EpAnn AnnParen
+type instance XSumTy DocNameI = EpAnn AnnParen
+type instance XOpTy DocNameI = EpAnn [AddEpAnn]
+type instance XParTy DocNameI = AnnParen
+type instance XIParamTy DocNameI = EpAnn [AddEpAnn]
+type instance XKindSig DocNameI = EpAnn [AddEpAnn]
+type instance XSpliceTy DocNameI = DataConCantHappen
+type instance XDocTy DocNameI = EpAnn [AddEpAnn]
+type instance XBangTy DocNameI = EpAnn [AddEpAnn]
+type instance XRecTy DocNameI = EpAnn [AddEpAnn]
+type instance XExplicitListTy DocNameI = EpAnn [AddEpAnn]
+type instance XExplicitTupleTy DocNameI = EpAnn [AddEpAnn]
+type instance XTyLit DocNameI = EpAnn [AddEpAnn]
+type instance XWildCardTy DocNameI = EpAnn [AddEpAnn]
+type instance XXType DocNameI = HsCoreTy
+
+type instance XNumTy DocNameI = NoExtField
+type instance XStrTy DocNameI = NoExtField
+type instance XCharTy DocNameI = NoExtField
+type instance XXTyLit DocNameI = DataConCantHappen
+
+type instance XHsForAllVis DocNameI = NoExtField
+type instance XHsForAllInvis DocNameI = NoExtField
+type instance XXHsForAllTelescope DocNameI = DataConCantHappen
+
+type instance XUserTyVar DocNameI = NoExtField
+type instance XKindedTyVar DocNameI = NoExtField
+type instance XXTyVarBndr DocNameI = DataConCantHappen
+
+type instance XCFieldOcc DocNameI = DocName
+type instance XXFieldOcc DocNameI = NoExtField
+
+type instance XFixitySig DocNameI = NoExtField
+type instance XFixSig DocNameI = NoExtField
+type instance XPatSynSig DocNameI = NoExtField
+type instance XClassOpSig DocNameI = NoExtField
+type instance XTypeSig DocNameI = NoExtField
+type instance XMinimalSig DocNameI = NoExtField
+
+type instance XForeignExport DocNameI = NoExtField
+type instance XForeignImport DocNameI = NoExtField
+
+type instance XCImport DocNameI = NoExtField
+type instance XCExport DocNameI = NoExtField
+
+type instance XXForeignImport DocNameI = DataConCantHappen
+type instance XXForeignExport DocNameI = DataConCantHappen
+
+type instance XConDeclGADT DocNameI = NoExtField
+type instance XConDeclH98 DocNameI = NoExtField
+type instance XXConDecl DocNameI = DataConCantHappen
+
+type instance XPrefixConGADT DocNameI = NoExtField
+type instance XRecConGADT DocNameI = NoExtField
+type instance XXConDeclGADTDetails DocNameI = DataConCantHappen
+
+type instance XDerivD DocNameI = NoExtField
+type instance XInstD DocNameI = NoExtField
+type instance XForD DocNameI = NoExtField
+type instance XSigD DocNameI = NoExtField
+type instance XTyClD DocNameI = NoExtField
+
+type instance XNoSig DocNameI = NoExtField
+type instance XCKindSig DocNameI = NoExtField
+type instance XTyVarSig DocNameI = NoExtField
+type instance XXFamilyResultSig DocNameI = DataConCantHappen
+
+type instance XCFamEqn DocNameI _ = NoExtField
+type instance XXFamEqn DocNameI _ = DataConCantHappen
+
+type instance XCClsInstDecl DocNameI = NoExtField
+type instance XCDerivDecl DocNameI = NoExtField
+type instance XStockStrategy DocNameI = NoExtField
+type instance XAnyClassStrategy DocNameI = NoExtField
+type instance XNewtypeStrategy DocNameI = NoExtField
+type instance XViaStrategy DocNameI = LHsSigType DocNameI
+type instance XDataFamInstD DocNameI = NoExtField
+type instance XTyFamInstD DocNameI = NoExtField
+type instance XClsInstD DocNameI = NoExtField
+type instance XCHsDataDefn DocNameI = NoExtField
+type instance XCFamilyDecl DocNameI = NoExtField
+type instance XClassDecl DocNameI = NoExtField
+type instance XDataDecl DocNameI = NoExtField
+type instance XSynDecl DocNameI = NoExtField
+type instance XFamDecl DocNameI = NoExtField
+type instance XXFamilyDecl DocNameI = DataConCantHappen
+type instance XXTyClDecl DocNameI = DataConCantHappen
+
+type instance XHsWC DocNameI _ = NoExtField
+
+type instance XHsOuterExplicit DocNameI _ = NoExtField
+type instance XHsOuterImplicit DocNameI = NoExtField
+type instance XXHsOuterTyVarBndrs DocNameI = DataConCantHappen
+
+type instance XHsSig DocNameI = NoExtField
+type instance XXHsSigType DocNameI = DataConCantHappen
+
+type instance XHsQTvs DocNameI = NoExtField
+type instance XConDeclField DocNameI = NoExtField
+type instance XXConDeclField DocNameI = DataConCantHappen
+
+type instance XXPat DocNameI = DataConCantHappen
+type instance XXHsBindsLR DocNameI a = DataConCantHappen
+
+type instance XSplicePat DocNameI = DataConCantHappen
+
+type instance XCInjectivityAnn DocNameI = NoExtField
+
+type instance XCFunDep DocNameI = NoExtField
+
+type instance XCTyFamInstDecl DocNameI = NoExtField
+
+-----------------------------------------------------------------------------
+
+-- * NFData instances for GHC types
+
+-----------------------------------------------------------------------------
+
+instance NFData RdrName where
+  rnf (Unqual on) = rnf on
+  rnf (Qual mn on) = mn `deepseq` on `deepseq` ()
+  rnf (Orig m on) = m `deepseq` on `deepseq` ()
+  rnf (Exact n) = rnf n
+
+instance NFData FixityDirection where
+  rnf InfixL = ()
+  rnf InfixR = ()
+  rnf InfixN = ()
+
+instance NFData Fixity where
+  rnf (Fixity sourceText n dir) =
+    sourceText `deepseq` n `deepseq` dir `deepseq` ()
+
+instance NFData (EpAnn NameAnn) where
+  rnf (EpAnn en ann cs) = en `deepseq` ann `deepseq` cs `deepseq` ()
+
+instance NFData NameAnn where
+  rnf (NameAnn a b c d e) =
+    a `deepseq`
+      b `deepseq`
+        c `deepseq`
+          d `deepseq`
+            e `deepseq`
+              ()
+  rnf (NameAnnCommas a b c d e) =
+    a `deepseq`
+      b `deepseq`
+        c `deepseq`
+          d `deepseq`
+            e `deepseq`
+              ()
+  rnf (NameAnnBars a b c d e) =
+    a `deepseq`
+      b `deepseq`
+        c `deepseq`
+          d `deepseq`
+            e `deepseq`
+              ()
+  rnf (NameAnnOnly a b c d) =
+    a `deepseq`
+      b `deepseq`
+        c `deepseq`
+          d `deepseq`
+            ()
+  rnf (NameAnnRArrow a b c d e) =
+    a `deepseq`
+      b `deepseq`
+        c `deepseq`
+          d `deepseq`
+            e `deepseq`
+              ()
+  rnf (NameAnnQuote a b c) =
+    a `deepseq`
+      b `deepseq`
+        c `deepseq`
+          ()
+  rnf (NameAnnTrailing a) = rnf a
+
+instance NFData TrailingAnn where
+  rnf (AddSemiAnn epaL) = rnf epaL
+  rnf (AddCommaAnn epaL) = rnf epaL
+  rnf (AddVbarAnn epaL) = rnf epaL
+  rnf (AddDarrowAnn epaL) = rnf epaL
+  rnf (AddDarrowUAnn epaL) = rnf epaL
+
+instance NFData NameAdornment where
+  rnf NameParens = ()
+  rnf NameParensHash = ()
+  rnf NameBackquotes = ()
+  rnf NameSquare = ()
+
+instance NFData NoComments where
+  rnf NoComments = ()
+
+instance NFData a => NFData (EpaLocation' a) where
+  rnf (EpaSpan ss) = rnf ss
+  rnf (EpaDelta dp lc) = dp `seq` lc `deepseq` ()
+
+instance NFData EpAnnComments where
+  rnf (EpaComments cs) = rnf cs
+  rnf (EpaCommentsBalanced cs1 cs2) = cs1 `deepseq` cs2 `deepseq` ()
+
+instance NFData EpaComment where
+  rnf (EpaComment t rss) = t `deepseq` rss `seq` ()
+
+instance NFData EpaCommentTok where
+  rnf (EpaDocComment ds) = rnf ds
+  rnf (EpaDocOptions s) = rnf s
+  rnf (EpaLineComment s) = rnf s
+  rnf (EpaBlockComment s) = rnf s
+
+instance NFData a => NFData (Strict.Maybe a) where
+  rnf Strict.Nothing = ()
+  rnf (Strict.Just x) = rnf x
+
+instance NFData BufSpan where
+  rnf (BufSpan p1 p2) = p1 `deepseq` p2 `deepseq` ()
+
+instance NFData BufPos where
+  rnf (BufPos n) = rnf n
+
+instance NFData DeltaPos where
+  rnf (SameLine n) = rnf n
+  rnf (DifferentLine n m) = n `deepseq` m `deepseq` ()
diff --git a/utils/haddock/haddock-api/src/Haddock/Utils.hs b/utils/haddock/haddock-api/src/Haddock/Utils.hs
new file mode 100644
index 0000000000000000000000000000000000000000..94b5138e65ea83f4559996f9e95d8ba5c1dbf7f4
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Utils.hs
@@ -0,0 +1,361 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE GADTs #-}
+{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Utils
+-- Copyright   :  (c) The University of Glasgow 2001-2002,
+--                    Simon Marlow 2003-2006,
+--                    David Waern  2006-2009
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Utils
+  ( -- * Filename utilities
+    moduleHtmlFile
+  , moduleHtmlFile'
+  , contentsHtmlFile
+  , indexHtmlFile
+  , indexJsonFile
+  , subIndexHtmlFile
+  , haddockJsFile
+  , jsQuickJumpFile
+  , quickJumpCssFile
+
+    -- * Anchor and URL utilities
+  , moduleNameUrl
+  , moduleNameUrl'
+  , moduleUrl
+  , nameAnchorId
+  , makeAnchorId
+
+    -- * Miscellaneous utilities
+  , getProgramName
+  , bye
+  , die
+  , escapeStr
+  , writeUtf8File
+  , withTempDir
+
+    -- * HTML cross reference mapping
+  , html_xrefs_ref
+  , html_xrefs_ref'
+
+    -- * Doc markup
+  , mkMeta
+
+    -- * List utilities
+  , replace
+  , spanWith
+
+    -- * Logging
+  , parseVerbosity
+  , Verbosity (..)
+  , silent
+  , normal
+  , verbose
+  , deafening
+  , out
+
+    -- * System tools
+  , getProcessID
+  ) where
+
+import Documentation.Haddock.Doc (emptyMetaDoc)
+import Haddock.Types
+
+import GHC
+import GHC.Types.Name
+
+import Control.Monad.Catch (MonadMask, bracket_)
+import Control.Monad.IO.Class (MonadIO (..))
+import Data.Char (chr, isAlpha, isAlphaNum, isAscii, ord)
+import Data.IORef (IORef, newIORef, readIORef)
+import Data.List (isSuffixOf)
+import Data.Map (Map)
+import qualified Data.Map as Map hiding (Map)
+import Numeric (showIntAtBase)
+import System.Directory (createDirectory, removeDirectoryRecursive)
+import System.Environment (getProgName)
+import System.Exit
+import qualified System.FilePath.Posix as HtmlPath
+import System.IO (IOMode (..), hPutStr, hSetEncoding, utf8, withFile)
+import System.IO.Unsafe (unsafePerformIO)
+
+#ifndef mingw32_HOST_OS
+import qualified System.Posix.Internals
+#endif
+
+--------------------------------------------------------------------------------
+
+-- * Logging
+
+--------------------------------------------------------------------------------
+
+data Verbosity = Silent | Normal | Verbose | Deafening
+  deriving (Eq, Ord, Enum, Bounded, Show)
+
+silent, normal, verbose, deafening :: Verbosity
+silent = Silent
+normal = Normal
+verbose = Verbose
+deafening = Deafening
+
+-- | Parse out a verbosity level. Inspired from Cabal's verbosity parsing.
+parseVerbosity :: String -> Either String Verbosity
+parseVerbosity "0" = Right Silent
+parseVerbosity "1" = Right Normal
+parseVerbosity "2" = Right Silent
+parseVerbosity "3" = Right Deafening
+parseVerbosity "silent" = return Silent
+parseVerbosity "normal" = return Normal
+parseVerbosity "verbose" = return Verbose
+parseVerbosity "debug" = return Deafening
+parseVerbosity "deafening" = return Deafening
+parseVerbosity other = Left ("Can't parse verbosity " ++ other)
+
+-- | Print a message to stdout, if it is not too verbose
+out
+  :: MonadIO m
+  => Verbosity
+  -- ^ program verbosity
+  -> Verbosity
+  -- ^ message verbosity
+  -> String
+  -> m ()
+out progVerbosity msgVerbosity msg
+  | msgVerbosity <= progVerbosity = liftIO $ putStrLn msg
+  | otherwise = return ()
+
+--------------------------------------------------------------------------------
+
+-- * Some Utilities
+
+--------------------------------------------------------------------------------
+
+mkMeta :: Doc a -> MDoc a
+mkMeta x = emptyMetaDoc{_doc = x}
+
+--------------------------------------------------------------------------------
+
+-- * Filename mangling functions stolen from s main/DriverUtil.lhs.
+
+--------------------------------------------------------------------------------
+
+baseName :: ModuleName -> FilePath
+baseName = map (\c -> if c == '.' then '-' else c) . moduleNameString
+
+moduleHtmlFile :: Module -> FilePath
+moduleHtmlFile mdl =
+  case Map.lookup mdl html_xrefs of
+    Nothing -> baseName mdl' ++ ".html"
+    Just fp0 -> HtmlPath.joinPath [fp0, baseName mdl' ++ ".html"]
+  where
+    mdl' = moduleName mdl
+
+moduleHtmlFile' :: ModuleName -> FilePath
+moduleHtmlFile' mdl =
+  case Map.lookup mdl html_xrefs' of
+    Nothing -> baseName mdl ++ ".html"
+    Just fp0 -> HtmlPath.joinPath [fp0, baseName mdl ++ ".html"]
+
+contentsHtmlFile, indexHtmlFile, indexJsonFile :: String
+contentsHtmlFile = "index.html"
+indexHtmlFile = "doc-index.html"
+indexJsonFile = "doc-index.json"
+
+subIndexHtmlFile :: String -> String
+subIndexHtmlFile ls = "doc-index-" ++ b ++ ".html"
+  where
+    b
+      | all isAlpha ls = ls
+      | otherwise = concatMap (show . ord) ls
+
+-------------------------------------------------------------------------------
+
+-- * Anchor and URL utilities
+
+--
+-- NB: Anchor IDs, used as the destination of a link within a document must
+-- conform to XML's NAME production. That, taken with XHTML and HTML 4.01's
+-- various needs and compatibility constraints, means these IDs have to match:
+--      [A-Za-z][A-Za-z0-9:_.-]*
+-- Such IDs do not need to be escaped in any way when used as the fragment part
+-- of a URL. Indeed, %-escaping them can lead to compatibility issues as it
+-- isn't clear if such fragment identifiers should, or should not be unescaped
+-- before being matched with IDs in the target document.
+-------------------------------------------------------------------------------
+
+moduleUrl :: Module -> String
+moduleUrl = moduleHtmlFile
+
+moduleNameUrl :: Module -> OccName -> String
+moduleNameUrl mdl n = moduleUrl mdl ++ '#' : nameAnchorId n
+
+moduleNameUrl' :: ModuleName -> OccName -> String
+moduleNameUrl' mdl n = moduleHtmlFile' mdl ++ '#' : nameAnchorId n
+
+nameAnchorId :: OccName -> String
+nameAnchorId name = makeAnchorId (prefix : ':' : occNameString name)
+  where
+    prefix
+      | isValOcc name = 'v'
+      | otherwise = 't'
+
+-- | Takes an arbitrary string and makes it a valid anchor ID. The mapping is
+-- identity preserving.
+makeAnchorId :: String -> String
+makeAnchorId [] = []
+makeAnchorId (f : r) = escape isAlpha f ++ concatMap (escape isLegal) r
+  where
+    escape p c
+      | p c = [c]
+      | otherwise = '-' : show (ord c) ++ "-"
+    isLegal ':' = True
+    isLegal '_' = True
+    isLegal '.' = True
+    isLegal c = isAscii c && isAlphaNum c
+
+-- NB: '-' is legal in IDs, but we use it as the escape char
+
+-------------------------------------------------------------------------------
+
+-- * Files we need to copy from our $libdir
+
+-------------------------------------------------------------------------------
+
+haddockJsFile :: String
+haddockJsFile = "haddock-bundle.min.js"
+
+jsQuickJumpFile :: String
+jsQuickJumpFile = "quick-jump.min.js"
+
+quickJumpCssFile :: String
+quickJumpCssFile = "quick-jump.css"
+
+-------------------------------------------------------------------------------
+
+-- * Misc.
+
+-------------------------------------------------------------------------------
+
+getProgramName :: IO String
+getProgramName = fmap (`withoutSuffix` ".bin") getProgName
+  where
+    str `withoutSuffix` suff
+      | suff `isSuffixOf` str = take (length str - length suff) str
+      | otherwise = str
+
+bye :: String -> IO a
+bye s = putStr s >> exitSuccess
+
+escapeStr :: String -> String
+escapeStr = escapeURIString isUnreserved
+
+-- Following few functions are copy'n'pasted from Network.URI module
+-- to avoid depending on the network lib, since doing so gives a
+-- circular build dependency between haddock and network
+-- (at least if you want to build network with haddock docs)
+escapeURIChar :: (Char -> Bool) -> Char -> String
+escapeURIChar p c
+  | p c = [c]
+  | otherwise = '%' : myShowHex (ord c) ""
+  where
+    myShowHex :: Int -> ShowS
+    myShowHex n r = case showIntAtBase 16 toChrHex n r of
+      [] -> "00"
+      [a] -> ['0', a]
+      cs -> cs
+    toChrHex d
+      | d < 10 = chr (ord '0' + fromIntegral d)
+      | otherwise = chr (ord 'A' + fromIntegral (d - 10))
+
+escapeURIString :: (Char -> Bool) -> String -> String
+escapeURIString = concatMap . escapeURIChar
+
+isUnreserved :: Char -> Bool
+isUnreserved c = isAlphaNumChar c || (c `elem` "-_.~")
+
+isAlphaChar, isDigitChar, isAlphaNumChar :: Char -> Bool
+isAlphaChar c = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
+isDigitChar c = c >= '0' && c <= '9'
+isAlphaNumChar c = isAlphaChar c || isDigitChar c
+
+-- | Utility to write output to UTF-8 encoded files.
+--
+-- The problem with 'writeFile' is that it picks up its 'TextEncoding' from
+-- 'getLocaleEncoding', and on some platforms (like Windows) this default
+-- encoding isn't enough for the characters we want to write.
+writeUtf8File :: FilePath -> String -> IO ()
+writeUtf8File filepath contents = withFile filepath WriteMode $ \h -> do
+  hSetEncoding h utf8
+  hPutStr h contents
+
+withTempDir :: (MonadIO m, MonadMask m) => FilePath -> m a -> m a
+withTempDir dir =
+  bracket_
+    (liftIO $ createDirectory dir)
+    (liftIO $ removeDirectoryRecursive dir)
+
+-----------------------------------------------------------------------------
+
+-- * HTML cross references
+
+--
+-- For each module, we need to know where its HTML documentation lives
+-- so that we can point hyperlinks to it.  It is extremely
+-- inconvenient to plumb this information to all the places that need
+-- it (basically every function in HaddockHtml), and furthermore the
+-- mapping is constant for any single run of Haddock.  So for the time
+-- being I'm going to use a write-once global variable.
+-----------------------------------------------------------------------------
+
+{-# NOINLINE html_xrefs_ref #-}
+html_xrefs_ref :: IORef (Map Module FilePath)
+html_xrefs_ref = unsafePerformIO (newIORef (error "module_map"))
+
+{-# NOINLINE html_xrefs_ref' #-}
+html_xrefs_ref' :: IORef (Map ModuleName FilePath)
+html_xrefs_ref' = unsafePerformIO (newIORef (error "module_map"))
+
+{-# NOINLINE html_xrefs #-}
+html_xrefs :: Map Module FilePath
+html_xrefs = unsafePerformIO (readIORef html_xrefs_ref)
+
+{-# NOINLINE html_xrefs' #-}
+html_xrefs' :: Map ModuleName FilePath
+html_xrefs' = unsafePerformIO (readIORef html_xrefs_ref')
+
+-----------------------------------------------------------------------------
+
+-- * List utils
+
+-----------------------------------------------------------------------------
+
+replace :: Eq a => a -> a -> [a] -> [a]
+replace a b = map (\x -> if x == a then b else x)
+
+spanWith :: (a -> Maybe b) -> [a] -> ([b], [a])
+spanWith _ [] = ([], [])
+spanWith p xs@(a : as)
+  | Just b <- p a = let (bs, cs) = spanWith p as in (b : bs, cs)
+  | otherwise = ([], xs)
+
+-----------------------------------------------------------------------------
+
+-- * System tools
+
+-----------------------------------------------------------------------------
+
+#ifdef mingw32_HOST_OS
+foreign import ccall unsafe "_getpid" getProcessID :: IO Int -- relies on Int == Int32 on Windows
+#else
+getProcessID :: IO Int
+getProcessID = fmap fromIntegral System.Posix.Internals.c_getpid
+#endif
diff --git a/utils/haddock/haddock-api/src/Haddock/Utils/Json.hs b/utils/haddock/haddock-api/src/Haddock/Utils/Json.hs
new file mode 100644
index 0000000000000000000000000000000000000000..1486519bd78cf0f9f1ec5fabf35c5963437410d2
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Utils/Json.hs
@@ -0,0 +1,561 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE RankNTypes #-}
+
+-- | Minimal JSON / RFC 7159 support
+--
+-- The API is heavily inspired by @aeson@'s API but puts emphasis on
+-- simplicity rather than performance. The 'ToJSON' instances are
+-- intended to have an encoding compatible with @aeson@'s encoding.
+module Haddock.Utils.Json
+  ( Value (..)
+  , Object
+  , object
+  , Pair
+  , (.=)
+  , encodeToString
+  , encodeToBuilder
+  , ToJSON (toJSON)
+  , Parser (..)
+  , Result (..)
+  , FromJSON (parseJSON)
+  , withObject
+  , withArray
+  , withString
+  , withDouble
+  , withBool
+  , fromJSON
+  , parse
+  , parseEither
+  , (.:)
+  , (.:?)
+  , decode
+  , decodeWith
+  , eitherDecode
+  , eitherDecodeWith
+  , decodeFile
+  , eitherDecodeFile
+  )
+where
+
+import Control.Applicative (Alternative (..))
+import Control.Monad (MonadPlus (..), zipWithM, (>=>))
+import qualified Control.Monad as Monad
+import qualified Control.Monad.Fail as Fail
+
+import Data.ByteString.Builder (Builder)
+import qualified Data.ByteString.Builder as BB
+import qualified Data.ByteString.Lazy as BSL
+import Data.Char
+import Data.Int
+import Data.List (intersperse)
+import Data.Monoid
+import Data.Word
+
+import GHC.Natural
+
+-- TODO: We may want to replace 'String' with 'Text' or 'ByteString'
+
+import qualified Text.Parsec.ByteString.Lazy as Parsec.Lazy
+import qualified Text.ParserCombinators.Parsec as Parsec
+
+import Haddock.Utils.Json.Parser
+import Haddock.Utils.Json.Types
+
+infixr 8 .=
+
+-- | A key-value pair for encoding a JSON object.
+(.=) :: ToJSON v => String -> v -> Pair
+k .= v = (k, toJSON v)
+
+-- | A type that can be converted to JSON.
+class ToJSON a where
+  -- | Convert a Haskell value to a JSON-friendly intermediate type.
+  toJSON :: a -> Value
+
+instance ToJSON () where
+  toJSON () = Array []
+
+instance ToJSON Value where
+  toJSON = id
+
+instance ToJSON Bool where
+  toJSON = Bool
+
+instance ToJSON a => ToJSON [a] where
+  toJSON = Array . map toJSON
+
+instance ToJSON a => ToJSON (Maybe a) where
+  toJSON Nothing = Null
+  toJSON (Just a) = toJSON a
+
+instance (ToJSON a, ToJSON b) => ToJSON (a, b) where
+  toJSON (a, b) = Array [toJSON a, toJSON b]
+
+instance (ToJSON a, ToJSON b, ToJSON c) => ToJSON (a, b, c) where
+  toJSON (a, b, c) = Array [toJSON a, toJSON b, toJSON c]
+
+instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a, b, c, d) where
+  toJSON (a, b, c, d) = Array [toJSON a, toJSON b, toJSON c, toJSON d]
+
+instance ToJSON Float where
+  toJSON = Number . realToFrac
+
+instance ToJSON Double where
+  toJSON = Number
+
+instance ToJSON Int where toJSON = Number . realToFrac
+instance ToJSON Int8 where toJSON = Number . realToFrac
+instance ToJSON Int16 where toJSON = Number . realToFrac
+instance ToJSON Int32 where toJSON = Number . realToFrac
+
+instance ToJSON Word where toJSON = Number . realToFrac
+instance ToJSON Word8 where toJSON = Number . realToFrac
+instance ToJSON Word16 where toJSON = Number . realToFrac
+instance ToJSON Word32 where toJSON = Number . realToFrac
+
+-- | Possibly lossy due to conversion to 'Double'
+instance ToJSON Int64 where toJSON = Number . realToFrac
+
+-- | Possibly lossy due to conversion to 'Double'
+instance ToJSON Word64 where toJSON = Number . realToFrac
+
+-- | Possibly lossy due to conversion to 'Double'
+instance ToJSON Integer where toJSON = Number . fromInteger
+
+------------------------------------------------------------------------------
+-- 'BB.Builder'-based encoding
+
+-- | Serialise value as JSON/UTF8-encoded 'Builder'
+encodeToBuilder :: ToJSON a => a -> Builder
+encodeToBuilder = encodeValueBB . toJSON
+
+encodeValueBB :: Value -> Builder
+encodeValueBB jv = case jv of
+  Bool True -> "true"
+  Bool False -> "false"
+  Null -> "null"
+  Number n
+    | isNaN n || isInfinite n -> encodeValueBB Null
+    | Just i <- doubleToInt64 n -> BB.int64Dec i
+    | otherwise -> BB.doubleDec n
+  Array a -> encodeArrayBB a
+  String s -> encodeStringBB s
+  Object o -> encodeObjectBB o
+
+encodeArrayBB :: [Value] -> Builder
+encodeArrayBB [] = "[]"
+encodeArrayBB jvs = BB.char8 '[' <> go jvs <> BB.char8 ']'
+  where
+    go = Data.Monoid.mconcat . intersperse (BB.char8 ',') . map encodeValueBB
+
+encodeObjectBB :: Object -> Builder
+encodeObjectBB [] = "{}"
+encodeObjectBB jvs = BB.char8 '{' <> go jvs <> BB.char8 '}'
+  where
+    go = Data.Monoid.mconcat . intersperse (BB.char8 ',') . map encPair
+    encPair (l, x) = encodeStringBB l <> BB.char8 ':' <> encodeValueBB x
+
+encodeStringBB :: String -> Builder
+encodeStringBB str = BB.char8 '"' <> go str <> BB.char8 '"'
+  where
+    go = BB.stringUtf8 . escapeString
+
+------------------------------------------------------------------------------
+-- 'String'-based encoding
+
+-- | Serialise value as JSON-encoded Unicode 'String'
+encodeToString :: ToJSON a => a -> String
+encodeToString jv = encodeValue (toJSON jv) []
+
+encodeValue :: Value -> ShowS
+encodeValue jv = case jv of
+  Bool b -> showString (if b then "true" else "false")
+  Null -> showString "null"
+  Number n
+    | isNaN n || isInfinite n -> encodeValue Null
+    | Just i <- doubleToInt64 n -> shows i
+    | otherwise -> shows n
+  Array a -> encodeArray a
+  String s -> encodeString s
+  Object o -> encodeObject o
+
+encodeArray :: [Value] -> ShowS
+encodeArray [] = showString "[]"
+encodeArray jvs = ('[' :) . go jvs . (']' :)
+  where
+    go [] = id
+    go [x] = encodeValue x
+    go (x : xs) = encodeValue x . (',' :) . go xs
+
+encodeObject :: Object -> ShowS
+encodeObject [] = showString "{}"
+encodeObject jvs = ('{' :) . go jvs . ('}' :)
+  where
+    go [] = id
+    go [(l, x)] = encodeString l . (':' :) . encodeValue x
+    go ((l, x) : lxs) = encodeString l . (':' :) . encodeValue x . (',' :) . go lxs
+
+encodeString :: String -> ShowS
+encodeString str = ('"' :) . showString (escapeString str) . ('"' :)
+
+------------------------------------------------------------------------------
+-- helpers
+
+-- | Try to convert 'Double' into 'Int64', return 'Nothing' if not
+-- representable loss-free as integral 'Int64' value.
+doubleToInt64 :: Double -> Maybe Int64
+doubleToInt64 x
+  | fromInteger x' == x
+  , x' <= toInteger (maxBound :: Int64)
+  , x' >= toInteger (minBound :: Int64) =
+      Just (fromIntegral x')
+  | otherwise = Nothing
+  where
+    x' = round x
+
+-- | Minimally escape a 'String' in accordance with RFC 7159, "7. Strings"
+escapeString :: String -> String
+escapeString s
+  | not (any needsEscape s) = s
+  | otherwise = escape s
+  where
+    escape [] = []
+    escape (x : xs) = case x of
+      '\\' -> '\\' : '\\' : escape xs
+      '"' -> '\\' : '"' : escape xs
+      '\b' -> '\\' : 'b' : escape xs
+      '\f' -> '\\' : 'f' : escape xs
+      '\n' -> '\\' : 'n' : escape xs
+      '\r' -> '\\' : 'r' : escape xs
+      '\t' -> '\\' : 't' : escape xs
+      c
+        | ord c < 0x10 -> '\\' : 'u' : '0' : '0' : '0' : intToDigit (ord c) : escape xs
+        | ord c < 0x20 -> '\\' : 'u' : '0' : '0' : '1' : intToDigit (ord c - 0x10) : escape xs
+        | otherwise -> c : escape xs
+
+    -- unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
+    needsEscape c = ord c < 0x20 || c `elem` ['\\', '"']
+
+------------------------------------------------------------------------------
+-- FromJSON
+
+-- | Elements of a JSON path used to describe the location of an
+-- error.
+data JSONPathElement
+  = -- | JSON path element of a key into an object,
+    -- \"object.key\".
+    Key String
+  | -- | JSON path element of an index into an
+    -- array, \"array[index]\".
+    Index !Int
+  deriving (Eq, Show, Ord)
+
+type JSONPath = [JSONPathElement]
+
+-- | Failure continuation.
+type Failure f r = JSONPath -> String -> f r
+
+-- | Success continuation.
+type Success a f r = a -> f r
+
+newtype Parser a = Parser
+  { runParser
+      :: forall f r
+       . JSONPath
+      -> Failure f r
+      -> Success a f r
+      -> f r
+  }
+
+modifyFailure :: (String -> String) -> Parser a -> Parser a
+modifyFailure f (Parser p) = Parser $ \path kf ks ->
+  p path (\p' m -> kf p' (f m)) ks
+
+prependFailure :: String -> Parser a -> Parser a
+prependFailure = modifyFailure . (++)
+
+prependContext :: String -> Parser a -> Parser a
+prependContext name = prependFailure ("parsing " ++ name ++ " failed, ")
+
+typeMismatch :: String -> Value -> Parser a
+typeMismatch expected actual =
+  fail $ "expected " ++ expected ++ ", but encountered " ++ typeOf actual
+
+instance Monad.Monad Parser where
+  m >>= g = Parser $ \path kf ks ->
+    runParser
+      m
+      path
+      kf
+      (\a -> runParser (g a) path kf ks)
+  return = pure
+
+instance Fail.MonadFail Parser where
+  fail msg = Parser $ \path kf _ks -> kf (reverse path) msg
+
+instance Functor Parser where
+  fmap f m = Parser $ \path kf ks ->
+    let ks' a = ks (f a)
+     in runParser m path kf ks'
+
+instance Applicative Parser where
+  pure a = Parser $ \_path _kf ks -> ks a
+  (<*>) = apP
+
+instance Alternative Parser where
+  empty = fail "empty"
+  (<|>) = mplus
+
+instance MonadPlus Parser where
+  mzero = fail "mzero"
+  mplus a b = Parser $ \path kf ks ->
+    runParser a path (\_ _ -> runParser b path kf ks) ks
+
+instance Semigroup (Parser a) where
+  (<>) = mplus
+
+instance Monoid (Parser a) where
+  mempty = fail "mempty"
+  mappend = (<>)
+
+apP :: Parser (a -> b) -> Parser a -> Parser b
+apP d e = do
+  b <- d
+  b <$> e
+
+(<?>) :: Parser a -> JSONPathElement -> Parser a
+p <?> pathElem = Parser $ \path kf ks -> runParser p (pathElem : path) kf ks
+
+parseIndexedJSON :: (Value -> Parser a) -> Int -> Value -> Parser a
+parseIndexedJSON p idx value = p value <?> Index idx
+
+unexpected :: Value -> Parser a
+unexpected actual = fail $ "unexpected " ++ typeOf actual
+
+withObject :: String -> (Object -> Parser a) -> Value -> Parser a
+withObject _ f (Object obj) = f obj
+withObject name _ v = prependContext name (typeMismatch "Object" v)
+
+withArray :: String -> ([Value] -> Parser a) -> Value -> Parser a
+withArray _ f (Array arr) = f arr
+withArray name _ v = prependContext name (typeMismatch "Array" v)
+
+withString :: String -> (String -> Parser a) -> Value -> Parser a
+withString _ f (String txt) = f txt
+withString name _ v = prependContext name (typeMismatch "String" v)
+
+withDouble :: String -> (Double -> Parser a) -> Value -> Parser a
+withDouble _ f (Number duble) = f duble
+withDouble name _ v = prependContext name (typeMismatch "Number" v)
+
+withBool :: String -> (Bool -> Parser a) -> Value -> Parser a
+withBool _ f (Bool arr) = f arr
+withBool name _ v = prependContext name (typeMismatch "Boolean" v)
+
+class FromJSON a where
+  parseJSON :: Value -> Parser a
+
+  parseJSONList :: Value -> Parser [a]
+  parseJSONList = withArray "[]" (zipWithM (parseIndexedJSON parseJSON) [0 ..])
+
+instance FromJSON Bool where
+  parseJSON (Bool b) = pure b
+  parseJSON v = typeMismatch "Bool" v
+
+instance FromJSON () where
+  parseJSON =
+    withArray "()" $ \v ->
+      if null v
+        then pure ()
+        else prependContext "()" $ fail "expected an empty array"
+
+instance FromJSON Char where
+  parseJSON = withString "Char" parseChar
+
+  parseJSONList (String s) = pure s
+  parseJSONList v = typeMismatch "String" v
+
+parseChar :: String -> Parser Char
+parseChar t =
+  if length t == 1
+    then pure $ head t
+    else prependContext "Char" $ fail "expected a string of length 1"
+
+parseRealFloat :: RealFloat a => String -> Value -> Parser a
+parseRealFloat _ (Number s) = pure $ realToFrac s
+parseRealFloat _ Null = pure (0 / 0)
+parseRealFloat name v = prependContext name (unexpected v)
+
+instance FromJSON Double where
+  parseJSON = parseRealFloat "Double"
+
+instance FromJSON Float where
+  parseJSON = parseRealFloat "Float"
+
+parseNatural :: Integer -> Parser Natural
+parseNatural integer =
+  if integer < 0
+    then fail $ "parsing Natural failed, unexpected negative number " <> show integer
+    else pure $ fromIntegral integer
+
+parseIntegralFromDouble :: Integral a => Double -> Parser a
+parseIntegralFromDouble d =
+  let r = toRational d
+      x = truncate r
+   in if toRational x == r
+        then pure x
+        else fail $ "unexpected floating number " <> show d
+
+parseIntegral :: Integral a => String -> Value -> Parser a
+parseIntegral name = withDouble name parseIntegralFromDouble
+
+instance FromJSON Integer where
+  parseJSON = parseIntegral "Integer"
+
+instance FromJSON Natural where
+  parseJSON =
+    withDouble
+      "Natural"
+      (parseIntegralFromDouble >=> parseNatural)
+
+instance FromJSON Int where
+  parseJSON = parseIntegral "Int"
+
+instance FromJSON Int8 where
+  parseJSON = parseIntegral "Int8"
+
+instance FromJSON Int16 where
+  parseJSON = parseIntegral "Int16"
+
+instance FromJSON Int32 where
+  parseJSON = parseIntegral "Int32"
+
+instance FromJSON Int64 where
+  parseJSON = parseIntegral "Int64"
+
+instance FromJSON Word where
+  parseJSON = parseIntegral "Word"
+
+instance FromJSON Word8 where
+  parseJSON = parseIntegral "Word8"
+
+instance FromJSON Word16 where
+  parseJSON = parseIntegral "Word16"
+
+instance FromJSON Word32 where
+  parseJSON = parseIntegral "Word32"
+
+instance FromJSON Word64 where
+  parseJSON = parseIntegral "Word64"
+
+instance FromJSON a => FromJSON [a] where
+  parseJSON = parseJSONList
+
+data Result a
+  = Error String
+  | Success a
+  deriving (Eq, Show)
+
+fromJSON :: FromJSON a => Value -> Result a
+fromJSON = parse parseJSON
+
+parse :: (a -> Parser b) -> a -> Result b
+parse m v = runParser (m v) [] (const Error) Success
+
+parseEither :: (a -> Parser b) -> a -> Either String b
+parseEither m v = runParser (m v) [] onError Right
+  where
+    onError path msg = Left (formatError path msg)
+
+formatError :: JSONPath -> String -> String
+formatError path msg = "Error in " ++ formatPath path ++ ": " ++ msg
+
+formatPath :: JSONPath -> String
+formatPath path = "$" ++ formatRelativePath path
+
+formatRelativePath :: JSONPath -> String
+formatRelativePath path = format "" path
+  where
+    format :: String -> JSONPath -> String
+    format pfx [] = pfx
+    format pfx (Index idx : parts) = format (pfx ++ "[" ++ show idx ++ "]") parts
+    format pfx (Key key : parts) = format (pfx ++ formatKey key) parts
+
+    formatKey :: String -> String
+    formatKey key
+      | isIdentifierKey key = "." ++ key
+      | otherwise = "['" ++ escapeKey key ++ "']"
+
+    isIdentifierKey :: String -> Bool
+    isIdentifierKey [] = False
+    isIdentifierKey (x : xs) = isAlpha x && all isAlphaNum xs
+
+    escapeKey :: String -> String
+    escapeKey = concatMap escapeChar
+
+    escapeChar :: Char -> String
+    escapeChar '\'' = "\\'"
+    escapeChar '\\' = "\\\\"
+    escapeChar c = [c]
+
+explicitParseField :: (Value -> Parser a) -> Object -> String -> Parser a
+explicitParseField p obj key =
+  case key `lookup` obj of
+    Nothing -> fail $ "key " ++ key ++ " not found"
+    Just v -> p v <?> Key key
+
+(.:) :: FromJSON a => Object -> String -> Parser a
+(.:) = explicitParseField parseJSON
+
+explicitParseFieldMaybe :: (Value -> Parser a) -> Object -> String -> Parser (Maybe a)
+explicitParseFieldMaybe p obj key =
+  case key `lookup` obj of
+    Nothing -> pure Nothing
+    Just v -> Just <$> p v <?> Key key
+
+(.:?) :: FromJSON a => Object -> String -> Parser (Maybe a)
+(.:?) = explicitParseFieldMaybe parseJSON
+
+decodeWith :: (Value -> Result a) -> BSL.ByteString -> Maybe a
+decodeWith decoder bsl =
+  case Parsec.parse parseJSONValue "<input>" bsl of
+    Left _ -> Nothing
+    Right json ->
+      case decoder json of
+        Success a -> Just a
+        Error _ -> Nothing
+
+decode :: FromJSON a => BSL.ByteString -> Maybe a
+decode = decodeWith fromJSON
+
+eitherDecodeWith :: (Value -> Result a) -> BSL.ByteString -> Either String a
+eitherDecodeWith decoder bsl =
+  case Parsec.parse parseJSONValue "<input>" bsl of
+    Left parsecError -> Left (show parsecError)
+    Right json ->
+      case decoder json of
+        Success a -> Right a
+        Error err -> Left err
+
+eitherDecode :: FromJSON a => BSL.ByteString -> Either String a
+eitherDecode = eitherDecodeWith fromJSON
+
+decodeFile :: FromJSON a => FilePath -> IO (Maybe a)
+decodeFile filePath = do
+  parsecResult <- Parsec.Lazy.parseFromFile parseJSONValue filePath
+  case parsecResult of
+    Right r ->
+      case fromJSON r of
+        Success a -> return (Just a)
+        Error _ -> return Nothing
+    Left _ -> return Nothing
+
+eitherDecodeFile :: FromJSON a => FilePath -> IO (Either String a)
+eitherDecodeFile filePath = do
+  parsecResult <- Parsec.Lazy.parseFromFile parseJSONValue filePath
+  case parsecResult of
+    Right r ->
+      case fromJSON r of
+        Success a -> return (Right a)
+        Error err -> return (Left err)
+    Left err -> return $ Left (show err)
diff --git a/utils/haddock/haddock-api/src/Haddock/Utils/Json/Parser.hs b/utils/haddock/haddock-api/src/Haddock/Utils/Json/Parser.hs
new file mode 100644
index 0000000000000000000000000000000000000000..79fc877a23b322033004cb8d7995c572bc308cb1
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Utils/Json/Parser.hs
@@ -0,0 +1,123 @@
+-- | Json "Parsec" parser, based on
+-- [json](https://hackage.haskell.org/package/json) package.
+module Haddock.Utils.Json.Parser
+  ( parseJSONValue
+  ) where
+
+import Prelude hiding (null)
+
+import Control.Applicative (Alternative (..))
+import Control.Monad (MonadPlus (..))
+import qualified Data.ByteString.Lazy.Char8 as BSCL
+import Data.Char (isHexDigit)
+import Data.Functor (($>))
+import Numeric
+import Text.Parsec.ByteString.Lazy (Parser)
+import Text.ParserCombinators.Parsec ((<?>))
+import qualified Text.ParserCombinators.Parsec as Parsec
+
+import Haddock.Utils.Json.Types hiding (object)
+
+parseJSONValue :: Parser Value
+parseJSONValue = Parsec.spaces *> parseValue
+
+tok :: Parser a -> Parser a
+tok p = p <* Parsec.spaces
+
+parseValue :: Parser Value
+parseValue =
+  parseNull
+    <|> Bool
+    <$> parseBoolean
+      <|> Array
+    <$> parseArray
+      <|> String
+    <$> parseString
+      <|> Object
+    <$> parseObject
+      <|> Number
+    <$> parseNumber
+      <?> "JSON value"
+
+parseNull :: Parser Value
+parseNull =
+  tok $
+    Parsec.string "null"
+      $> Null
+
+parseBoolean :: Parser Bool
+parseBoolean =
+  tok $
+    Parsec.string "true"
+      $> True
+        <|> Parsec.string "false"
+      $> False
+
+parseArray :: Parser [Value]
+parseArray =
+  Parsec.between
+    (tok (Parsec.char '['))
+    (tok (Parsec.char ']'))
+    (parseValue `Parsec.sepBy` tok (Parsec.char ','))
+
+parseString :: Parser String
+parseString =
+  Parsec.between
+    (tok (Parsec.char '"'))
+    (tok (Parsec.char '"'))
+    (many char)
+  where
+    char =
+      (Parsec.char '\\' >> escapedChar)
+        <|> Parsec.satisfy (\x -> x /= '"' && x /= '\\')
+
+    escapedChar =
+      Parsec.char '"'
+        $> '"'
+          <|> Parsec.char '\\'
+        $> '\\'
+          <|> Parsec.char '/'
+        $> '/'
+          <|> Parsec.char 'b'
+        $> '\b'
+          <|> Parsec.char 'f'
+        $> '\f'
+          <|> Parsec.char 'n'
+        $> '\n'
+          <|> Parsec.char 'r'
+        $> '\r'
+          <|> Parsec.char 't'
+        $> '\t'
+          <|> Parsec.char 'u'
+        *> uni
+          <?> "escape character"
+
+    uni = check =<< Parsec.count 4 (Parsec.satisfy isHexDigit)
+      where
+        check x
+          | code <= max_char = return (toEnum code)
+          | otherwise = mzero
+          where
+            code = fst $ head $ readHex x
+            max_char = fromEnum (maxBound :: Char)
+
+parseObject :: Parser Object
+parseObject =
+  Parsec.between
+    (tok (Parsec.char '{'))
+    (tok (Parsec.char '}'))
+    (field `Parsec.sepBy` tok (Parsec.char ','))
+  where
+    field :: Parser (String, Value)
+    field =
+      (,)
+        <$> parseString
+        <* tok (Parsec.char ':')
+        <*> parseValue
+
+parseNumber :: Parser Double
+parseNumber = tok $ do
+  s <- BSCL.unpack <$> Parsec.getInput
+  case readSigned readFloat s of
+    [(n, s')] -> Parsec.setInput (BSCL.pack s') $> n
+    _ -> mzero
diff --git a/utils/haddock/haddock-api/src/Haddock/Utils/Json/Types.hs b/utils/haddock/haddock-api/src/Haddock/Utils/Json/Types.hs
new file mode 100644
index 0000000000000000000000000000000000000000..7887ecf16c22f9bdc8227eb37bd58db45dd07463
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Utils/Json/Types.hs
@@ -0,0 +1,43 @@
+module Haddock.Utils.Json.Types
+  ( Value (..)
+  , typeOf
+  , Pair
+  , Object
+  , object
+  ) where
+
+import Data.String
+
+-- TODO: We may want to replace 'String' with 'Text' or 'ByteString'
+
+-- | A JSON value represented as a Haskell value.
+data Value
+  = Object !Object
+  | Array [Value]
+  | String String
+  | Number !Double
+  | Bool !Bool
+  | Null
+  deriving (Eq, Read, Show)
+
+typeOf :: Value -> String
+typeOf v = case v of
+  Object _ -> "Object"
+  Array _ -> "Array"
+  String _ -> "String"
+  Number _ -> "Number"
+  Bool _ -> "Boolean"
+  Null -> "Null"
+
+-- | A key\/value pair for an 'Object'
+type Pair = (String, Value)
+
+-- | A JSON \"object\" (key/value map).
+type Object = [Pair]
+
+-- | Create a 'Value' from a list of name\/value 'Pair's.
+object :: [Pair] -> Value
+object = Object
+
+instance IsString Value where
+  fromString = String
diff --git a/utils/haddock/haddock-api/src/Haddock/Version.hs b/utils/haddock/haddock-api/src/Haddock/Version.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4ff3f4c00023c5f851574188452760731017325d
--- /dev/null
+++ b/utils/haddock/haddock-api/src/Haddock/Version.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE CPP #-}
+
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
+-- |
+-- Module      :  Haddock.Version
+-- Copyright   :  (c) Simon Marlow 2003
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+module Haddock.Version
+  ( projectName
+  , projectVersion
+  , projectUrl
+  ) where
+
+#ifdef IN_GHC_TREE
+import Paths_haddock ( version )
+#else
+import Paths_haddock_api ( version )
+#endif
+import Data.Version (showVersion)
+
+projectName :: String
+projectName = "Haddock"
+
+projectUrl :: String
+projectUrl = "http://www.haskell.org/haddock/"
+
+projectVersion :: String
+projectVersion = showVersion version
diff --git a/utils/haddock/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs b/utils/haddock/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs
new file mode 100644
index 0000000000000000000000000000000000000000..7ec182bffa170f371c409b706f054243b0fd56f2
--- /dev/null
+++ b/utils/haddock/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs
@@ -0,0 +1,216 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Haddock.Backends.Hyperlinker.ParserSpec (main, spec) where
+
+import Test.Hspec
+import Test.QuickCheck
+
+import Control.Monad.IO.Class
+import GHC (getSessionDynFlags, runGhc)
+import GHC.Driver.Session (DynFlags)
+
+import Data.ByteString (ByteString)
+import qualified Data.ByteString as BS
+import Data.String (fromString)
+
+import Haddock (getGhcDirs)
+import Haddock.Backends.Hyperlinker.Parser
+import Haddock.Backends.Hyperlinker.Types
+
+withDynFlags :: (DynFlags -> IO ()) -> IO ()
+withDynFlags cont = do
+  libDir <- fmap snd (getGhcDirs [])
+  runGhc libDir $ do
+    dflags <- getSessionDynFlags
+    liftIO $ cont dflags
+
+main :: IO ()
+main = hspec spec
+
+spec :: Spec
+spec = describe "parse" parseSpec
+
+-- | Defined for its instance of 'Arbitrary'. Represents strings that, when
+-- considered as GHC source, won't be rewritten.
+newtype NoGhcRewrite = NoGhcRewrite String deriving (Show, Eq)
+
+-- | Filter out strings where GHC would replace/remove some characters during
+-- lexing.
+noGhcRewrite :: String -> Bool
+noGhcRewrite ('\t' : _) = False -- GHC replaces tabs with 8 spaces
+noGhcRewrite ('\r' : _) = False
+noGhcRewrite ('\f' : _) = False
+noGhcRewrite ('\v' : _) = False
+noGhcRewrite (' ' : '\n' : _) = False -- GHC strips whitespace on empty lines
+noGhcRewrite (_ : s) = noGhcRewrite s
+noGhcRewrite "" = True
+
+instance Arbitrary NoGhcRewrite where
+  arbitrary = fmap NoGhcRewrite (arbitrary `suchThat` noGhcRewrite)
+  shrink (NoGhcRewrite src) =
+    [ NoGhcRewrite shrunk
+    | shrunk <- shrink src
+    , noGhcRewrite shrunk
+    ]
+
+parseSpec :: Spec
+parseSpec = around withDynFlags $ do
+  it "is total" $ \dflags ->
+    property $ \src -> length (parse dflags "" (fromString src)) `shouldSatisfy` (>= 0)
+
+  it "retains file layout" $ \dflags ->
+    property $ \(NoGhcRewrite src) ->
+      let orig = fromString src
+          lexed = BS.concat (map tkValue (parse dflags "" orig))
+       in lexed == orig
+
+  context "when parsing single-line comments" $ do
+    it "should ignore content until the end of line" $ \dflags ->
+      shouldParseTo
+        "-- some very simple comment\nidentifier"
+        [TkComment, TkSpace, TkIdentifier]
+        dflags
+
+    it "should allow endline escaping" $ \dflags ->
+      shouldParseTo
+        "#define first line\\\nsecond line\\\nand another one"
+        [TkCpp]
+        dflags
+
+  context "when parsing multi-line comments" $ do
+    it "should support nested comments" $ \dflags ->
+      shouldParseTo
+        "{- comment {- nested -} still comment -} {- next comment -}"
+        [TkComment, TkSpace, TkComment]
+        dflags
+
+    it "should distinguish compiler pragma" $ \dflags ->
+      shouldParseTo
+        "{- comment -}{-# LANGUAGE GADTs #-}{- comment -}"
+        [TkComment, TkPragma, TkComment]
+        dflags
+
+  it "should recognize preprocessor directives" $ \dflags -> do
+    shouldParseTo
+      "\n#define foo bar"
+      [TkCpp]
+      dflags
+    shouldParseTo
+      "x # y"
+      [TkIdentifier, TkSpace, TkOperator, TkSpace, TkIdentifier]
+      dflags
+
+  it "should distinguish basic language constructs" $ \dflags -> do
+    shouldParseTo
+      "(* 2) <$> (\"abc\", foo)"
+      [ TkSpecial
+      , TkOperator
+      , TkSpace
+      , TkNumber
+      , TkSpecial
+      , TkSpace
+      , TkOperator
+      , TkSpace
+      , TkSpecial
+      , TkString
+      , TkSpecial
+      , TkSpace
+      , TkIdentifier
+      , TkSpecial
+      ]
+      dflags
+
+    shouldParseTo
+      "let foo' = foo in foo' + foo'"
+      [ TkKeyword
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkGlyph
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkKeyword
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkOperator
+      , TkSpace
+      , TkIdentifier
+      ]
+      dflags
+
+    shouldParseTo
+      "square x = y^2 where y = x"
+      [ TkIdentifier
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkGlyph
+      , TkSpace
+      , TkIdentifier
+      , TkOperator
+      , TkNumber
+      , TkSpace
+      , TkKeyword
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkGlyph
+      , TkSpace
+      , TkIdentifier
+      ]
+      dflags
+
+  it "should parse do-notation syntax" $ \dflags -> do
+    shouldParseTo
+      "do { foo <- getLine; putStrLn foo }"
+      [ TkKeyword
+      , TkSpace
+      , TkSpecial
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkGlyph
+      , TkSpace
+      , TkIdentifier
+      , TkSpecial
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkSpecial
+      ]
+      dflags
+
+    shouldParseTo
+      ( fromString $
+          unlines
+            [ "do"
+            , "    foo <- getLine"
+            , "    putStrLn foo"
+            ]
+      )
+      [ TkKeyword
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkGlyph
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      , TkIdentifier
+      , TkSpace
+      ]
+      dflags
+  where
+    shouldParseTo :: ByteString -> [TokenType] -> DynFlags -> Expectation
+    shouldParseTo str tokens dflags =
+      [ tkType tok
+      | tok <- parse dflags "" str
+      , not (BS.null (tkValue tok))
+      ]
+        `shouldBe` tokens
diff --git a/utils/haddock/haddock-api/test/Spec.hs b/utils/haddock/haddock-api/test/Spec.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a824f8c30c8d0402a34ed34ad58153e59f95b76f
--- /dev/null
+++ b/utils/haddock/haddock-api/test/Spec.hs
@@ -0,0 +1 @@
+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
diff --git a/utils/haddock/haddock-library/CHANGES.md b/utils/haddock/haddock-library/CHANGES.md
new file mode 100644
index 0000000000000000000000000000000000000000..b34822092e68949fb04f82b882233ebdf3c11602
--- /dev/null
+++ b/utils/haddock/haddock-library/CHANGES.md
@@ -0,0 +1,48 @@
+## Changes in version 1.11.0
+
+  * Add support for linking identifiers with a quote between backticks (#1408)
+
+## Changes in version 1.10.0
+
+  * Add support for labeled module references (#1360)
+## Changes in version 1.9.0
+
+ * Fix build-time regression for `base < 4.7` (#1119)
+
+ * Update parsing to strip whitespace from table cells (#1074)
+
+## Changes in version 1.8.0
+
+ * Support inline markup in markdown-style links (#875)
+
+ * Remove now unused `Documentation.Haddock.Utf8` module.
+   This module was anyways copied from the `utf8-string` package.
+
+## Changes in version 1.7.0
+
+ * Make `Documentation.Haddock.Parser.Monad` an internal module
+
+## Changes in version 1.6.1
+
+ * Replace `attoparsec` with `parsec` (#799)
+
+## Changes in version 1.6.0
+
+ * `MetaDoc` stores package name for since annotations
+
+## Changes in version 1.5.0.1
+
+ * Support for parsing unicode operators (#458)
+
+## Changes in version 1.5.0
+
+ * Bifunctor, Bifoldable and Bitraversable instances for DocH and MetaDoc
+
+ * Support for grid tables
+   * added `DocTable` constructor to `DocH`
+   * added `Table`, `TableCell` and `TableRow` data types
+   * added `markupTable` to `DocMarkupH` data type
+
+## Changes in version 1.4.5
+
+ * Move markup related data types to haddock-library
diff --git a/utils/haddock/haddock-library/LICENSE b/utils/haddock/haddock-library/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..d5f0b37c4140c901b64760bfca422e1cd94a5e1c
--- /dev/null
+++ b/utils/haddock/haddock-library/LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2002-2010, Simon Marlow
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the
+   distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/utils/haddock/haddock-library/Setup.hs b/utils/haddock/haddock-library/Setup.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e8ef27dbba9992f80d9271a60892aadc63c9ef36
--- /dev/null
+++ b/utils/haddock/haddock-library/Setup.hs
@@ -0,0 +1,3 @@
+import Distribution.Simple
+
+main = defaultMain
diff --git a/utils/haddock/haddock-library/fixtures/Fixtures.hs b/utils/haddock/haddock-library/fixtures/Fixtures.hs
new file mode 100644
index 0000000000000000000000000000000000000000..21655360e42935b52c7153583fb8606116765363
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/Fixtures.hs
@@ -0,0 +1,176 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Main (main) where
+
+import Control.Applicative ((<|>))
+import Control.Exception (IOException, catch)
+import Control.Monad (when)
+import Data.Foldable (traverse_)
+import Data.List (foldl')
+import Data.Traversable (for)
+import GHC.Generics (Generic)
+import System.Directory (getDirectoryContents)
+import System.Exit (exitFailure)
+import System.FilePath
+import System.IO
+import Prelude
+
+import Data.TreeDiff
+import Data.TreeDiff.Golden
+
+import qualified Options.Applicative as O
+
+import qualified Documentation.Haddock.Parser as Parse
+import Documentation.Haddock.Types
+
+type Doc id = DocH () id
+
+data Fixture = Fixture
+  { fixtureName :: FilePath
+  , fixtureOutput :: FilePath
+  }
+  deriving (Show)
+
+data Result = Result
+  { _resultSuccess :: !Int
+  , _resultTotal :: !Int
+  }
+  deriving (Show)
+
+combineResults :: Result -> Result -> Result
+combineResults (Result s t) (Result s' t') = Result (s + s') (t + t')
+
+readFixtures :: IO [Fixture]
+readFixtures = do
+  let dir = "fixtures/examples"
+  files <- getDirectoryContents dir
+  let inputs = filter (\fp -> takeExtension fp == ".input") files
+  return $ flip map inputs $ \fp ->
+    Fixture
+      { fixtureName = dir </> fp
+      , fixtureOutput = dir </> fp -<.> "parsed"
+      }
+
+goldenFixture
+  :: String
+  -> IO Expr
+  -> IO Expr
+  -> (Expr -> Expr -> IO (Maybe String))
+  -> (Expr -> IO ())
+  -> IO Result
+goldenFixture name expect actual cmp wrt = do
+  putStrLn $ "running " ++ name
+  a <- actual
+  e <- expect `catch` handler a
+  mres <- cmp e a
+  case mres of
+    Nothing -> return (Result 1 1)
+    Just str -> do
+      putStrLn str
+      return (Result 0 1)
+  where
+    handler :: Expr -> IOException -> IO Expr
+    handler a exc = do
+      putStrLn $ "Caught " ++ show exc
+      putStrLn "Accepting the test"
+      wrt a
+      return a
+
+runFixtures :: [Fixture] -> IO ()
+runFixtures fixtures = do
+  results <- for fixtures $ \(Fixture i o) -> do
+    let name = takeBaseName i
+    let readDoc = do
+          input <- readFile i
+          return (parseString input)
+    ediffGolden goldenFixture name o readDoc
+  case foldl' combineResults (Result 0 0) results of
+    Result s t -> do
+      putStrLn $ "Fixtures: success " ++ show s ++ "; total " ++ show t
+      when (s /= t) exitFailure
+
+listFixtures :: [Fixture] -> IO ()
+listFixtures = traverse_ $ \(Fixture i _) -> do
+  let name = takeBaseName i
+  putStrLn name
+
+acceptFixtures :: [Fixture] -> IO ()
+acceptFixtures = traverse_ $ \(Fixture i o) -> do
+  input <- readFile i
+  let doc = parseString input
+  let actual = show (prettyExpr $ toExpr doc) ++ "\n"
+  writeFile o actual
+
+parseString :: String -> Doc String
+parseString = Parse.toRegular . _doc . Parse.parseParas Nothing
+
+data Cmd = CmdRun | CmdAccept | CmdList
+
+main :: IO ()
+main = do
+  hSetBuffering stdout NoBuffering -- For interleaved output when debugging
+  runCmd =<< O.execParser opts
+  where
+    opts = O.info (O.helper <*> cmdParser) O.fullDesc
+
+    cmdParser :: O.Parser Cmd
+    cmdParser = cmdRun <|> cmdAccept <|> cmdList <|> pure CmdRun
+
+    cmdRun =
+      O.flag' CmdRun $
+        mconcat
+          [ O.long "run"
+          , O.help "Run parser fixtures"
+          ]
+
+    cmdAccept =
+      O.flag' CmdAccept $
+        mconcat
+          [ O.long "accept"
+          , O.help "Run & accept parser fixtures"
+          ]
+
+    cmdList =
+      O.flag' CmdList $
+        mconcat
+          [ O.long "list"
+          , O.help "List fixtures"
+          ]
+
+runCmd :: Cmd -> IO ()
+runCmd CmdRun = readFixtures >>= runFixtures
+runCmd CmdList = readFixtures >>= listFixtures
+runCmd CmdAccept = readFixtures >>= acceptFixtures
+
+-------------------------------------------------------------------------------
+-- Orphans
+-------------------------------------------------------------------------------
+
+deriving instance Generic (DocH mod id)
+instance (ToExpr mod, ToExpr id) => ToExpr (DocH mod id)
+
+deriving instance Generic (Header id)
+instance ToExpr id => ToExpr (Header id)
+
+deriving instance Generic (Hyperlink id)
+instance ToExpr id => ToExpr (Hyperlink id)
+
+deriving instance Generic (ModLink id)
+instance ToExpr id => ToExpr (ModLink id)
+
+deriving instance Generic Picture
+instance ToExpr Picture
+
+deriving instance Generic Example
+instance ToExpr Example
+
+deriving instance Generic (Table id)
+instance ToExpr id => ToExpr (Table id)
+
+deriving instance Generic (TableRow id)
+instance ToExpr id => ToExpr (TableRow id)
+
+deriving instance Generic (TableCell id)
+instance ToExpr id => ToExpr (TableCell id)
diff --git a/utils/haddock/haddock-library/fixtures/examples/definitionList.input b/utils/haddock/haddock-library/fixtures/examples/definitionList.input
new file mode 100644
index 0000000000000000000000000000000000000000..e1bffb21cb85f9115d4c599b0ece51b7726d08fd
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/definitionList.input
@@ -0,0 +1 @@
+[foo]: bar
diff --git a/utils/haddock/haddock-library/fixtures/examples/definitionList.parsed b/utils/haddock/haddock-library/fixtures/examples/definitionList.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..048aa1419713bb37f50ec9276d2883e949cc7d85
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/definitionList.parsed
@@ -0,0 +1 @@
+DocDefList [_×_ (DocString "foo") (DocString "bar")]
diff --git a/utils/haddock/haddock-library/fixtures/examples/identifier.input b/utils/haddock/haddock-library/fixtures/examples/identifier.input
new file mode 100644
index 0000000000000000000000000000000000000000..c2c4af01dc2a7d2a468fc81438ff6a3a2d855ca7
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/identifier.input
@@ -0,0 +1 @@
+'foo'
diff --git a/utils/haddock/haddock-library/fixtures/examples/identifier.parsed b/utils/haddock/haddock-library/fixtures/examples/identifier.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..3405a5c984148565d25bd7bd0077588f99a276ac
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/identifier.parsed
@@ -0,0 +1 @@
+DocParagraph (DocIdentifier "foo")
diff --git a/utils/haddock/haddock-library/fixtures/examples/identifierBackticks.input b/utils/haddock/haddock-library/fixtures/examples/identifierBackticks.input
new file mode 100644
index 0000000000000000000000000000000000000000..347253a079966d6a79aed8825ea337ba203cb94b
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/identifierBackticks.input
@@ -0,0 +1 @@
+`foo`
diff --git a/utils/haddock/haddock-library/fixtures/examples/identifierBackticks.parsed b/utils/haddock/haddock-library/fixtures/examples/identifierBackticks.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..3405a5c984148565d25bd7bd0077588f99a276ac
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/identifierBackticks.parsed
@@ -0,0 +1 @@
+DocParagraph (DocIdentifier "foo")
diff --git a/utils/haddock/haddock-library/fixtures/examples/link.input b/utils/haddock/haddock-library/fixtures/examples/link.input
new file mode 100644
index 0000000000000000000000000000000000000000..a55c05a65d492009c1d5fd692241aa3225036349
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/link.input
@@ -0,0 +1 @@
+[link](http://example.com)
diff --git a/utils/haddock/haddock-library/fixtures/examples/link.parsed b/utils/haddock/haddock-library/fixtures/examples/link.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..781dee87b806fae6dd845eb6147b89045e269742
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/link.parsed
@@ -0,0 +1,5 @@
+DocParagraph
+  (DocHyperlink
+     Hyperlink
+       {hyperlinkLabel = Just (DocString "link"),
+        hyperlinkUrl = "http://example.com"})
diff --git a/utils/haddock/haddock-library/fixtures/examples/linkInline.input b/utils/haddock/haddock-library/fixtures/examples/linkInline.input
new file mode 100644
index 0000000000000000000000000000000000000000..eeca5a07948c3d507d13f004308d0689a117b74c
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/linkInline.input
@@ -0,0 +1 @@
+Bla [link](http://example.com)
diff --git a/utils/haddock/haddock-library/fixtures/examples/linkInline.parsed b/utils/haddock/haddock-library/fixtures/examples/linkInline.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..fe77159885d89caccf79f357dceff8d87d31c182
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/linkInline.parsed
@@ -0,0 +1,7 @@
+DocParagraph
+  (DocAppend
+     (DocString "Bla ")
+     (DocHyperlink
+        Hyperlink
+          {hyperlinkLabel = Just (DocString "link"),
+           hyperlinkUrl = "http://example.com"}))
diff --git a/utils/haddock/haddock-library/fixtures/examples/linkInlineMarkup.input b/utils/haddock/haddock-library/fixtures/examples/linkInlineMarkup.input
new file mode 100644
index 0000000000000000000000000000000000000000..e2f4e405b4bb55a5cd0c1efb2bfc73fadecf6625
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/linkInlineMarkup.input
@@ -0,0 +1 @@
+Bla [link /emphasized/](http://example.com)
diff --git a/utils/haddock/haddock-library/fixtures/examples/linkInlineMarkup.parsed b/utils/haddock/haddock-library/fixtures/examples/linkInlineMarkup.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..39adab641990411acdf2da098e05c70adc2a5afd
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/linkInlineMarkup.parsed
@@ -0,0 +1,8 @@
+DocParagraph
+  (DocAppend
+     (DocString "Bla ")
+     (DocHyperlink
+        Hyperlink
+          {hyperlinkLabel = Just (DocAppend (DocString "link ")
+                                            (DocEmphasis (DocString "emphasized"))),
+           hyperlinkUrl = "http://example.com"}))
diff --git a/utils/haddock/haddock-library/fixtures/examples/list-blocks1.input b/utils/haddock/haddock-library/fixtures/examples/list-blocks1.input
new file mode 100644
index 0000000000000000000000000000000000000000..72a0640b2cc7019d841634748f8c7473bfac6af8
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/list-blocks1.input
@@ -0,0 +1,15 @@
+* Something about foo
+
+    @
+    foo :: a -> b -> c
+    foo a b = bar c b
+    @
+
+* Something about bar
+
+    @
+    bar :: a -> b -> c
+    bar a b = foo b a
+    @
+
+* And then we continue
diff --git a/utils/haddock/haddock-library/fixtures/examples/list-blocks1.parsed b/utils/haddock/haddock-library/fixtures/examples/list-blocks1.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..9fc4f0ba1feeae047c2b5a46925c8e1e963cda0e
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/list-blocks1.parsed
@@ -0,0 +1,12 @@
+DocUnorderedList
+  [DocAppend
+     (DocParagraph (DocString "Something about foo"))
+     (DocCodeBlock
+        (DocString
+           (concat ["foo :: a -> b -> c\n", "foo a b = bar c b\n"]))),
+   DocAppend
+     (DocParagraph (DocString "Something about bar"))
+     (DocCodeBlock
+        (DocString
+           (concat ["bar :: a -> b -> c\n", "bar a b = foo b a\n"]))),
+   DocParagraph (DocString "And then we continue")]
diff --git a/utils/haddock/haddock-library/fixtures/examples/list-blocks2.input b/utils/haddock/haddock-library/fixtures/examples/list-blocks2.input
new file mode 100644
index 0000000000000000000000000000000000000000..91492adb0d93a70d97a25ee86f7b395b9dbd7115
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/list-blocks2.input
@@ -0,0 +1,10 @@
+=== Title
+
+* List directly
+* after the title
+
+    @
+    with some inline things
+    @
+
+* is parsed weirdly
diff --git a/utils/haddock/haddock-library/fixtures/examples/list-blocks2.parsed b/utils/haddock/haddock-library/fixtures/examples/list-blocks2.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..169677b7ca30feaecf71ac20fc677c43c0b7c3f3
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/list-blocks2.parsed
@@ -0,0 +1,10 @@
+DocAppend
+  (DocAppend
+     (DocHeader
+        Header {headerLevel = 3, headerTitle = DocString "Title"})
+     (DocUnorderedList
+        [DocParagraph (DocString "List directly"),
+         DocAppend
+           (DocParagraph (DocString "after the title"))
+           (DocCodeBlock (DocString "with some inline things\n"))]))
+  (DocUnorderedList [DocParagraph (DocString "is parsed weirdly")])
diff --git a/utils/haddock/haddock-library/fixtures/examples/table-cell-strip-whitespaces.input b/utils/haddock/haddock-library/fixtures/examples/table-cell-strip-whitespaces.input
new file mode 100644
index 0000000000000000000000000000000000000000..f5e3756dcdb78487d891c7bbaacb08e9cf66437c
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table-cell-strip-whitespaces.input
@@ -0,0 +1,5 @@
++------+--------------+-------------------------------------------------+
+| C1   |     C2       |         C3                                      |
++======+==============+=================================================+
+| row  | 'test'       | 'test table cell with  .. whitepspace '         |
++------+--------------+-------------------------------------------------+
diff --git a/utils/haddock/haddock-library/fixtures/examples/table-cell-strip-whitespaces.parsed b/utils/haddock/haddock-library/fixtures/examples/table-cell-strip-whitespaces.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..190023697ddc8fedacc4ac27cc5a1cba104f0cde
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table-cell-strip-whitespaces.parsed
@@ -0,0 +1,29 @@
+DocTable
+  Table
+    {tableBodyRows = [TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "row",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocIdentifier "test",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString
+                                                  "'test table cell with  .. whitepspace '",
+                            tableCellRowspan = 1}]],
+     tableHeaderRows = [TableRow
+                          [TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "C1",
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "C2",
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "C3",
+                              tableCellRowspan = 1}]]}
diff --git a/utils/haddock/haddock-library/fixtures/examples/table-simple.input b/utils/haddock/haddock-library/fixtures/examples/table-simple.input
new file mode 100644
index 0000000000000000000000000000000000000000..d9c49f87038225e8b1353b26a2091201c2cffb71
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table-simple.input
@@ -0,0 +1,7 @@
++------+--------------+------------------------------------------+
+| code | message      | description                              |
++======+==============+==========================================+
+| 200  |   @OK@       | operation successful                     |
++------+--------------+------------------------------------------+
+| 204  | @No Content@ | operation successful, no body returned   |
++------+--------------+------------------------------------------+
diff --git a/utils/haddock/haddock-library/fixtures/examples/table-simple.parsed b/utils/haddock/haddock-library/fixtures/examples/table-simple.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..d027c75d6e11e082bfac3f2de8b161de8431f881
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table-simple.parsed
@@ -0,0 +1,42 @@
+DocTable
+  Table
+    {tableBodyRows = [TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "200",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocMonospaced (DocString "OK"),
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "operation successful",
+                            tableCellRowspan = 1}],
+                      TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "204",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocMonospaced (DocString "No Content"),
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString
+                                                  "operation successful, no body returned",
+                            tableCellRowspan = 1}]],
+     tableHeaderRows = [TableRow
+                          [TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "code",
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "message",
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "description",
+                              tableCellRowspan = 1}]]}
diff --git a/utils/haddock/haddock-library/fixtures/examples/table1.input b/utils/haddock/haddock-library/fixtures/examples/table1.input
new file mode 100644
index 0000000000000000000000000000000000000000..a007020c7363e2b030f60c795b876de05e264d18
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table1.input
@@ -0,0 +1,12 @@
++------------------------+------------+----------+----------+
+| Header row, column 1   | Header 2   | Header 3 | Header 4 |
+| (header rows optional) |            |          |          |
++========================+============+==========+==========+
+| body row 1, column 1   | column 2   | column 3 | column 4 |
++------------------------+------------+----------+----------+
+| body row 2             | Cells may span columns.          |
++------------------------+------------+---------------------+
+| body row 3             | Cells may  | \[                  |
++------------------------+ span rows. | f(n) = \sum_{i=1}   |
+| body row 4             |            | \]                  |
++------------------------+------------+---------------------+
diff --git a/utils/haddock/haddock-library/fixtures/examples/table1.parsed b/utils/haddock/haddock-library/fixtures/examples/table1.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..8b8908f4cff02fd7e63396f84787ab9969ad9e6e
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table1.parsed
@@ -0,0 +1,68 @@
+DocTable
+  Table
+    {tableBodyRows = [TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "body row 1, column 1",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "column 2",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "column 3",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "column 4",
+                            tableCellRowspan = 1}],
+                      TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "body row 2",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 3,
+                            tableCellContents = DocString "Cells may span columns.",
+                            tableCellRowspan = 1}],
+                      TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "body row 3",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString
+                                                  (concat ["Cells may\n", "span rows.\n"]),
+                            tableCellRowspan = 2},
+                         TableCell
+                           {tableCellColspan = 2,
+                            tableCellContents = DocMathDisplay
+                                                  (concat ["\n", "f(n) = \\sum_{i=1}\n"]),
+                            tableCellRowspan = 2}],
+                      TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "body row 4",
+                            tableCellRowspan = 1}]],
+     tableHeaderRows = [TableRow
+                          [TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString
+                                                    (concat
+                                                       ["Header row, column 1\n",
+                                                        "(header rows optional)"]),
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "Header 2\n",
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "Header 3\n",
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "Header 4\n",
+                              tableCellRowspan = 1}]]}
diff --git a/utils/haddock/haddock-library/fixtures/examples/table2.input b/utils/haddock/haddock-library/fixtures/examples/table2.input
new file mode 100644
index 0000000000000000000000000000000000000000..aa5d08624c32763c50f7e11d7ce936e27a0b3db3
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table2.input
@@ -0,0 +1,7 @@
++--------------+----------+-----------+-----------+
+| row 1, col 1 | column 2 | column 3  | column 4  |
++--------------+----------+-----------+-----------+
+| row 2        |                                  |
++--------------+----------+-----------+-----------+
+| row 3        |          |           |           |
++--------------+----------+-----------+-----------+
diff --git a/utils/haddock/haddock-library/fixtures/examples/table2.parsed b/utils/haddock/haddock-library/fixtures/examples/table2.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..44cc813b6de99afb814cc4002ea959fe727ac5b7
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table2.parsed
@@ -0,0 +1,46 @@
+DocTable
+  Table
+    {tableBodyRows = [TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "row 1, col 1",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "column 2",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "column 3",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "column 4",
+                            tableCellRowspan = 1}],
+                      TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "row 2",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 3,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1}],
+                      TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "row 3",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1}]],
+     tableHeaderRows = []}
diff --git a/utils/haddock/haddock-library/fixtures/examples/table3.input b/utils/haddock/haddock-library/fixtures/examples/table3.input
new file mode 100644
index 0000000000000000000000000000000000000000..a6ca84ca889e39bc2ff3c91600a3919f472e5ba8
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table3.input
@@ -0,0 +1,7 @@
++--------------+----------+-----------+-----------+
+| row 1, col 1 | column 2 | column 3  | column 4  |
++--------------+----------+-----------+-----------+
+| row 2        | Use the command ``ls | more``.   |
++--------------+----------+-----------+-----------+
+| row 3        |          |           |           |
++--------------+----------+-----------+-----------+
diff --git a/utils/haddock/haddock-library/fixtures/examples/table3.parsed b/utils/haddock/haddock-library/fixtures/examples/table3.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..c978b50f76184bec602693c6f802196420e43593
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table3.parsed
@@ -0,0 +1,50 @@
+DocTable
+  Table
+    {tableBodyRows = [TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "row 1, col 1",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "column 2",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "column 3",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "column 4",
+                            tableCellRowspan = 1}],
+                      TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "row 2",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 2,
+                            tableCellContents = DocString "Use the command ``ls",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "more``.",
+                            tableCellRowspan = 1}],
+                      TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString "row 3",
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1}]],
+     tableHeaderRows = []}
diff --git a/utils/haddock/haddock-library/fixtures/examples/table4.input b/utils/haddock/haddock-library/fixtures/examples/table4.input
new file mode 100644
index 0000000000000000000000000000000000000000..2c5611c83d4c2c7a9b34a1db3a024636ad056ff8
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table4.input
@@ -0,0 +1,17 @@
+Single outer cell:
+
++-------------+
+|   outer     |
+|             |
++-------+     |
+| inner |     |
++-------+-----+
+
+Broken (only inner cell is rendered):
+
++-------+-----+
+| inner |     |
++-------+     |
+|             |
+|   outer     |
++-------------+
diff --git a/utils/haddock/haddock-library/fixtures/examples/table4.parsed b/utils/haddock/haddock-library/fixtures/examples/table4.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..c4dabb0d6c288bc0af53f53d74d9ff45acd9a300
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table4.parsed
@@ -0,0 +1,26 @@
+DocAppend
+  (DocParagraph (DocString "Single outer cell:"))
+  (DocAppend
+     (DocTable
+        Table
+          {tableBodyRows = [TableRow
+                              [TableCell
+                                 {tableCellColspan = 1,
+                                  tableCellContents = DocString
+                                                        (concat
+                                                           ["outer\n",
+                                                            "\n",
+                                                            "-------+\n",
+                                                            "inner |"]),
+                                  tableCellRowspan = 1}]],
+           tableHeaderRows = []})
+     (DocAppend
+        (DocParagraph (DocString "Broken (only inner cell is rendered):"))
+        (DocTable
+           Table
+             {tableBodyRows = [TableRow
+                                 [TableCell
+                                    {tableCellColspan = 1,
+                                     tableCellContents = DocString "inner",
+                                     tableCellRowspan = 1}]],
+              tableHeaderRows = []})))
diff --git a/utils/haddock/haddock-library/fixtures/examples/table5.input b/utils/haddock/haddock-library/fixtures/examples/table5.input
new file mode 100644
index 0000000000000000000000000000000000000000..7cf26512968d201712701517ca0c38ab7fdc21e2
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table5.input
@@ -0,0 +1,8 @@
++--------------+----------+-----------+-----------+
+| row 1, col 1 | column 2 | column 3  | column 4  |
++==============+==========+===========+===========+
+| row 2        | Use the command  @ls | more@.    |
+|              |                                  |
+|              +----------+-----------+-----------+
+| row 3        |          |           |           |
++--------------+----------+-----------+-----------+
diff --git a/utils/haddock/haddock-library/fixtures/examples/table5.parsed b/utils/haddock/haddock-library/fixtures/examples/table5.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..f9a387bb0c5b3d698b79ea538d73054d85dd5cc7
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/table5.parsed
@@ -0,0 +1,46 @@
+DocTable
+  Table
+    {tableBodyRows = [TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocString
+                                                  (concat ["row 2\n", "\n", "\n", "row 3"]),
+                            tableCellRowspan = 2},
+                         TableCell
+                           {tableCellColspan = 3,
+                            tableCellContents = DocAppend
+                                                  (DocString "Use the command  ")
+                                                  (DocAppend
+                                                     (DocMonospaced (DocString "ls | more"))
+                                                     (DocString ".\n")),
+                            tableCellRowspan = 1}],
+                      TableRow
+                        [TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1},
+                         TableCell
+                           {tableCellColspan = 1,
+                            tableCellContents = DocEmpty,
+                            tableCellRowspan = 1}]],
+     tableHeaderRows = [TableRow
+                          [TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "row 1, col 1",
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "column 2",
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "column 3",
+                              tableCellRowspan = 1},
+                           TableCell
+                             {tableCellColspan = 1,
+                              tableCellContents = DocString "column 4",
+                              tableCellRowspan = 1}]]}
diff --git a/utils/haddock/haddock-library/fixtures/examples/url.input b/utils/haddock/haddock-library/fixtures/examples/url.input
new file mode 100644
index 0000000000000000000000000000000000000000..5bfed0a12b23fae13f2d2f5a87e22e7dc2aa061f
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/url.input
@@ -0,0 +1 @@
+<http://example.com/>
diff --git a/utils/haddock/haddock-library/fixtures/examples/url.parsed b/utils/haddock/haddock-library/fixtures/examples/url.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..0fbbbb30eee732f4097595f248ed9a9a8bf31d59
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/url.parsed
@@ -0,0 +1,4 @@
+DocParagraph
+  (DocHyperlink
+     Hyperlink
+       {hyperlinkLabel = Nothing, hyperlinkUrl = "http://example.com/"})
diff --git a/utils/haddock/haddock-library/fixtures/examples/urlLabel.input b/utils/haddock/haddock-library/fixtures/examples/urlLabel.input
new file mode 100644
index 0000000000000000000000000000000000000000..729812e88a504e8e7fb7ca21faea8935428571f5
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/urlLabel.input
@@ -0,0 +1 @@
+<http://example.com/ some link>
diff --git a/utils/haddock/haddock-library/fixtures/examples/urlLabel.parsed b/utils/haddock/haddock-library/fixtures/examples/urlLabel.parsed
new file mode 100644
index 0000000000000000000000000000000000000000..58d2a81a17ba22ce3702287b5e4dae4398fbd036
--- /dev/null
+++ b/utils/haddock/haddock-library/fixtures/examples/urlLabel.parsed
@@ -0,0 +1,5 @@
+DocParagraph
+  (DocHyperlink
+     Hyperlink
+       {hyperlinkLabel = Just (DocString "some link"),
+        hyperlinkUrl = "http://example.com/"})
diff --git a/utils/haddock/haddock-library/haddock-library.cabal b/utils/haddock/haddock-library/haddock-library.cabal
new file mode 100644
index 0000000000000000000000000000000000000000..50210eca69fb8de121ec8bd9c6583a89c3b67dc5
--- /dev/null
+++ b/utils/haddock/haddock-library/haddock-library.cabal
@@ -0,0 +1,125 @@
+cabal-version:        3.0
+name:                 haddock-library
+version:              1.11.0
+synopsis:             Library exposing some functionality of Haddock.
+
+description:          Haddock is a documentation-generation tool for Haskell
+                      libraries. These modules expose some
+                      functionality of it without pulling in the GHC
+                      dependency. Please note that the API is likely
+                      to change so be sure to specify upper bounds in
+                      your projects. For interacting with Haddock
+                      itself, see the [haddock package](https://hackage.haskell.org/package/haddock).
+
+license:              BSD-2-Clause
+license-file:         LICENSE
+maintainer:           Alec Theriault <alec.theriault@gmail.com>, Alex Biehl <alexbiehl@gmail.com>, Simon Hengel <sol@typeful.net>, Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>
+homepage:             http://www.haskell.org/haddock/
+bug-reports:          https://github.com/haskell/haddock/issues
+category:             Documentation
+tested-with:          GHC == 7.4.2
+                    , GHC == 7.6.3
+                    , GHC == 7.8.4
+                    , GHC == 7.10.3
+                    , GHC == 8.0.2
+                    , GHC == 8.2.2
+                    , GHC == 8.4.4
+                    , GHC == 8.6.5
+                    , GHC == 8.8.3
+                    , GHC == 8.10.1
+                    , GHC == 9.0.1
+                    , GHC == 9.2.0
+
+extra-source-files:
+  CHANGES.md
+  fixtures/examples/*.input
+  fixtures/examples/*.parsed
+
+common lib-defaults
+  default-language: Haskell2010
+
+  build-depends:
+    , base         >= 4.5     && < 4.20
+    , containers   ^>= 0.4.2.1 || ^>= 0.5.0.0 || ^>= 0.6.0.1 || ^>= 0.7
+    , text         ^>= 1.2.3.0 || ^>= 2.0 || ^>= 2.1
+    , parsec       ^>= 3.1.13.0
+
+  ghc-options: -funbox-strict-fields -Wall
+  if impl(ghc >= 8.0)
+    ghc-options: -Wcompat -Wnoncanonical-monad-instances
+
+library
+  import: lib-defaults
+
+  hs-source-dirs:       src
+
+  exposed-modules:
+    Documentation.Haddock.Doc
+    Documentation.Haddock.Markup
+    Documentation.Haddock.Parser
+    Documentation.Haddock.Types
+
+  other-modules:
+    CompatPrelude
+    Documentation.Haddock.Parser.Util
+    Documentation.Haddock.Parser.Monad
+    Documentation.Haddock.Parser.Identifier
+
+test-suite spec
+  import: lib-defaults
+  type:             exitcode-stdio-1.0
+  main-is:          Spec.hs
+  hs-source-dirs:
+    test
+    src
+
+  other-modules:
+    CompatPrelude
+    Documentation.Haddock.Doc
+    Documentation.Haddock.Markup
+    Documentation.Haddock.Parser
+    Documentation.Haddock.Parser.Monad
+    Documentation.Haddock.Parser.Util
+    Documentation.Haddock.Parser.UtilSpec
+    Documentation.Haddock.ParserSpec
+    Documentation.Haddock.Types
+    Documentation.Haddock.Parser.Identifier
+
+  build-depends:
+    , base-compat  ^>= 0.12.0
+    , QuickCheck   ^>= 2.11  || ^>= 2.13.2 || ^>= 2.14
+    , deepseq      ^>= 1.3.0.0 || ^>= 1.4.0.0
+
+  -- NB: build-depends & build-tool-depends have independent
+  --     install-plans, so it's best to limit to a single major
+  --     version of `hspec` & `hspec-discover` to ensure
+  --     intercompatibility
+  build-depends:
+    , hspec                          >= 2.4.4    && < 2.10
+
+  build-tool-depends:
+    , hspec-discover:hspec-discover  >= 2.4.4    && < 2.10
+
+test-suite fixtures
+  type:             exitcode-stdio-1.0
+  default-language: Haskell2010
+  main-is:          Fixtures.hs
+  ghc-options:      -Wall
+  hs-source-dirs:   fixtures
+  build-depends:
+      -- intra-package dependency
+    , haddock-library
+      -- constraints inherited via lib:haddock-library component
+    , base
+
+      -- extra dependencies
+    , base-compat           ^>= 0.12.0
+    , directory             ^>= 1.3.0.2
+    , filepath              ^>= 1.4.1.2
+    , optparse-applicative  ^>= 0.15
+    , tree-diff             ^>= 0.2
+
+source-repository head
+  type:     git
+  subdir:   haddock-library
+  location: https://github.com/haskell/haddock.git
diff --git a/utils/haddock/haddock-library/src/CompatPrelude.hs b/utils/haddock/haddock-library/src/CompatPrelude.hs
new file mode 100644
index 0000000000000000000000000000000000000000..0a98d485adda95cc9f5cdf0224fc4de9e4c844da
--- /dev/null
+++ b/utils/haddock/haddock-library/src/CompatPrelude.hs
@@ -0,0 +1,52 @@
+{-# LANGUAGE CPP #-}
+
+#ifdef __HLINT__
+#elif !MIN_VERSION_base(4,5,0)
+# error This module doesn't provide compat-shims for versions prior to base-4.5
+#endif
+
+-- | Bridge impedance mismatch of different @base@ versions back till @base-4.5@ (GHC 7.4.2)
+module CompatPrelude
+  ( ($>)
+  , isSymbolChar
+  ) where
+
+#if MIN_VERSION_base(4,7,0)
+import           Data.Functor                ( ($>) )
+#else
+import           Data.Functor                ( (<$) )
+#endif
+
+#if MIN_VERSION_base(4,9,0)
+import           Text.Read.Lex                      (isSymbolChar)
+#else
+import           Data.Char (GeneralCategory(..), generalCategory)
+#endif
+
+#if !MIN_VERSION_base(4,7,0)
+infixl 4 $>
+
+-- | Flipped version of '<$'.
+--
+-- @since 4.7.0.0
+($>) :: Functor f => f a -> b -> f b
+($>) = flip (<$)
+#endif
+
+#if !MIN_VERSION_base(4,9,0)
+-- inlined from base-4.10.0.0
+isSymbolChar :: Char -> Bool
+isSymbolChar c = not (isPuncChar c) && case generalCategory c of
+    MathSymbol           -> True
+    CurrencySymbol       -> True
+    ModifierSymbol       -> True
+    OtherSymbol          -> True
+    DashPunctuation      -> True
+    OtherPunctuation     -> c `notElem` "'\""
+    ConnectorPunctuation -> c /= '_'
+    _                    -> False
+  where
+    -- | The @special@ character class as defined in the Haskell Report.
+    isPuncChar :: Char -> Bool
+    isPuncChar = (`elem` (",;()[]{}`" :: String))
+#endif
diff --git a/utils/haddock/haddock-library/src/Documentation/Haddock/Doc.hs b/utils/haddock/haddock-library/src/Documentation/Haddock/Doc.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4e43a10b59799ad90b56058f9ecf8e62e58665a4
--- /dev/null
+++ b/utils/haddock/haddock-library/src/Documentation/Haddock/Doc.hs
@@ -0,0 +1,97 @@
+module Documentation.Haddock.Doc
+  ( docParagraph
+  , docAppend
+  , docConcat
+  , metaDocConcat
+  , metaDocAppend
+  , emptyMetaDoc
+  , metaAppend
+  , metaConcat
+  ) where
+
+import Control.Applicative ((<|>))
+import Data.Char (isSpace)
+import Documentation.Haddock.Types
+
+docConcat :: [DocH mod id] -> DocH mod id
+docConcat = foldr docAppend DocEmpty
+
+-- | Concat using 'metaAppend'.
+metaConcat :: [Meta] -> Meta
+metaConcat = foldr metaAppend emptyMeta
+
+-- | Like 'docConcat' but also joins the 'Meta' info.
+metaDocConcat :: [MetaDoc mod id] -> MetaDoc mod id
+metaDocConcat = foldr metaDocAppend emptyMetaDoc
+
+-- | We do something perhaps unexpected here and join the meta info
+-- in ‘reverse’: this results in the metadata from the ‘latest’
+-- paragraphs taking precedence.
+metaDocAppend :: MetaDoc mod id -> MetaDoc mod id -> MetaDoc mod id
+metaDocAppend
+  (MetaDoc{_meta = m, _doc = d})
+  (MetaDoc{_meta = m', _doc = d'}) =
+    MetaDoc{_meta = m' `metaAppend` m, _doc = d `docAppend` d'}
+
+-- | This is not a monoidal append, it uses '<|>' for the '_version' and
+-- '_package'.
+metaAppend :: Meta -> Meta -> Meta
+metaAppend (Meta v1) (Meta v2) = Meta (v1 <|> v2)
+
+emptyMetaDoc :: MetaDoc mod id
+emptyMetaDoc = MetaDoc{_meta = emptyMeta, _doc = DocEmpty}
+
+emptyMeta :: Meta
+emptyMeta = Meta Nothing
+
+docAppend :: DocH mod id -> DocH mod id -> DocH mod id
+docAppend (DocDefList ds1) (DocDefList ds2) = DocDefList (ds1 ++ ds2)
+docAppend (DocDefList ds1) (DocAppend (DocDefList ds2) d) = DocAppend (DocDefList (ds1 ++ ds2)) d
+docAppend (DocOrderedList ds1) (DocOrderedList ds2) = DocOrderedList (ds1 ++ ds2)
+docAppend (DocOrderedList ds1) (DocAppend (DocOrderedList ds2) d) = DocAppend (DocOrderedList (ds1 ++ ds2)) d
+docAppend (DocUnorderedList ds1) (DocUnorderedList ds2) = DocUnorderedList (ds1 ++ ds2)
+docAppend (DocUnorderedList ds1) (DocAppend (DocUnorderedList ds2) d) = DocAppend (DocUnorderedList (ds1 ++ ds2)) d
+docAppend DocEmpty d = d
+docAppend d DocEmpty = d
+docAppend (DocString s1) (DocString s2) = DocString (s1 ++ s2)
+docAppend (DocAppend d (DocString s1)) (DocString s2) = DocAppend d (DocString (s1 ++ s2))
+docAppend (DocString s1) (DocAppend (DocString s2) d) = DocAppend (DocString (s1 ++ s2)) d
+docAppend d1 d2 = DocAppend d1 d2
+
+-- again to make parsing easier - we spot a paragraph whose only item
+-- is a DocMonospaced and make it into a DocCodeBlock
+docParagraph :: DocH mod id -> DocH mod id
+docParagraph (DocMonospaced p) =
+  DocCodeBlock (docCodeBlock p)
+docParagraph (DocAppend (DocString s1) (DocMonospaced p))
+  | all isSpace s1 =
+      DocCodeBlock (docCodeBlock p)
+docParagraph
+  ( DocAppend
+      (DocString s1)
+      (DocAppend (DocMonospaced p) (DocString s2))
+    )
+    | all isSpace s1 && all isSpace s2 =
+        DocCodeBlock (docCodeBlock p)
+docParagraph (DocAppend (DocMonospaced p) (DocString s2))
+  | all isSpace s2 =
+      DocCodeBlock (docCodeBlock p)
+docParagraph p =
+  DocParagraph p
+
+-- Drop trailing whitespace from @..@ code blocks.  Otherwise this:
+--
+--    -- @
+--    -- foo
+--    -- @
+--
+-- turns into (DocCodeBlock "\nfoo\n ") which when rendered in HTML
+-- gives an extra vertical space after the code block.  The single space
+-- on the final line seems to trigger the extra vertical space.
+--
+docCodeBlock :: DocH mod id -> DocH mod id
+docCodeBlock (DocString s) =
+  DocString (reverse $ dropWhile (`elem` " \t") $ reverse s)
+docCodeBlock (DocAppend l r) =
+  DocAppend l (docCodeBlock r)
+docCodeBlock d = d
diff --git a/utils/haddock/haddock-library/src/Documentation/Haddock/Markup.hs b/utils/haddock/haddock-library/src/Documentation/Haddock/Markup.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a2fce2330e90f7dcaa9d3358bcc663b45eda4e40
--- /dev/null
+++ b/utils/haddock/haddock-library/src/Documentation/Haddock/Markup.hs
@@ -0,0 +1,101 @@
+-- | @since 1.4.5
+module Documentation.Haddock.Markup
+  ( markup
+  , idMarkup
+  , plainMarkup
+  ) where
+
+import Documentation.Haddock.Types
+
+import Data.Maybe (fromMaybe)
+
+markup :: DocMarkupH mod id a -> DocH mod id -> a
+markup m DocEmpty = markupEmpty m
+markup m (DocAppend d1 d2) = markupAppend m (markup m d1) (markup m d2)
+markup m (DocString s) = markupString m s
+markup m (DocParagraph d) = markupParagraph m (markup m d)
+markup m (DocIdentifier x) = markupIdentifier m x
+markup m (DocIdentifierUnchecked x) = markupIdentifierUnchecked m x
+markup m (DocModule (ModLink mo l)) = markupModule m (ModLink mo (fmap (markup m) l))
+markup m (DocWarning d) = markupWarning m (markup m d)
+markup m (DocEmphasis d) = markupEmphasis m (markup m d)
+markup m (DocBold d) = markupBold m (markup m d)
+markup m (DocMonospaced d) = markupMonospaced m (markup m d)
+markup m (DocUnorderedList ds) = markupUnorderedList m (map (markup m) ds)
+markup m (DocOrderedList ds) = markupOrderedList m (map (\(index, a) -> (index, markup m a)) ds)
+markup m (DocDefList ds) = markupDefList m (map (markupPair m) ds)
+markup m (DocCodeBlock d) = markupCodeBlock m (markup m d)
+markup m (DocHyperlink (Hyperlink u l)) = markupHyperlink m (Hyperlink u (fmap (markup m) l))
+markup m (DocAName ref) = markupAName m ref
+markup m (DocPic img) = markupPic m img
+markup m (DocMathInline mathjax) = markupMathInline m mathjax
+markup m (DocMathDisplay mathjax) = markupMathDisplay m mathjax
+markup m (DocProperty p) = markupProperty m p
+markup m (DocExamples e) = markupExample m e
+markup m (DocHeader (Header l t)) = markupHeader m (Header l (markup m t))
+markup m (DocTable (Table h b)) = markupTable m (Table (map (fmap (markup m)) h) (map (fmap (markup m)) b))
+
+markupPair :: DocMarkupH mod id a -> (DocH mod id, DocH mod id) -> (a, a)
+markupPair m (a, b) = (markup m a, markup m b)
+
+-- | The identity markup
+idMarkup :: DocMarkupH mod id (DocH mod id)
+idMarkup =
+  Markup
+    { markupEmpty = DocEmpty
+    , markupString = DocString
+    , markupParagraph = DocParagraph
+    , markupAppend = DocAppend
+    , markupIdentifier = DocIdentifier
+    , markupIdentifierUnchecked = DocIdentifierUnchecked
+    , markupModule = DocModule
+    , markupWarning = DocWarning
+    , markupEmphasis = DocEmphasis
+    , markupBold = DocBold
+    , markupMonospaced = DocMonospaced
+    , markupUnorderedList = DocUnorderedList
+    , markupOrderedList = DocOrderedList
+    , markupDefList = DocDefList
+    , markupCodeBlock = DocCodeBlock
+    , markupHyperlink = DocHyperlink
+    , markupAName = DocAName
+    , markupPic = DocPic
+    , markupMathInline = DocMathInline
+    , markupMathDisplay = DocMathDisplay
+    , markupProperty = DocProperty
+    , markupExample = DocExamples
+    , markupHeader = DocHeader
+    , markupTable = DocTable
+    }
+
+-- | Map a 'DocH' into a best estimate of an alternate string. The idea is to
+-- strip away any formatting while preserving as much of the actual text as
+-- possible.
+plainMarkup :: (mod -> String) -> (id -> String) -> DocMarkupH mod id String
+plainMarkup plainMod plainIdent =
+  Markup
+    { markupEmpty = ""
+    , markupString = id
+    , markupParagraph = id
+    , markupAppend = (++)
+    , markupIdentifier = plainIdent
+    , markupIdentifierUnchecked = plainMod
+    , markupModule = \(ModLink m lbl) -> fromMaybe m lbl
+    , markupWarning = id
+    , markupEmphasis = id
+    , markupBold = id
+    , markupMonospaced = id
+    , markupUnorderedList = const ""
+    , markupOrderedList = const ""
+    , markupDefList = const ""
+    , markupCodeBlock = id
+    , markupHyperlink = \(Hyperlink url lbl) -> fromMaybe url lbl
+    , markupAName = id
+    , markupPic = \(Picture uri title) -> fromMaybe uri title
+    , markupMathInline = id
+    , markupMathDisplay = id
+    , markupProperty = id
+    , markupExample = const ""
+    , markupHeader = \(Header _ title) -> title
+    , markupTable = const ""
+    }
diff --git a/utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs b/utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
new file mode 100644
index 0000000000000000000000000000000000000000..0463e26ef0a3e18abf627b97d64908123ecf51bd
--- /dev/null
+++ b/utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -0,0 +1,929 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE ViewPatterns #-}
+
+-- |
+-- Module      :  Documentation.Haddock.Parser
+-- Copyright   :  (c) Mateusz Kowalczyk 2013-2014,
+--                    Simon Hengel      2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Parser used for Haddock comments. For external users of this
+-- library, the most commonly used combination of functions is going
+-- to be
+--
+-- @'toRegular' . '_doc' . 'parseParas'@
+module Documentation.Haddock.Parser
+  ( parseString
+  , parseParas
+  , overIdentifier
+  , toRegular
+  , Identifier
+  ) where
+
+import Control.Applicative
+import Control.Arrow (first)
+import Control.Monad
+import Data.Char (chr, isAlpha, isSpace, isUpper)
+import Data.List (elemIndex, intercalate, unfoldr)
+import Data.Maybe (fromMaybe, mapMaybe)
+import Data.Monoid
+import qualified Data.Set as Set
+import Documentation.Haddock.Doc
+import Documentation.Haddock.Markup (markup, plainMarkup)
+import Documentation.Haddock.Parser.Identifier
+import Documentation.Haddock.Parser.Monad
+import Documentation.Haddock.Parser.Util
+import Documentation.Haddock.Types
+import Prelude hiding (takeWhile)
+import qualified Prelude as P
+
+import Text.Parsec (try)
+import qualified Text.Parsec as Parsec
+
+import Data.Text (Text)
+import qualified Data.Text as T
+
+-- $setup
+-- >>> :set -XOverloadedStrings
+
+-- | Drops the quotes/backticks around all identifiers, as if they
+-- were valid but still 'String's.
+toRegular :: DocH mod Identifier -> DocH mod String
+toRegular = fmap (\(Identifier _ _ x _) -> x)
+
+-- | Maps over 'DocIdentifier's over 'String' with potentially failing
+-- conversion using user-supplied function. If the conversion fails,
+-- the identifier is deemed to not be valid and is treated as a
+-- regular string.
+overIdentifier
+  :: (Namespace -> String -> Maybe a)
+  -> DocH mod Identifier
+  -> DocH mod a
+overIdentifier f d = g d
+  where
+    g (DocIdentifier (Identifier ns o x e)) = case f ns x of
+      Nothing -> DocString $ renderNs ns ++ [o] ++ x ++ [e]
+      Just x' -> DocIdentifier x'
+    g DocEmpty = DocEmpty
+    g (DocAppend x x') = DocAppend (g x) (g x')
+    g (DocString x) = DocString x
+    g (DocParagraph x) = DocParagraph $ g x
+    g (DocIdentifierUnchecked x) = DocIdentifierUnchecked x
+    g (DocModule (ModLink m x)) = DocModule (ModLink m (fmap g x))
+    g (DocWarning x) = DocWarning $ g x
+    g (DocEmphasis x) = DocEmphasis $ g x
+    g (DocMonospaced x) = DocMonospaced $ g x
+    g (DocBold x) = DocBold $ g x
+    g (DocUnorderedList x) = DocUnorderedList $ fmap g x
+    g (DocOrderedList x) = DocOrderedList $ fmap (\(index, a) -> (index, g a)) x
+    g (DocDefList x) = DocDefList $ fmap (\(y, z) -> (g y, g z)) x
+    g (DocCodeBlock x) = DocCodeBlock $ g x
+    g (DocHyperlink (Hyperlink u x)) = DocHyperlink (Hyperlink u (fmap g x))
+    g (DocPic x) = DocPic x
+    g (DocMathInline x) = DocMathInline x
+    g (DocMathDisplay x) = DocMathDisplay x
+    g (DocAName x) = DocAName x
+    g (DocProperty x) = DocProperty x
+    g (DocExamples x) = DocExamples x
+    g (DocHeader (Header l x)) = DocHeader . Header l $ g x
+    g (DocTable (Table h b)) = DocTable (Table (map (fmap g) h) (map (fmap g) b))
+
+choice' :: [Parser a] -> Parser a
+choice' [] = empty
+choice' [p] = p
+choice' (p : ps) = try p <|> choice' ps
+
+parse :: Parser a -> Text -> (ParserState, a)
+parse p = either err id . parseOnly (p <* Parsec.eof)
+  where
+    err = error . ("Haddock.Parser.parse: " ++)
+
+-- | Main entry point to the parser. Appends the newline character
+-- to the input string.
+parseParas
+  :: Maybe Package
+  -> String
+  -- ^ String to parse
+  -> MetaDoc mod Identifier
+parseParas pkg input = case parseParasState input of
+  (state, a) ->
+    let defaultPackage s = s{sincePackage = sincePackage s <|> pkg}
+     in MetaDoc
+          { _meta = Meta{_metaSince = defaultPackage <$> parserStateSince state}
+          , _doc = a
+          }
+
+parseParasState :: String -> (ParserState, DocH mod Identifier)
+parseParasState = parse (emptyLines *> p) . T.pack . (++ "\n") . filter (/= '\r')
+  where
+    p :: Parser (DocH mod Identifier)
+    p = docConcat <$> many (paragraph <* emptyLines)
+
+    emptyLines :: Parser ()
+    emptyLines = void $ many (try (skipHorizontalSpace *> "\n"))
+
+parseParagraphs :: String -> Parser (DocH mod Identifier)
+parseParagraphs input = case parseParasState input of
+  (state, a) -> Parsec.putState state *> pure a
+
+-- | Variant of 'parseText' for 'String' instead of 'Text'
+parseString :: String -> DocH mod Identifier
+parseString = parseText . T.pack
+
+-- | Parse a text paragraph. Actually just a wrapper over 'parseParagraph' which
+-- drops leading whitespace.
+parseText :: Text -> DocH mod Identifier
+parseText = parseParagraph . T.dropWhile isSpace . T.filter (/= '\r')
+
+parseParagraph :: Text -> DocH mod Identifier
+parseParagraph = snd . parse p
+  where
+    p :: Parser (DocH mod Identifier)
+    p =
+      docConcat
+        <$> many
+          ( choice'
+              [ monospace
+              , anchor
+              , identifier
+              , moduleName
+              , picture
+              , mathDisplay
+              , mathInline
+              , markdownImage
+              , markdownLink
+              , hyperlink
+              , bold
+              , emphasis
+              , encodedChar
+              , string'
+              , skipSpecialChar
+              ]
+          )
+
+-- | Parses and processes
+-- <https://en.wikipedia.org/wiki/Numeric_character_reference Numeric character references>
+--
+-- >>> parseString "&#65;"
+-- DocString "A"
+encodedChar :: Parser (DocH mod a)
+encodedChar = "&#" *> c <* ";"
+  where
+    c = DocString . return . chr <$> num
+    num = hex <|> decimal
+    hex = ("x" <|> "X") *> hexadecimal
+
+-- | List of characters that we use to delimit any special markup.
+-- Once we have checked for any of these and tried to parse the
+-- relevant markup, we can assume they are used as regular text.
+specialChar :: [Char]
+specialChar = "_/<@\"&'`#[ "
+
+-- | Plain, regular parser for text. Called as one of the last parsers
+-- to ensure that we have already given a chance to more meaningful parsers
+-- before capturing their characters.
+string' :: Parser (DocH mod a)
+string' = DocString . unescape . T.unpack <$> takeWhile1_ (`notElem` specialChar)
+  where
+    unescape "" = ""
+    unescape ('\\' : x : xs) = x : unescape xs
+    unescape (x : xs) = x : unescape xs
+
+-- | Skips a single special character and treats it as a plain string.
+-- This is done to skip over any special characters belonging to other
+-- elements but which were not deemed meaningful at their positions.
+skipSpecialChar :: Parser (DocH mod a)
+skipSpecialChar = DocString . return <$> Parsec.oneOf specialChar
+
+-- | Emphasis parser.
+--
+-- >>> parseString "/Hello world/"
+-- DocEmphasis (DocString "Hello world")
+emphasis :: Parser (DocH mod Identifier)
+emphasis =
+  DocEmphasis . parseParagraph
+    <$> disallowNewline ("/" *> takeWhile1_ (/= '/') <* "/")
+
+-- | Bold parser.
+--
+-- >>> parseString "__Hello world__"
+-- DocBold (DocString "Hello world")
+bold :: Parser (DocH mod Identifier)
+bold = DocBold . parseParagraph <$> disallowNewline ("__" *> takeUntil "__")
+
+disallowNewline :: Parser Text -> Parser Text
+disallowNewline = mfilter (T.all (/= '\n'))
+
+-- | Like `takeWhile`, but unconditionally take escaped characters.
+takeWhile_ :: (Char -> Bool) -> Parser Text
+takeWhile_ p = scan p_ False
+  where
+    p_ escaped c
+      | escaped = Just False
+      | not $ p c = Nothing
+      | otherwise = Just (c == '\\')
+
+-- | Like 'takeWhile1', but unconditionally take escaped characters.
+takeWhile1_ :: (Char -> Bool) -> Parser Text
+takeWhile1_ = mfilter (not . T.null) . takeWhile_
+
+-- | Text anchors to allow for jumping around the generated documentation.
+--
+-- >>> parseString "#Hello world#"
+-- DocAName "Hello world"
+anchor :: Parser (DocH mod a)
+anchor =
+  DocAName . T.unpack
+    <$> ("#" *> takeWhile1_ (\x -> x /= '#' && not (isSpace x)) <* "#")
+
+-- | Monospaced strings.
+--
+-- >>> parseString "@cruel@"
+-- DocMonospaced (DocString "cruel")
+monospace :: Parser (DocH mod Identifier)
+monospace =
+  DocMonospaced . parseParagraph
+    <$> ("@" *> takeWhile1_ (/= '@') <* "@")
+
+-- | Module names.
+--
+-- Note that we allow '#' and '\' to support anchors (old style anchors are of
+-- the form "SomeModule\#anchor").
+moduleName :: Parser (DocH mod a)
+moduleName = DocModule . flip ModLink Nothing <$> ("\"" *> moduleNameString <* "\"")
+
+-- | A module name, optionally with an anchor
+moduleNameString :: Parser String
+moduleNameString = modid `maybeFollowedBy` anchor_
+  where
+    modid = intercalate "." <$> conid `Parsec.sepBy1` "."
+    anchor_ =
+      (++)
+        <$> (Parsec.string "#" <|> Parsec.string "\\#")
+        <*> many (Parsec.satisfy (\c -> c /= '"' && not (isSpace c)))
+
+    maybeFollowedBy pre suf = (\x -> maybe x (x ++)) <$> pre <*> optional suf
+    conid :: Parser String
+    conid =
+      (:)
+        <$> Parsec.satisfy (\c -> isAlpha c && isUpper c)
+        <*> many conChar
+
+    conChar = Parsec.alphaNum <|> Parsec.char '_'
+
+-- | A labeled link to an indentifier, module or url using markdown
+-- syntax.
+markdownLink :: Parser (DocH mod Identifier)
+markdownLink = do
+  lbl <- markdownLinkText
+  choice' [markdownModuleName lbl, markdownURL lbl]
+  where
+    markdownModuleName lbl = do
+      mn <-
+        "("
+          *> skipHorizontalSpace
+          *> "\""
+          *> moduleNameString
+          <* "\""
+          <* skipHorizontalSpace
+          <* ")"
+      pure $ DocModule (ModLink mn (Just lbl))
+
+    markdownURL lbl = do
+      target <- markdownLinkTarget
+      pure $ DocHyperlink $ Hyperlink target (Just lbl)
+
+-- | Picture parser, surrounded by \<\< and \>\>. It's possible to specify
+-- a title for the picture.
+--
+-- >>> parseString "<<hello.png>>"
+-- DocPic (Picture {pictureUri = "hello.png", pictureTitle = Nothing})
+-- >>> parseString "<<hello.png world>>"
+-- DocPic (Picture {pictureUri = "hello.png", pictureTitle = Just "world"})
+picture :: Parser (DocH mod a)
+picture =
+  DocPic . makeLabeled Picture
+    <$> disallowNewline ("<<" *> takeUntil ">>")
+
+-- | Inline math parser, surrounded by \\( and \\).
+--
+-- >>> parseString "\\(\\int_{-\\infty}^{\\infty} e^{-x^2/2} = \\sqrt{2\\pi}\\)"
+-- DocMathInline "\\int_{-\\infty}^{\\infty} e^{-x^2/2} = \\sqrt{2\\pi}"
+mathInline :: Parser (DocH mod a)
+mathInline =
+  DocMathInline . T.unpack
+    <$> disallowNewline ("\\(" *> takeUntil "\\)")
+
+-- | Display math parser, surrounded by \\[ and \\].
+--
+-- >>> parseString "\\[\\int_{-\\infty}^{\\infty} e^{-x^2/2} = \\sqrt{2\\pi}\\]"
+-- DocMathDisplay "\\int_{-\\infty}^{\\infty} e^{-x^2/2} = \\sqrt{2\\pi}"
+mathDisplay :: Parser (DocH mod a)
+mathDisplay =
+  DocMathDisplay . T.unpack
+    <$> ("\\[" *> takeUntil "\\]")
+
+-- | Markdown image parser. As per the commonmark reference recommendation, the
+-- description text for an image converted to its a plain string representation.
+--
+-- >>> parseString "![some /emphasis/ in a description](www.site.com)"
+-- DocPic (Picture "www.site.com" (Just "some emphasis in a description"))
+markdownImage :: Parser (DocH mod Identifier)
+markdownImage = do
+  text <- markup stringMarkup <$> ("!" *> markdownLinkText)
+  url <- markdownLinkTarget
+  pure $ DocPic (Picture url (Just text))
+  where
+    stringMarkup = plainMarkup (const "") renderIdent
+    renderIdent (Identifier ns l c r) = renderNs ns <> [l] <> c <> [r]
+
+-- | Paragraph parser, called by 'parseParas'.
+paragraph :: Parser (DocH mod Identifier)
+paragraph =
+  choice'
+    [ examples
+    , table
+    , do
+        indent <- takeIndent
+        choice'
+          [ since
+          , unorderedList indent
+          , orderedList indent
+          , birdtracks
+          , codeblock
+          , property
+          , header
+          , textParagraphThatStartsWithMarkdownLink
+          , definitionList indent
+          , docParagraph <$> textParagraph
+          ]
+    ]
+
+-- | Provides support for grid tables.
+--
+-- Tables are composed by an optional header and body. The header is composed by
+-- a single row. The body is composed by a non-empty list of rows.
+--
+-- Example table with header:
+--
+-- > +----------+----------+
+-- > | /32bit/  |   64bit  |
+-- > +==========+==========+
+-- > |  0x0000  | @0x0000@ |
+-- > +----------+----------+
+--
+-- Algorithms loosely follows ideas in
+-- http://docutils.sourceforge.net/docutils/parsers/rst/tableparser.py
+table :: Parser (DocH mod Identifier)
+table = do
+  -- first we parse the first row, which determines the width of the table
+  firstRow <- parseFirstRow
+  let len = T.length firstRow
+
+  -- then we parse all consecutive rows starting and ending with + or |,
+  -- of the width `len`.
+  restRows <- many (try (parseRestRows len))
+
+  -- Now we gathered the table block, the next step is to split the block
+  -- into cells.
+  DocTable <$> tableStepTwo len (firstRow : restRows)
+  where
+    parseFirstRow :: Parser Text
+    parseFirstRow = do
+      skipHorizontalSpace
+      cs <- takeWhile (\c -> c == '-' || c == '+')
+
+      -- upper-left and upper-right corners are `+`
+      guard
+        ( T.length cs >= 2
+            && T.head cs == '+'
+            && T.last cs == '+'
+        )
+
+      -- trailing space
+      skipHorizontalSpace
+      _ <- Parsec.newline
+
+      return cs
+
+    parseRestRows :: Int -> Parser Text
+    parseRestRows l = do
+      skipHorizontalSpace
+      bs <- scan predicate l
+
+      -- Left and right edges are `|` or `+`
+      guard
+        ( T.length bs >= 2
+            && (T.head bs == '|' || T.head bs == '+')
+            && (T.last bs == '|' || T.last bs == '+')
+        )
+
+      -- trailing space
+      skipHorizontalSpace
+      _ <- Parsec.newline
+
+      return bs
+      where
+        predicate n c
+          | n <= 0 = Nothing
+          | c == '\n' = Nothing
+          | otherwise = Just (n - 1)
+
+-- Second step searchs for row of '+' and '=' characters, records it's index
+-- and changes to '=' to '-'.
+tableStepTwo
+  :: Int
+  -- ^ width
+  -> [Text]
+  -- ^ rows
+  -> Parser (Table (DocH mod Identifier))
+tableStepTwo width = go 0 []
+  where
+    go _ left [] = tableStepThree width (reverse left) Nothing
+    go n left (r : rs)
+      | T.all (`elem` ['+', '=']) r =
+          tableStepThree width (reverse left ++ r' : rs) (Just n)
+      | otherwise =
+          go (n + 1) (r : left) rs
+      where
+        r' = T.map (\c -> if c == '=' then '-' else c) r
+
+-- Third step recognises cells in the table area, returning a list of TC, cells.
+tableStepThree
+  :: Int
+  -- ^ width
+  -> [Text]
+  -- ^ rows
+  -> Maybe Int
+  -- ^ index of header separator
+  -> Parser (Table (DocH mod Identifier))
+tableStepThree width rs hdrIndex = do
+  cells <- loop (Set.singleton (0, 0))
+  tableStepFour rs hdrIndex cells
+  where
+    height = length rs
+
+    loop :: Set.Set (Int, Int) -> Parser [TC]
+    loop queue = case Set.minView queue of
+      Nothing -> return []
+      Just ((y, x), queue')
+        | y + 1 >= height || x + 1 >= width -> loop queue'
+        | otherwise -> case scanRight x y of
+            Nothing -> loop queue'
+            Just (x2, y2) -> do
+              let tc = TC y x y2 x2
+              fmap (tc :) $
+                loop $
+                  queue'
+                    `Set.union` Set.fromList
+                      [(y, x2), (y2, x), (y2, x2)]
+
+    -- scan right looking for +, then try scan down
+    --
+    -- do we need to record + saw on the way left and down?
+    scanRight :: Int -> Int -> Maybe (Int, Int)
+    scanRight x y = go (x + 1)
+      where
+        bs = rs !! y
+        go x'
+          | x' >= width = fail "overflow right "
+          | T.index bs x' == '+' = scanDown x y x' <|> go (x' + 1)
+          | T.index bs x' == '-' = go (x' + 1)
+          | otherwise = fail $ "not a border (right) " ++ show (x, y, x')
+
+    -- scan down looking for +
+    scanDown :: Int -> Int -> Int -> Maybe (Int, Int)
+    scanDown x y x2 = go (y + 1)
+      where
+        go y'
+          | y' >= height = fail "overflow down"
+          | T.index (rs !! y') x2 == '+' = scanLeft x y x2 y' <|> go (y' + 1)
+          | T.index (rs !! y') x2 == '|' = go (y' + 1)
+          | otherwise = fail $ "not a border (down) " ++ show (x, y, x2, y')
+
+    -- check that at y2 x..x2 characters are '+' or '-'
+    scanLeft :: Int -> Int -> Int -> Int -> Maybe (Int, Int)
+    scanLeft x y x2 y2
+      | all (\x' -> T.index bs x' `elem` ['+', '-']) [x .. x2] = scanUp x y x2 y2
+      | otherwise = fail $ "not a border (left) " ++ show (x, y, x2, y2)
+      where
+        bs = rs !! y2
+
+    -- check that at y2 x..x2 characters are '+' or '-'
+    scanUp :: Int -> Int -> Int -> Int -> Maybe (Int, Int)
+    scanUp x y x2 y2
+      | all (\y' -> T.index (rs !! y') x `elem` ['+', '|']) [y .. y2] = return (x2, y2)
+      | otherwise = fail $ "not a border (up) " ++ show (x, y, x2, y2)
+
+-- | table cell: top left bottom right
+data TC = TC !Int !Int !Int !Int
+  deriving (Show)
+
+tcXS :: TC -> [Int]
+tcXS (TC _ x _ x2) = [x, x2]
+
+tcYS :: TC -> [Int]
+tcYS (TC y _ y2 _) = [y, y2]
+
+-- | Fourth step. Given the locations of cells, forms 'Table' structure.
+tableStepFour :: [Text] -> Maybe Int -> [TC] -> Parser (Table (DocH mod Identifier))
+tableStepFour rs hdrIndex cells = case hdrIndex of
+  Nothing -> return $ Table [] rowsDoc
+  Just i -> case elemIndex i yTabStops of
+    Nothing -> return $ Table [] rowsDoc
+    Just i' -> return $ uncurry Table $ splitAt i' rowsDoc
+  where
+    xTabStops = sortNub $ concatMap tcXS cells
+    yTabStops = sortNub $ concatMap tcYS cells
+
+    sortNub :: Ord a => [a] -> [a]
+    sortNub = Set.toList . Set.fromList
+
+    init' :: [a] -> [a]
+    init' [] = []
+    init' [_] = []
+    init' (x : xs) = x : init' xs
+
+    rowsDoc = (fmap . fmap) parseParagraph rows
+
+    rows = map makeRow (init' yTabStops)
+      where
+        makeRow y = TableRow $ mapMaybe (makeCell y) cells
+        makeCell y (TC y' x y2 x2)
+          | y /= y' = Nothing
+          | otherwise = Just $ TableCell xts yts (extract (x + 1) (y + 1) (x2 - 1) (y2 - 1))
+          where
+            xts = length $ P.takeWhile (< x2) $ dropWhile (< x) xTabStops
+            yts = length $ P.takeWhile (< y2) $ dropWhile (< y) yTabStops
+
+    -- extract cell contents given boundaries
+    extract :: Int -> Int -> Int -> Int -> Text
+    extract x y x2 y2 =
+      T.intercalate
+        "\n"
+        [ T.stripEnd $ T.stripStart $ T.take (x2 - x + 1) $ T.drop x $ rs !! y'
+        | y' <- [y .. y2]
+        ]
+
+-- | Parse \@since annotations.
+since :: Parser (DocH mod a)
+since = do
+  ("@since " *> version <* skipHorizontalSpace <* endOfLine) >>= setSince
+  return DocEmpty
+  where
+    version = do
+      pkg <- Parsec.optionMaybe $ Parsec.try $ package <* Parsec.char '-'
+      ver <- decimal `Parsec.sepBy1` "."
+      return (MetaSince pkg ver)
+
+    package = Parsec.many1 $ Parsec.alphaNum <|> Parsec.oneOf "_-"
+
+-- | Headers inside the comment denoted with @=@ signs, up to 6 levels
+-- deep.
+--
+-- >>> snd <$> parseOnly header "= Hello"
+-- Right (DocHeader (Header {headerLevel = 1, headerTitle = DocString "Hello"}))
+-- >>> snd <$> parseOnly header "== World"
+-- Right (DocHeader (Header {headerLevel = 2, headerTitle = DocString "World"}))
+header :: Parser (DocH mod Identifier)
+header = do
+  let psers = map (string . flip T.replicate "=") [6, 5 .. 1]
+      pser = Parsec.choice psers
+  depth <- T.length <$> pser
+  line <- parseText <$> (skipHorizontalSpace *> nonEmptyLine)
+  rest <- try paragraph <|> return DocEmpty
+  return $ DocHeader (Header depth line) `docAppend` rest
+
+textParagraph :: Parser (DocH mod Identifier)
+textParagraph = parseText . T.intercalate "\n" <$> some nonEmptyLine
+
+textParagraphThatStartsWithMarkdownLink :: Parser (DocH mod Identifier)
+textParagraphThatStartsWithMarkdownLink = docParagraph <$> (docAppend <$> markdownLink <*> optionalTextParagraph)
+  where
+    optionalTextParagraph :: Parser (DocH mod Identifier)
+    optionalTextParagraph =
+      choice'
+        [ docAppend <$> whitespace <*> textParagraph
+        , pure DocEmpty
+        ]
+
+    whitespace :: Parser (DocH mod a)
+    whitespace = DocString <$> (f <$> takeHorizontalSpace <*> optional "\n")
+      where
+        f :: Text -> Maybe Text -> String
+        f xs (fromMaybe "" -> x)
+          | T.null (xs <> x) = ""
+          | otherwise = " "
+
+-- | Parses unordered (bullet) lists.
+unorderedList :: Text -> Parser (DocH mod Identifier)
+unorderedList indent = DocUnorderedList <$> p
+  where
+    p = ("*" <|> "-") *> innerList indent p
+
+-- | Parses ordered lists (numbered or dashed).
+orderedList :: Text -> Parser (DocH mod Identifier)
+orderedList indent = DocOrderedList <$> p
+  where
+    p = do
+      index <- paren <|> dot
+      innerList' indent p index
+    dot = (decimal :: Parser Int) <* "."
+    paren = "(" *> decimal <* ")"
+
+-- | Like 'innerList' but takes the parsed index of the list item
+innerList'
+  :: Text
+  -> Parser [(Int, DocH mod Identifier)]
+  -> Int
+  -> Parser [(Int, DocH mod Identifier)]
+innerList' indent item index = do
+  c <- takeLine
+  (cs, items) <- more indent item
+  let contents = docParagraph . parseText . dropNLs . T.unlines $ c : cs
+  return $ case items of
+    Left p -> [(index, contents `docAppend` p)]
+    Right i -> (index, contents) : i
+
+-- | Generic function collecting any further lines belonging to the
+-- list entry and recursively collecting any further lists in the
+-- same paragraph. Usually used as
+--
+-- > someListFunction = listBeginning *> innerList someListFunction
+innerList
+  :: Text
+  -> Parser [DocH mod Identifier]
+  -> Parser [DocH mod Identifier]
+innerList indent item = do
+  c <- takeLine
+  (cs, items) <- more indent item
+  let contents = docParagraph . parseText . dropNLs . T.unlines $ c : cs
+  return $ case items of
+    Left p -> [contents `docAppend` p]
+    Right i -> contents : i
+
+-- | Parses definition lists.
+definitionList :: Text -> Parser (DocH mod Identifier)
+definitionList indent = DocDefList <$> p
+  where
+    p = do
+      label <- "[" *> (parseParagraph <$> takeWhile1_ (`notElem` ("]\n" :: String))) <* ("]" <* optional ":")
+      c <- takeLine
+      (cs, items) <- more indent p
+      let contents = parseText . dropNLs . T.unlines $ c : cs
+      return $ case items of
+        Left x -> [(label, contents `docAppend` x)]
+        Right i -> (label, contents) : i
+
+-- | Drops all trailing newlines.
+dropNLs :: Text -> Text
+dropNLs = T.dropWhileEnd (== '\n')
+
+-- | Main worker for 'innerList' and 'definitionList'.
+-- We need the 'Either' here to be able to tell in the respective functions
+-- whether we're dealing with the next list or a nested paragraph.
+more
+  :: Monoid a
+  => Text
+  -> Parser a
+  -> Parser ([Text], Either (DocH mod Identifier) a)
+more indent item =
+  choice'
+    [ innerParagraphs indent
+    , moreListItems indent item
+    , moreContent indent item
+    , pure ([], Right mempty)
+    ]
+
+-- | Used by 'innerList' and 'definitionList' to parse any nested paragraphs.
+innerParagraphs
+  :: Text
+  -> Parser ([Text], Either (DocH mod Identifier) a)
+innerParagraphs indent = (,) [] . Left <$> ("\n" *> indentedParagraphs indent)
+
+-- | Attempts to fetch the next list if possibly. Used by 'innerList' and
+-- 'definitionList' to recursively grab lists that aren't separated by a whole
+-- paragraph.
+moreListItems
+  :: Text
+  -> Parser a
+  -> Parser ([Text], Either (DocH mod Identifier) a)
+moreListItems indent item = (,) [] . Right <$> indentedItem
+  where
+    indentedItem = string indent *> Parsec.spaces *> item
+
+-- | Helper for 'innerList' and 'definitionList' which simply takes
+-- a line of text and attempts to parse more list content with 'more'.
+moreContent
+  :: Monoid a
+  => Text
+  -> Parser a
+  -> Parser ([Text], Either (DocH mod Identifier) a)
+moreContent indent item = first . (:) <$> nonEmptyLine <*> more indent item
+
+-- | Parses an indented paragraph.
+-- The indentation is 4 spaces.
+indentedParagraphs :: Text -> Parser (DocH mod Identifier)
+indentedParagraphs indent =
+  (T.unpack . T.concat <$> dropFrontOfPara indent') >>= parseParagraphs
+  where
+    indent' = string $ indent <> "    "
+
+-- | Grab as many fully indented paragraphs as we can.
+dropFrontOfPara :: Parser Text -> Parser [Text]
+dropFrontOfPara sp = do
+  currentParagraph <- some (try (sp *> takeNonEmptyLine))
+  followingParagraphs <-
+    choice'
+      [ skipHorizontalSpace *> nextPar -- we have more paragraphs to take
+      , skipHorizontalSpace *> nlList -- end of the ride, remember the newline
+      , Parsec.eof *> return [] -- nothing more to take at all
+      ]
+  return (currentParagraph ++ followingParagraphs)
+  where
+    nextPar = (++) <$> nlList <*> dropFrontOfPara sp
+    nlList = "\n" *> return ["\n"]
+
+nonSpace :: Text -> Parser Text
+nonSpace xs
+  | T.all isSpace xs = fail "empty line"
+  | otherwise = return xs
+
+-- | Takes a non-empty, not fully whitespace line.
+--
+--  Doesn't discard the trailing newline.
+takeNonEmptyLine :: Parser Text
+takeNonEmptyLine = do
+  l <- takeWhile1 (/= '\n') >>= nonSpace
+  _ <- "\n"
+  pure (l <> "\n")
+
+-- | Takes indentation of first non-empty line.
+--
+-- More precisely: skips all whitespace-only lines and returns indentation
+-- (horizontal space, might be empty) of that non-empty line.
+takeIndent :: Parser Text
+takeIndent = do
+  indent <- takeHorizontalSpace
+  choice'
+    [ "\n" *> takeIndent
+    , return indent
+    ]
+
+-- | Blocks of text of the form:
+--
+-- >> foo
+-- >> bar
+-- >> baz
+birdtracks :: Parser (DocH mod a)
+birdtracks = DocCodeBlock . DocString . T.unpack . T.intercalate "\n" . stripSpace <$> some line
+  where
+    line = try (skipHorizontalSpace *> ">" *> takeLine)
+
+stripSpace :: [Text] -> [Text]
+stripSpace = fromMaybe <*> mapM strip'
+  where
+    strip' t = case T.uncons t of
+      Nothing -> Just ""
+      Just (' ', t') -> Just t'
+      _ -> Nothing
+
+-- | Parses examples. Examples are a paragraph level entity (separated by an empty line).
+-- Consecutive examples are accepted.
+examples :: Parser (DocH mod a)
+examples = DocExamples <$> (many (try (skipHorizontalSpace *> "\n")) *> go)
+  where
+    go :: Parser [Example]
+    go = do
+      prefix <- takeHorizontalSpace <* ">>>"
+      expr <- takeLine
+      (rs, es) <- resultAndMoreExamples
+      return (makeExample prefix expr rs : es)
+      where
+        resultAndMoreExamples :: Parser ([Text], [Example])
+        resultAndMoreExamples = choice' [moreExamples, result, pure ([], [])]
+          where
+            moreExamples :: Parser ([Text], [Example])
+            moreExamples = (,) [] <$> go
+
+            result :: Parser ([Text], [Example])
+            result = first . (:) <$> nonEmptyLine <*> resultAndMoreExamples
+
+    makeExample :: Text -> Text -> [Text] -> Example
+    makeExample prefix expression res =
+      Example (T.unpack (T.strip expression)) result
+      where
+        result = map (T.unpack . substituteBlankLine . tryStripPrefix) res
+
+        tryStripPrefix xs = fromMaybe xs (T.stripPrefix prefix xs)
+
+        substituteBlankLine "<BLANKLINE>" = ""
+        substituteBlankLine xs = xs
+
+nonEmptyLine :: Parser Text
+nonEmptyLine = try (mfilter (T.any (not . isSpace)) takeLine)
+
+takeLine :: Parser Text
+takeLine = try (takeWhile (/= '\n') <* endOfLine)
+
+endOfLine :: Parser ()
+endOfLine = void "\n" <|> Parsec.eof
+
+-- | Property parser.
+--
+-- >>> snd <$> parseOnly property "prop> hello world"
+-- Right (DocProperty "hello world")
+property :: Parser (DocH mod a)
+property = DocProperty . T.unpack . T.strip <$> ("prop>" *> takeWhile1 (/= '\n'))
+
+-- |
+-- Paragraph level codeblock. Anything between the two delimiting \@ is parsed
+-- for markup.
+codeblock :: Parser (DocH mod Identifier)
+codeblock =
+  DocCodeBlock . parseParagraph . dropSpaces
+    <$> ("@" *> skipHorizontalSpace *> "\n" *> block' <* "@")
+  where
+    dropSpaces xs =
+      case splitByNl xs of
+        [] -> xs
+        ys -> case T.uncons (last ys) of
+          Just (' ', _) -> case mapM dropSpace ys of
+            Nothing -> xs
+            Just zs -> T.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
+        ( \x -> case T.uncons x of
+            Just ('\n', x') -> Just (T.span (/= '\n') x')
+            _ -> Nothing
+        )
+        . ("\n" <>)
+
+    dropSpace t = case T.uncons t of
+      Nothing -> Just ""
+      Just (' ', t') -> Just t'
+      _ -> Nothing
+
+    block' = scan p False
+      where
+        p isNewline c
+          | isNewline && c == '@' = Nothing
+          | isNewline && isSpace c = Just isNewline
+          | otherwise = Just $ c == '\n'
+
+hyperlink :: Parser (DocH mod Identifier)
+hyperlink = choice' [angleBracketLink, autoUrl]
+
+angleBracketLink :: Parser (DocH mod a)
+angleBracketLink =
+  DocHyperlink . makeLabeled (\s -> Hyperlink s . fmap DocString)
+    <$> disallowNewline ("<" *> takeUntil ">")
+
+-- | The text for a markdown link, enclosed in square brackets.
+markdownLinkText :: Parser (DocH mod Identifier)
+markdownLinkText = parseParagraph . T.strip <$> ("[" *> takeUntil "]")
+
+-- | The target for a markdown link, enclosed in parenthesis.
+markdownLinkTarget :: Parser String
+markdownLinkTarget = whitespace *> url
+  where
+    whitespace :: Parser ()
+    whitespace = skipHorizontalSpace <* optional ("\n" *> skipHorizontalSpace)
+
+    url :: Parser String
+    url = rejectWhitespace (decode <$> ("(" *> takeUntil ")"))
+
+    rejectWhitespace :: MonadPlus m => m String -> m String
+    rejectWhitespace = mfilter (all (not . isSpace))
+
+    decode :: Text -> String
+    decode = T.unpack . removeEscapes
+
+-- | Looks for URL-like things to automatically hyperlink even if they
+-- weren't marked as links.
+autoUrl :: Parser (DocH mod a)
+autoUrl = mkLink <$> url
+  where
+    url = mappend <$> choice' ["http://", "https://", "ftp://"] <*> takeWhile1 (not . isSpace)
+
+    mkLink :: Text -> DocH mod a
+    mkLink s = case T.unsnoc s of
+      Just (xs, x) | x `elem` (",.!?" :: String) -> DocHyperlink (mkHyperlink xs) `docAppend` DocString [x]
+      _ -> DocHyperlink (mkHyperlink s)
+
+    mkHyperlink :: Text -> Hyperlink (DocH mod a)
+    mkHyperlink lnk = Hyperlink (T.unpack lnk) Nothing
+
+-- | Parses identifiers with help of 'parseValid'.
+identifier :: Parser (DocH mod Identifier)
+identifier = DocIdentifier <$> parseValid
diff --git a/utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs b/utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
new file mode 100644
index 0000000000000000000000000000000000000000..6ed3d040198af8afaafee6d38d345af54cc390c0
--- /dev/null
+++ b/utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
@@ -0,0 +1,170 @@
+{-# LANGUAGE BangPatterns #-}
+
+-- |
+-- Module      :  Documentation.Haddock.Parser.Identifier
+-- Copyright   :  (c) Alec Theriault 2019,
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Functionality for parsing identifiers and operators
+module Documentation.Haddock.Parser.Identifier
+  ( Identifier (..)
+  , parseValid
+  ) where
+
+import Documentation.Haddock.Parser.Monad
+import Documentation.Haddock.Types (Namespace (..))
+import Text.Parsec
+  ( State (..)
+  , getParserState
+  , setParserState
+  )
+import qualified Text.Parsec as Parsec
+import Text.Parsec.Pos (updatePosChar)
+
+import Data.Text (Text)
+import qualified Data.Text as T
+
+import CompatPrelude
+import Control.Monad (guard)
+import Data.Char (isAlpha, isAlphaNum)
+import Data.Maybe
+
+-- | Identifier string surrounded with namespace, opening, and closing quotes/backticks.
+data Identifier = Identifier !Namespace !Char String !Char
+  deriving (Show, Eq)
+
+parseValid :: Parser Identifier
+parseValid = do
+  s@State{stateInput = inp, statePos = pos} <- getParserState
+
+  case takeIdentifier inp of
+    Nothing -> Parsec.parserFail "parseValid: Failed to match a valid identifier"
+    Just (ns, op, ident, cl, inp') ->
+      let posOp = updatePosChar pos op
+          posIdent = T.foldl updatePosChar posOp ident
+          posCl = updatePosChar posIdent cl
+          s' = s{stateInput = inp', statePos = posCl}
+       in setParserState s' $> Identifier ns op (T.unpack ident) cl
+
+-- | Try to parse a delimited identifier off the front of the given input.
+--
+-- This tries to match as many valid Haskell identifiers/operators as possible,
+-- to the point of sometimes accepting invalid things (ex: keywords). Some
+-- considerations:
+--
+--   - operators and identifiers can have module qualifications
+--   - operators can be wrapped in parens (for prefix)
+--   - identifiers can be wrapped in backticks (for infix)
+--   - delimiters are backticks or regular ticks
+--   - since regular ticks are also valid in identifiers, we opt for the
+--     longest successful parse
+--
+-- This function should make /O(1)/ allocations
+takeIdentifier :: Text -> Maybe (Namespace, Char, Text, Char, Text)
+takeIdentifier input = listToMaybe $ do
+  -- Optional namespace
+  let (ns, input') = case T.uncons input of
+        Just ('v', i) -> (Value, i)
+        Just ('t', i) -> (Type, i)
+        _ -> (None, input)
+
+  -- Opening tick
+  (op, input'') <- maybeToList (T.uncons input')
+  guard (op == '\'' || op == '`')
+
+  -- Identifier/operator
+  (ident, input''') <- wrapped input''
+
+  -- Closing tick
+  (cl, input'''') <- maybeToList (T.uncons input''')
+  guard (cl == '\'' || cl == '`')
+
+  return (ns, op, ident, cl, input'''')
+  where
+    -- \| Parse out a wrapped, possibly qualified, operator or identifier
+    wrapped t = do
+      (c, t') <- maybeToList (T.uncons t)
+      -- Tuples
+      case c of
+        '('
+          | Just (c', _) <- T.uncons t'
+          , c' == ',' || c' == ')' ->
+              do
+                let (commas, t'') = T.span (== ',') t'
+                (')', t''') <- maybeToList (T.uncons t'')
+                return (T.take (T.length commas + 2) t, t''')
+
+        -- Parenthesized
+        '(' -> do
+          (n, t'') <- general False 0 [] t'
+          (')', t''') <- maybeToList (T.uncons t'')
+          return (T.take (n + 2) t, t''')
+
+        -- Backticked
+        '`' -> do
+          (n, t'') <- general False 0 [] t'
+          ('`', t''') <- maybeToList (T.uncons t'')
+          return (T.take (n + 2) t, t''')
+
+        -- Unadorned
+        _ -> do
+          (n, t'') <- general False 0 [] t
+          return (T.take n t, t'')
+
+    -- \| Parse out a possibly qualified operator or identifier
+    general
+      :: Bool
+      -- \^ refuse inputs starting with operators
+      -> Int
+      -- \^ total characters \"consumed\" so far
+      -> [(Int, Text)]
+      -- \^ accumulated results
+      -> Text
+      -- \^ current input
+      -> [(Int, Text)]
+    -- \^ total characters parsed & what remains
+    general !identOnly !i acc t
+      -- Starts with an identifier (either just an identifier, or a module qual)
+      | Just (n, rest) <- identLike t =
+          if T.null rest
+            then acc
+            else case T.head rest of
+              '`' -> (n + i, rest) : acc
+              ')' -> (n + i, rest) : acc
+              '.' -> general False (n + i + 1) acc (T.tail rest)
+              '\'' ->
+                let (m, rest') = quotes rest
+                 in general True (n + m + 1 + i) ((n + m + i, rest') : acc) (T.tail rest')
+              _ -> acc
+      -- An operator
+      | Just (n, rest) <- optr t
+      , not identOnly =
+          (n + i, rest) : acc
+      -- Anything else
+      | otherwise =
+          acc
+
+    -- \| Parse an identifier off the front of the input
+    identLike t
+      | T.null t = Nothing
+      | isAlpha (T.head t) || '_' == T.head t =
+          let !(idt, rest) = T.span (\c -> isAlphaNum c || c == '_') t
+              !(octos, rest') = T.span (== '#') rest
+           in Just (T.length idt + T.length octos, rest')
+      | otherwise = Nothing
+
+    -- \| Parse all but the last quote off the front of the input
+    -- PRECONDITION: T.head t `elem` ['\'', '`']
+    quotes :: Text -> (Int, Text)
+    quotes t =
+      let !n = T.length (T.takeWhile (`elem` ['\'', '`']) t) - 1
+       in (n, T.drop n t)
+
+    -- \| Parse an operator off the front of the input
+    optr t =
+      let !(op, rest) = T.span isSymbolChar t
+       in if T.null op then Nothing else Just (T.length op, rest)
diff --git a/utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Monad.hs b/utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Monad.hs
new file mode 100644
index 0000000000000000000000000000000000000000..344360cf36d495fb751265d1cd8a08b6bdc51e08
--- /dev/null
+++ b/utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Monad.hs
@@ -0,0 +1,163 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeOperators #-}
+
+-- |
+-- Module      :  Documentation.Haddock.Parser.Monad
+-- Copyright   :  (c) Alec Theriault 2018-2019,
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Defines the Parsec monad over which all parsing is done and also provides
+-- more efficient versions of the usual parsec combinator functions (but
+-- specialized to 'Text').
+module Documentation.Haddock.Parser.Monad where
+
+import Text.Parsec
+  ( State (..)
+  , getParserState
+  , setParserState
+  )
+import qualified Text.Parsec as Parsec
+import qualified Text.Parsec.Char as Parsec
+import Text.Parsec.Pos (updatePosChar)
+
+import Data.Text (Text)
+import qualified Data.Text as T
+
+import Control.Applicative as App
+import Control.Monad (mfilter)
+import Data.Bits (Bits (..))
+import Data.Char (ord)
+import Data.List (foldl')
+import Data.String (IsString (..))
+
+import Documentation.Haddock.Types (MetaSince (..))
+
+import CompatPrelude
+import Prelude hiding (takeWhile)
+
+-- | The only bit of information we really care about trudging along with us
+-- through parsing is the version attached to a @\@since@ annotation - if
+-- the doc even contained one.
+newtype ParserState = ParserState
+  { parserStateSince :: Maybe MetaSince
+  }
+  deriving (Eq, Show)
+
+initialParserState :: ParserState
+initialParserState = ParserState Nothing
+
+setSince :: MetaSince -> Parser ()
+setSince since = Parsec.modifyState (\st -> st{parserStateSince = Just since})
+
+type Parser = Parsec.Parsec Text ParserState
+
+instance a ~ Text => IsString (Parser a) where
+  fromString = fmap T.pack . Parsec.string
+
+parseOnly :: Parser a -> Text -> Either String (ParserState, a)
+parseOnly p t = case Parsec.runParser p' initialParserState "<haddock>" t of
+  Left e -> Left (show e)
+  Right (x, s) -> Right (s, x)
+  where
+    p' = (,) <$> p <*> Parsec.getState
+
+-- | Always succeeds, but returns 'Nothing' if at the end of input. Does not
+-- consume input.
+--
+-- Equivalent to @Parsec.optionMaybe . Parsec.lookAhead $ Parsec.anyChar@, but
+-- more efficient.
+peekChar :: Parser (Maybe Char)
+peekChar = headOpt . stateInput <$> getParserState
+  where
+    headOpt t
+      | T.null t = Nothing
+      | otherwise = Just (T.head t)
+{-# INLINE peekChar #-}
+
+-- | Fails if at the end of input. Does not consume input.
+--
+-- Equivalent to @Parsec.lookAhead Parsec.anyChar@, but more efficient.
+peekChar' :: Parser Char
+peekChar' = headFail . stateInput =<< getParserState
+  where
+    headFail t
+      | T.null t = Parsec.parserFail "peekChar': reached EOF"
+      | otherwise = App.pure (T.head t)
+{-# INLINE peekChar' #-}
+
+-- | Parses the given string. Returns the parsed string.
+--
+-- Equivalent to @Parsec.string (T.unpack t) $> t@, but more efficient.
+string :: Text -> Parser Text
+string t = do
+  s@State{stateInput = inp, statePos = pos} <- getParserState
+  case T.stripPrefix t inp of
+    Nothing -> Parsec.parserFail "string: Failed to match the input string"
+    Just inp' ->
+      let pos' = T.foldl updatePosChar pos t
+          s' = s{stateInput = inp', statePos = pos'}
+       in setParserState s' $> t
+
+-- | Keep matching characters as long as the predicate function holds (and
+-- return them).
+--
+-- Equivalent to @fmap T.pack . Parsec.many@, but more efficient.
+takeWhile :: (Char -> Bool) -> Parser Text
+takeWhile f = do
+  s@State{stateInput = inp, statePos = pos} <- getParserState
+  let (t, inp') = T.span f inp
+      pos' = T.foldl updatePosChar pos t
+      s' = s{stateInput = inp', statePos = pos'}
+  setParserState s' $> t
+
+-- | Like 'takeWhile', but fails if no characters matched.
+--
+-- Equivalent to @fmap T.pack . Parsec.many1@, but more efficient.
+takeWhile1 :: (Char -> Bool) -> Parser Text
+takeWhile1 = mfilter (not . T.null) . takeWhile
+
+-- | Scan the input text, accumulating characters as long as the scanning
+-- function returns true.
+scan
+  :: (s -> Char -> Maybe s)
+  -- ^ scan function
+  -> s
+  -- ^ initial state
+  -> Parser Text
+scan f st = do
+  s@State{stateInput = inp, statePos = pos} <- getParserState
+  go inp st pos 0 $ \inp' pos' n ->
+    let s' = s{Parsec.stateInput = inp', Parsec.statePos = pos'}
+     in setParserState s' $> T.take n inp
+  where
+    go inp s !pos !n cont =
+      case T.uncons inp of
+        Nothing -> cont inp pos n -- ran out of input
+        Just (c, inp') ->
+          case f s c of
+            Nothing -> cont inp pos n -- scan function failed
+            Just s' -> go inp' s' (updatePosChar pos c) (n + 1) cont
+
+-- | Parse a decimal number.
+decimal :: Integral a => Parser a
+decimal = foldl' step 0 `fmap` Parsec.many1 Parsec.digit
+  where
+    step a c = a * 10 + fromIntegral (ord c - 48)
+
+-- | Parse a hexadecimal number.
+hexadecimal :: (Integral a, Bits a) => Parser a
+hexadecimal = foldl' step 0 `fmap` Parsec.many1 Parsec.hexDigit
+  where
+    step a c
+      | w >= 48 && w <= 57 = (a `shiftL` 4) .|. fromIntegral (w - 48)
+      | w >= 97 = (a `shiftL` 4) .|. fromIntegral (w - 87)
+      | otherwise = (a `shiftL` 4) .|. fromIntegral (w - 55)
+      where
+        w = ord c
diff --git a/utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Util.hs b/utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Util.hs
new file mode 100644
index 0000000000000000000000000000000000000000..3cc85bcc7a3b0f4b8470181248473b5e34e84661
--- /dev/null
+++ b/utils/haddock/haddock-library/src/Documentation/Haddock/Parser/Util.hs
@@ -0,0 +1,80 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+-- |
+-- Module      :  Documentation.Haddock.Parser.Util
+-- Copyright   :  (c) Mateusz Kowalczyk 2013-2014,
+--                    Simon Hengel      2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Various utility functions used by the parser.
+module Documentation.Haddock.Parser.Util
+  ( takeUntil
+  , removeEscapes
+  , makeLabeled
+  , takeHorizontalSpace
+  , skipHorizontalSpace
+  ) where
+
+import qualified Text.Parsec as Parsec
+
+import Data.Text (Text)
+import qualified Data.Text as T
+
+import Control.Applicative
+import Control.Monad (mfilter)
+import Documentation.Haddock.Parser.Monad
+import Prelude hiding (takeWhile)
+
+import Data.Char (isSpace)
+
+-- | Characters that count as horizontal space
+horizontalSpace :: Char -> Bool
+horizontalSpace c = isSpace c && c /= '\n'
+
+-- | Skip and ignore leading horizontal space
+skipHorizontalSpace :: Parser ()
+skipHorizontalSpace = Parsec.skipMany (Parsec.satisfy horizontalSpace)
+
+-- | Take leading horizontal space
+takeHorizontalSpace :: Parser Text
+takeHorizontalSpace = takeWhile horizontalSpace
+
+makeLabeled :: (String -> Maybe String -> a) -> Text -> a
+makeLabeled f input = case T.break isSpace $ removeEscapes $ T.strip input of
+  (uri, "") -> f (T.unpack uri) Nothing
+  (uri, label) -> f (T.unpack uri) (Just . T.unpack $ T.stripStart label)
+
+-- | Remove escapes from given string.
+--
+-- Only do this if you do not process (read: parse) the input any further.
+removeEscapes :: Text -> Text
+removeEscapes = T.unfoldr go
+  where
+    go :: Text -> Maybe (Char, Text)
+    go xs = case T.uncons xs of
+      Just ('\\', ys) -> T.uncons ys
+      unconsed -> unconsed
+
+-- | Consume characters from the input up to and including the given pattern.
+-- Return everything consumed except for the end pattern itself.
+takeUntil :: Text -> Parser Text
+takeUntil end_ = T.dropEnd (T.length end_) <$> requireEnd (scan p (False, end)) >>= gotSome
+  where
+    end = T.unpack end_
+
+    p :: (Bool, String) -> Char -> Maybe (Bool, String)
+    p acc c = case acc of
+      (True, _) -> Just (False, end)
+      (_, []) -> Nothing
+      (_, x : xs) | x == c -> Just (False, xs)
+      _ -> Just (c == '\\', end)
+
+    requireEnd = mfilter (T.isSuffixOf end_)
+
+    gotSome xs
+      | T.null xs = fail "didn't get any content"
+      | otherwise = return xs
diff --git a/utils/haddock/haddock-library/src/Documentation/Haddock/Types.hs b/utils/haddock/haddock-library/src/Documentation/Haddock/Types.hs
new file mode 100644
index 0000000000000000000000000000000000000000..424e7f86ca0e3f09b9e9e17f36ce2bc837872b46
--- /dev/null
+++ b/utils/haddock/haddock-library/src/Documentation/Haddock/Types.hs
@@ -0,0 +1,280 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE DeriveTraversable #-}
+
+-- |
+-- Module      :  Documentation.Haddock.Types
+-- Copyright   :  (c) Simon Marlow      2003-2006,
+--                    David Waern       2006-2009,
+--                    Mateusz Kowalczyk 2013
+-- License     :  BSD-like
+--
+-- Maintainer  :  haddock@projects.haskellorg
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Exposes documentation data types used for (some) of Haddock.
+module Documentation.Haddock.Types where
+
+#if !MIN_VERSION_base(4,8,0)
+import Control.Applicative
+import Data.Foldable
+import Data.Traversable
+#endif
+
+#if MIN_VERSION_base(4,8,0)
+import Control.Arrow ((***))
+import Data.Bifunctor
+#endif
+
+#if MIN_VERSION_base(4,10,0)
+import Data.Bifoldable
+import Data.Bitraversable
+#endif
+
+-- | A @\@since@ declaration.
+data MetaSince = MetaSince
+  { sincePackage :: Maybe Package
+  -- ^ optional package qualification
+  , sinceVersion :: Version
+  }
+  deriving (Eq, Show)
+
+-- | With the advent of 'Version', we may want to start attaching more
+-- meta-data to comments. We make a structure for this ahead of time
+-- so we don't have to gut half the core each time we want to add such
+-- info.
+data Meta = Meta
+  { _metaSince :: Maybe MetaSince
+  }
+  deriving (Eq, Show)
+
+data MetaDoc mod id = MetaDoc
+  { _meta :: Meta
+  , _doc :: DocH mod id
+  }
+  deriving (Eq, Show, Functor, Foldable, Traversable)
+
+#if MIN_VERSION_base(4,8,0)
+-- | __NOTE__: Only defined for @base >= 4.8.0@
+instance Bifunctor MetaDoc where
+  bimap f g (MetaDoc m d) = MetaDoc m (bimap f g d)
+#endif
+
+#if MIN_VERSION_base(4,10,0)
+-- | __NOTE__: Only defined for @base >= 4.10.0@
+instance Bifoldable MetaDoc where
+  bifoldr f g z d = bifoldr f g z (_doc d)
+
+-- | __NOTE__: Only defined for @base >= 4.10.0@
+instance Bitraversable MetaDoc where
+  bitraverse f g (MetaDoc m d) = MetaDoc m <$> bitraverse f g d
+#endif
+
+overDoc :: (DocH a b -> DocH c d) -> MetaDoc a b -> MetaDoc c d
+overDoc f d = d{_doc = f $ _doc d}
+
+overDocF :: Functor f => (DocH a b -> f (DocH c d)) -> MetaDoc a b -> f (MetaDoc c d)
+overDocF f d = (\x -> d{_doc = x}) <$> f (_doc d)
+
+type Version = [Int]
+type Package = String
+
+data Hyperlink id = Hyperlink
+  { hyperlinkUrl :: String
+  , hyperlinkLabel :: Maybe id
+  }
+  deriving (Eq, Show, Functor, Foldable, Traversable)
+
+data ModLink id = ModLink
+  { modLinkName :: String
+  , modLinkLabel :: Maybe id
+  }
+  deriving (Eq, Show, Functor, Foldable, Traversable)
+
+data Picture = Picture
+  { pictureUri :: String
+  , pictureTitle :: Maybe String
+  }
+  deriving (Eq, Show)
+
+data Header id = Header
+  { headerLevel :: Int
+  -- ^ between 1 and 6 inclusive
+  , headerTitle :: id
+  }
+  deriving (Eq, Show, Functor, Foldable, Traversable)
+
+data Example = Example
+  { exampleExpression :: String
+  , exampleResult :: [String]
+  }
+  deriving (Eq, Show)
+
+data TableCell id = TableCell
+  { tableCellColspan :: Int
+  , tableCellRowspan :: Int
+  , tableCellContents :: id
+  }
+  deriving (Eq, Show, Functor, Foldable, Traversable)
+
+newtype TableRow id = TableRow
+  { tableRowCells :: [TableCell id]
+  }
+  deriving (Eq, Show, Functor, Foldable, Traversable)
+
+data Table id = Table
+  { tableHeaderRows :: [TableRow id]
+  , tableBodyRows :: [TableRow id]
+  }
+  deriving (Eq, Show, Functor, Foldable, Traversable)
+
+data DocH mod id
+  = DocEmpty
+  | DocAppend (DocH mod id) (DocH mod id)
+  | DocString String
+  | DocParagraph (DocH mod id)
+  | DocIdentifier id
+  | -- | A qualified identifier that couldn't be resolved.
+    DocIdentifierUnchecked mod
+  | -- | A link to a module, with an optional label.
+    DocModule (ModLink (DocH mod id))
+  | -- | This constructor has no counterpart in Haddock markup.
+    DocWarning (DocH mod id)
+  | DocEmphasis (DocH mod id)
+  | DocMonospaced (DocH mod id)
+  | DocBold (DocH mod id)
+  | DocUnorderedList [DocH mod id]
+  | DocOrderedList [(Int, DocH mod id)]
+  | DocDefList [(DocH mod id, DocH mod id)]
+  | DocCodeBlock (DocH mod id)
+  | DocHyperlink (Hyperlink (DocH mod id))
+  | DocPic Picture
+  | DocMathInline String
+  | DocMathDisplay String
+  | -- | A (HTML) anchor. It must not contain any spaces.
+    DocAName String
+  | DocProperty String
+  | DocExamples [Example]
+  | DocHeader (Header (DocH mod id))
+  | DocTable (Table (DocH mod id))
+  deriving (Eq, Show, Functor, Foldable, Traversable)
+
+#if MIN_VERSION_base(4,8,0)
+-- | __NOTE__: Only defined for @base >= 4.8.0@
+instance Bifunctor DocH where
+  bimap _ _ DocEmpty = DocEmpty
+  bimap f g (DocAppend docA docB) = DocAppend (bimap f g docA) (bimap f g docB)
+  bimap _ _ (DocString s) = DocString s
+  bimap f g (DocParagraph doc) = DocParagraph (bimap f g doc)
+  bimap _ g (DocIdentifier i) = DocIdentifier (g i)
+  bimap f _ (DocIdentifierUnchecked m) = DocIdentifierUnchecked (f m)
+  bimap f g (DocModule (ModLink m lbl)) = DocModule (ModLink m (fmap (bimap f g) lbl))
+  bimap f g (DocWarning doc) = DocWarning (bimap f g doc)
+  bimap f g (DocEmphasis doc) = DocEmphasis (bimap f g doc)
+  bimap f g (DocMonospaced doc) = DocMonospaced (bimap f g doc)
+  bimap f g (DocBold doc) = DocBold (bimap f g doc)
+  bimap f g (DocUnorderedList docs) = DocUnorderedList (map (bimap f g) docs)
+  bimap f g (DocOrderedList docs) = DocOrderedList (map (\(index, a) -> (index, bimap f g a)) docs)
+  bimap f g (DocDefList docs) = DocDefList (map (bimap f g *** bimap f g) docs)
+  bimap f g (DocCodeBlock doc) = DocCodeBlock (bimap f g doc)
+  bimap f g (DocHyperlink (Hyperlink url lbl)) = DocHyperlink (Hyperlink url (fmap (bimap f g) lbl))
+  bimap _ _ (DocPic picture) = DocPic picture
+  bimap _ _ (DocMathInline s) = DocMathInline s
+  bimap _ _ (DocMathDisplay s) = DocMathDisplay s
+  bimap _ _ (DocAName s) = DocAName s
+  bimap _ _ (DocProperty s) = DocProperty s
+  bimap _ _ (DocExamples examples) = DocExamples examples
+  bimap f g (DocHeader (Header level title)) = DocHeader (Header level (bimap f g title))
+  bimap f g (DocTable (Table header body)) = DocTable (Table (map (fmap (bimap f g)) header) (map (fmap (bimap f g)) body))
+#endif
+
+#if MIN_VERSION_base(4,10,0)
+-- | __NOTE__: Only defined for @base >= 4.10.0@
+instance Bifoldable DocH where
+  bifoldr f g z (DocAppend docA docB) = bifoldr f g (bifoldr f g z docA) docB
+  bifoldr f g z (DocParagraph doc) = bifoldr f g z doc
+  bifoldr _ g z (DocIdentifier i) = g i z
+  bifoldr f _ z (DocIdentifierUnchecked m) = f m z
+  bifoldr f g z (DocWarning doc) = bifoldr f g z doc
+  bifoldr f g z (DocEmphasis doc) = bifoldr f g z doc
+  bifoldr f g z (DocMonospaced doc) = bifoldr f g z doc
+  bifoldr f g z (DocBold doc) = bifoldr f g z doc
+  bifoldr f g z (DocUnorderedList docs) = foldr (flip (bifoldr f g)) z docs
+  bifoldr f g z (DocOrderedList docs) = foldr (flip (bifoldr f g)) z (map snd docs)
+  bifoldr f g z (DocDefList docs) = foldr (\(l, r) acc -> bifoldr f g (bifoldr f g acc l) r) z docs
+  bifoldr f g z (DocCodeBlock doc) = bifoldr f g z doc
+  bifoldr f g z (DocHeader (Header _ title)) = bifoldr f g z title
+  bifoldr f g z (DocTable (Table header body)) = foldr (\r acc -> foldr (flip (bifoldr f g)) acc r) (foldr (\r acc -> foldr (flip (bifoldr f g)) acc r) z body) header
+  bifoldr _ _ z _ = z
+
+-- | __NOTE__: Only defined for @base >= 4.10.0@
+instance Bitraversable DocH where
+  bitraverse _ _ DocEmpty = pure DocEmpty
+  bitraverse f g (DocAppend docA docB) = DocAppend <$> bitraverse f g docA <*> bitraverse f g docB
+  bitraverse _ _ (DocString s) = pure (DocString s)
+  bitraverse f g (DocParagraph doc) = DocParagraph <$> bitraverse f g doc
+  bitraverse _ g (DocIdentifier i) = DocIdentifier <$> g i
+  bitraverse f _ (DocIdentifierUnchecked m) = DocIdentifierUnchecked <$> f m
+  bitraverse f g (DocModule (ModLink m lbl)) = DocModule <$> (ModLink m <$> traverse (bitraverse f g) lbl)
+  bitraverse f g (DocWarning doc) = DocWarning <$> bitraverse f g doc
+  bitraverse f g (DocEmphasis doc) = DocEmphasis <$> bitraverse f g doc
+  bitraverse f g (DocMonospaced doc) = DocMonospaced <$> bitraverse f g doc
+  bitraverse f g (DocBold doc) = DocBold <$> bitraverse f g doc
+  bitraverse f g (DocUnorderedList docs) = DocUnorderedList <$> traverse (bitraverse f g) docs
+  bitraverse f g (DocOrderedList docs) = DocOrderedList <$> traverseSnd (bitraverse f g) docs
+    where traverseSnd f' = traverse (\(x, a) -> (\b -> (x, b)) <$> f' a)
+  bitraverse f g (DocDefList docs) = DocDefList <$> traverse (bitraverse (bitraverse f g) (bitraverse f g)) docs
+  bitraverse f g (DocCodeBlock doc) = DocCodeBlock <$> bitraverse f g doc
+  bitraverse f g (DocHyperlink (Hyperlink url lbl)) = DocHyperlink <$> (Hyperlink url <$> traverse (bitraverse f g) lbl)
+  bitraverse _ _ (DocPic picture) = pure (DocPic picture)
+  bitraverse _ _ (DocMathInline s) = pure (DocMathInline s)
+  bitraverse _ _ (DocMathDisplay s) = pure (DocMathDisplay s)
+  bitraverse _ _ (DocAName s) = pure (DocAName s)
+  bitraverse _ _ (DocProperty s) = pure (DocProperty s)
+  bitraverse _ _ (DocExamples examples) = pure (DocExamples examples)
+  bitraverse f g (DocHeader (Header level title)) = (DocHeader . Header level) <$> bitraverse f g title
+  bitraverse f g (DocTable (Table header body)) = (\h b -> DocTable (Table h b)) <$> traverse (traverse (bitraverse f g)) header <*> traverse (traverse (bitraverse f g)) body
+#endif
+
+-- | The namespace qualification for an identifier.
+data Namespace = Value | Type | None deriving (Eq, Ord, Enum, Show)
+
+-- | Render the a namespace into the same format it was initially parsed.
+renderNs :: Namespace -> String
+renderNs Value = "v"
+renderNs Type = "t"
+renderNs None = ""
+
+-- | 'DocMarkupH' is a set of instructions for marking up documentation.
+-- In fact, it's really just a mapping from 'Doc' to some other
+-- type [a], where [a] is usually the type of the output (HTML, say).
+-- Use 'Documentation.Haddock.Markup.markup' to apply a 'DocMarkupH' to
+-- a 'DocH'.
+--
+-- @since 1.4.5
+data DocMarkupH mod id a = Markup
+  { markupEmpty :: a
+  , markupString :: String -> a
+  , markupParagraph :: a -> a
+  , markupAppend :: a -> a -> a
+  , markupIdentifier :: id -> a
+  , markupIdentifierUnchecked :: mod -> a
+  , markupModule :: ModLink a -> a
+  , markupWarning :: a -> a
+  , markupEmphasis :: a -> a
+  , markupBold :: a -> a
+  , markupMonospaced :: a -> a
+  , markupUnorderedList :: [a] -> a
+  , markupOrderedList :: [(Int, a)] -> a
+  , markupDefList :: [(a, a)] -> a
+  , markupCodeBlock :: a -> a
+  , markupHyperlink :: Hyperlink a -> a
+  , markupAName :: String -> a
+  , markupPic :: Picture -> a
+  , markupMathInline :: String -> a
+  , markupMathDisplay :: String -> a
+  , markupProperty :: String -> a
+  , markupExample :: [Example] -> a
+  , markupHeader :: Header a -> a
+  , markupTable :: Table a -> a
+  }
diff --git a/utils/haddock/haddock-library/test/Documentation/Haddock/Parser/UtilSpec.hs b/utils/haddock/haddock-library/test/Documentation/Haddock/Parser/UtilSpec.hs
new file mode 100644
index 0000000000000000000000000000000000000000..ee16569798e93f5e6425d47d5852326fcc8cf1fc
--- /dev/null
+++ b/utils/haddock/haddock-library/test/Documentation/Haddock/Parser/UtilSpec.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE OverloadedStrings #-}
+
+module Documentation.Haddock.Parser.UtilSpec (main, spec) where
+
+import Data.Either (isLeft)
+import Documentation.Haddock.Parser.Monad
+import Documentation.Haddock.Parser.Util
+import Test.Hspec
+#if !(MIN_VERSION_base(4,8,0))
+import Control.Applicative
+#endif
+
+main :: IO ()
+main = hspec spec
+
+spec :: Spec
+spec = do
+  describe "takeUntil" $ do
+    it "takes everything until a specified byte sequence" $ do
+      snd <$> parseOnly (takeUntil "end") "someend" `shouldBe` Right "some"
+
+    it "requires the end sequence" $ do
+      snd <$> parseOnly (takeUntil "end") "someen" `shouldSatisfy` isLeft
+
+    it "takes escaped bytes unconditionally" $ do
+      snd <$> parseOnly (takeUntil "end") "some\\endend" `shouldBe` Right "some\\end"
diff --git a/utils/haddock/haddock-library/test/Documentation/Haddock/ParserSpec.hs b/utils/haddock/haddock-library/test/Documentation/Haddock/ParserSpec.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a2b36cc95ae0a596c3af56bcd321fc138bb5de90
--- /dev/null
+++ b/utils/haddock/haddock-library/test/Documentation/Haddock/ParserSpec.hs
@@ -0,0 +1,1264 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Documentation.Haddock.ParserSpec (main, spec) where
+
+import Data.Char (isSpace)
+import Data.String
+import Documentation.Haddock.Doc (docAppend)
+import qualified Documentation.Haddock.Parser as Parse
+import Documentation.Haddock.Types
+import Test.Hspec
+import Test.QuickCheck
+
+import Prelude hiding ((<>))
+
+infixr 6 <>
+(<>) :: Doc id -> Doc id -> Doc id
+(<>) = docAppend
+
+type Doc id = DocH () id
+
+instance IsString (Doc String) where
+  fromString = DocString
+
+instance IsString a => IsString (Maybe a) where
+  fromString = Just . fromString
+
+emptyMeta :: Meta
+emptyMeta =
+  Meta
+    { _metaSince = Nothing
+    }
+
+parseParas :: String -> MetaDoc () String
+parseParas = overDoc Parse.toRegular . Parse.parseParas Nothing
+
+parseString :: String -> Doc String
+parseString = Parse.toRegular . Parse.parseString
+
+hyperlink :: String -> Maybe (Doc String) -> Doc String
+hyperlink url = DocHyperlink . Hyperlink url
+
+main :: IO ()
+main = hspec spec
+
+spec :: Spec
+spec = do
+  describe "parseString" $ do
+    let infix 1 `shouldParseTo`
+        shouldParseTo :: String -> Doc String -> Expectation
+        shouldParseTo input ast = parseString input `shouldBe` ast
+
+    it "is total" $ do
+      property $ \xs ->
+        (length . show . parseString) xs `shouldSatisfy` (> 0)
+
+    context "when parsing text" $ do
+      it "can handle unicode" $ do
+        "灼眼のシャナ" `shouldParseTo` "灼眼のシャナ"
+
+      it "accepts numeric character references" $ do
+        "foo b&#97;r b&#97;z &#955;" `shouldParseTo` "foo bar baz λ"
+
+      it "accepts hexadecimal character references" $ do
+        "&#x65;" `shouldParseTo` "e"
+
+      it "allows to backslash-escape characters except \\r" $ do
+        property $ \y -> case y of
+          '\r' -> "\\\r" `shouldParseTo` DocString "\\"
+          x -> ['\\', x] `shouldParseTo` DocString [x]
+
+      context "when parsing strings contaning numeric character references" $ do
+        it "will implicitly convert digits to characters" $ do
+          "&#65;&#65;&#65;&#65;" `shouldParseTo` "AAAA"
+
+          "&#28796;&#30524;&#12398;&#12471;&#12515;&#12490;"
+            `shouldParseTo` "灼眼のシャナ"
+
+        it "will implicitly convert hex encoded characters" $ do
+          "&#x65;&#x65;&#x65;&#x65;" `shouldParseTo` "eeee"
+
+    context "when parsing identifiers" $ do
+      it "parses identifiers enclosed within single ticks" $ do
+        "'foo'" `shouldParseTo` DocIdentifier "foo"
+
+      it "parses identifiers enclosed within backticks" $ do
+        "`foo`" `shouldParseTo` DocIdentifier "foo"
+
+      it "parses identifiers preceded by a backtick and followed by a single quote" $ do
+        "`foo'" `shouldParseTo` DocIdentifier "foo"
+
+      it "parses identifiers preceded by a single quote and followed by a backtick" $ do
+        "'foo`" `shouldParseTo` DocIdentifier "foo"
+
+      it "can parse a constructor identifier" $ do
+        "'Foo'" `shouldParseTo` DocIdentifier "Foo"
+
+      it "can parse a qualified identifier" $ do
+        "'Foo.bar'" `shouldParseTo` DocIdentifier "Foo.bar"
+
+      it "parses a word with an one of the delimiters in it as DocString" $ do
+        "don't" `shouldParseTo` "don't"
+
+      it "doesn't pass pairs of delimiters with spaces between them" $ do
+        "hel'lo w'orld" `shouldParseTo` "hel'lo w'orld"
+
+      it "don't use apostrophe's in the wrong place's" $ do
+        " don't use apostrophe's in the wrong place's"
+          `shouldParseTo` "don't use apostrophe's in the wrong place's"
+
+      it "doesn't parse empty identifiers" $ do
+        "``" `shouldParseTo` "``"
+
+      it "can parse an identifier in infix notation enclosed within backticks" $ do
+        "``infix``" `shouldParseTo` DocIdentifier "`infix`"
+
+      it "can parse identifiers containing a single quote" $ do
+        "'don't'" `shouldParseTo` DocIdentifier "don't"
+
+      it "can parse identifiers ending with a single quote" $ do
+        "'foo''" `shouldParseTo` DocIdentifier "foo'"
+
+      it "can parse identifiers in backticks ending with a single quote" $ do
+        "`foo'`" `shouldParseTo` DocIdentifier "foo'"
+
+      it "can parse an identifier containing a digit" $ do
+        "'f0'" `shouldParseTo` DocIdentifier "f0"
+
+      it "can parse an identifier containing unicode characters" $ do
+        "'λ'" `shouldParseTo` DocIdentifier "λ"
+
+      it "can parse a single quote followed by an identifier" $ do
+        "''foo'" `shouldParseTo` "'" <> DocIdentifier "foo"
+
+      it "can parse an identifier that starts with an underscore" $ do
+        "'_x'" `shouldParseTo` DocIdentifier "_x"
+
+      it "can parse value-namespaced identifiers" $ do
+        "v'foo'" `shouldParseTo` DocIdentifier "foo"
+
+      it "can parse type-namespaced identifiers" $ do
+        "t'foo'" `shouldParseTo` DocIdentifier "foo"
+
+      it "can parse parenthesized operators and backticked identifiers" $ do
+        "'(<|>)'" `shouldParseTo` DocIdentifier "(<|>)"
+        "'`elem`'" `shouldParseTo` DocIdentifier "`elem`"
+
+      it "can properly figure out the end of identifiers" $ do
+        "'DbModule'/'DbUnitId'" `shouldParseTo` DocIdentifier "DbModule" <> "/" <> DocIdentifier "DbUnitId"
+
+    context "when parsing operators" $ do
+      it "can parse an operator enclosed within single quotes" $ do
+        "'.='" `shouldParseTo` DocIdentifier ".="
+
+      it "can parse a qualified operator" $ do
+        "'F..'" `shouldParseTo` DocIdentifier "F.."
+
+      it "can parse a constructor operator" $ do
+        "':='" `shouldParseTo` DocIdentifier ":="
+
+      it "can parse a qualified constructor operator" $ do
+        "'F.:='" `shouldParseTo` DocIdentifier "F.:="
+
+      it "can parse a unicode operator" $ do
+        "'∧'" `shouldParseTo` DocIdentifier "∧"
+
+    context "when parsing URLs" $ do
+      it "parses a URL" $ do
+        "<http://example.com/>" `shouldParseTo` hyperlink "http://example.com/" Nothing
+
+      it "accepts an optional label" $ do
+        "<http://example.com/ some link>" `shouldParseTo` hyperlink "http://example.com/" "some link"
+
+      it "does not accept newlines in label" $ do
+        "<foo bar\nbaz>" `shouldParseTo` "<foo bar\nbaz>"
+
+      -- new behaviour test, this will be now consistent with other markup
+      it "allows us to escape > inside the URL" $ do
+        "<http://examp\\>le.com>"
+          `shouldParseTo` hyperlink "http://examp>le.com" Nothing
+
+        "<http://exa\\>mp\\>le.com>"
+          `shouldParseTo` hyperlink "http://exa>mp>le.com" Nothing
+
+        -- Likewise in label
+        "<http://example.com f\\>oo>"
+          `shouldParseTo` hyperlink "http://example.com" "f>oo"
+
+      it "parses inline URLs" $ do
+        "foo <http://example.com/> bar"
+          `shouldParseTo` "foo "
+          <> hyperlink "http://example.com/" Nothing
+          <> " bar"
+
+      it "doesn't allow for multi-line link tags" $ do
+        "<ba\nz aar>" `shouldParseTo` "<ba\nz aar>"
+
+      context "when parsing markdown links" $ do
+        it "parses a simple link" $ do
+          "[some label](url)"
+            `shouldParseTo` hyperlink "url" "some label"
+
+        it "allows whitespace between label and URL" $ do
+          "[some label] \t (url)"
+            `shouldParseTo` hyperlink "url" "some label"
+
+        it "allows newlines in label" $ do
+          "[some\n\nlabel](url)"
+            `shouldParseTo` hyperlink "url" "some\n\nlabel"
+
+        it "allows escaping in label" $ do
+          "[some\\] label](url)"
+            `shouldParseTo` hyperlink "url" "some] label"
+
+        it "strips leading and trailing whitespace from label" $ do
+          "[  some label  ](url)"
+            `shouldParseTo` hyperlink "url" "some label"
+
+        it "rejects whitespace in URL" $ do
+          "[some label]( url)"
+            `shouldParseTo` "[some label]( url)"
+
+        it "allows inline markup in the label" $ do
+          "[something /emphasized/](url)"
+            `shouldParseTo` hyperlink "url" (Just ("something " <> DocEmphasis "emphasized"))
+
+        context "when URL is on a separate line" $ do
+          it "allows URL to be on a separate line" $ do
+            "[some label]\n(url)"
+              `shouldParseTo` hyperlink "url" "some label"
+
+          it "allows leading whitespace" $ do
+            "[some label]\n  \t (url)"
+              `shouldParseTo` hyperlink "url" "some label"
+
+          it "rejects additional newlines" $ do
+            "[some label]\n\n(url)"
+              `shouldParseTo` "[some label]\n\n(url)"
+
+      context "when autolinking URLs" $ do
+        it "autolinks HTTP URLs" $ do
+          "http://example.com/" `shouldParseTo` hyperlink "http://example.com/" Nothing
+
+        it "autolinks HTTPS URLs" $ do
+          "https://www.example.com/" `shouldParseTo` hyperlink "https://www.example.com/" Nothing
+
+        it "autolinks FTP URLs" $ do
+          "ftp://example.com/" `shouldParseTo` hyperlink "ftp://example.com/" Nothing
+
+        it "does not include a trailing comma" $ do
+          "http://example.com/, Some other sentence."
+            `shouldParseTo` hyperlink "http://example.com/" Nothing
+            <> ", Some other sentence."
+
+        it "does not include a trailing dot" $ do
+          "http://example.com/. Some other sentence."
+            `shouldParseTo` hyperlink "http://example.com/" Nothing
+            <> ". Some other sentence."
+
+        it "does not include a trailing exclamation mark" $ do
+          "http://example.com/! Some other sentence."
+            `shouldParseTo` hyperlink "http://example.com/" Nothing
+            <> "! Some other sentence."
+
+        it "does not include a trailing question mark" $ do
+          "http://example.com/? Some other sentence."
+            `shouldParseTo` hyperlink "http://example.com/" Nothing
+            <> "? Some other sentence."
+
+        it "autolinks URLs occuring mid-sentence with multiple ‘/’s" $ do
+          "foo https://example.com/example bar"
+            `shouldParseTo` "foo "
+            <> hyperlink "https://example.com/example" Nothing
+            <> " bar"
+
+    context "when parsing images" $ do
+      let image :: String -> Maybe String -> Doc String
+          image uri = DocPic . Picture uri
+
+      it "accepts markdown syntax for images" $ do
+        "![label](url)" `shouldParseTo` image "url" "label"
+
+      it "accepts Unicode" $ do
+        "![灼眼のシャナ](url)" `shouldParseTo` image "url" "灼眼のシャナ"
+
+      it "supports deprecated picture syntax" $ do
+        "<<baz>>" `shouldParseTo` image "baz" Nothing
+
+      it "supports title for deprecated picture syntax" $ do
+        "<<b a z>>" `shouldParseTo` image "b" "a z"
+
+    context "when parsing display math" $ do
+      it "accepts markdown syntax for display math containing newlines" $ do
+        "\\[\\pi\n\\pi\\]" `shouldParseTo` DocMathDisplay "\\pi\n\\pi"
+
+    context "when parsing anchors" $ do
+      it "parses a single word anchor" $ do
+        "#foo#" `shouldParseTo` DocAName "foo"
+
+      -- Spaces are not allowed:
+      -- https://www.w3.org/TR/html51/dom.html#the-id-attribute
+      it "doesn't parse a multi word anchor" $ do
+        "#foo bar#" `shouldParseTo` "#foo bar#"
+
+      it "parses a unicode anchor" $ do
+        "#灼眼のシャナ#" `shouldParseTo` DocAName "灼眼のシャナ"
+
+      it "does not accept newlines in anchors" $ do
+        "#foo\nbar#" `shouldParseTo` "#foo\nbar#"
+
+      it "accepts anchors mid-paragraph" $ do
+        "Hello #someAnchor# world!"
+          `shouldParseTo` "Hello "
+          <> DocAName "someAnchor"
+          <> " world!"
+
+      it "does not accept empty anchors" $ do
+        "##" `shouldParseTo` "##"
+
+      it "does not accept anchors containing spaces" $ do
+        "{-# LANGUAGE GADTs #-}" `shouldParseTo` "{-# LANGUAGE GADTs #-}"
+
+    context "when parsing emphasised text" $ do
+      it "emphasises a word on its own" $ do
+        "/foo/" `shouldParseTo` DocEmphasis "foo"
+
+      it "emphasises inline correctly" $ do
+        "foo /bar/ baz" `shouldParseTo` "foo " <> DocEmphasis "bar" <> " baz"
+
+      it "emphasises unicode" $ do
+        "/灼眼のシャナ/" `shouldParseTo` DocEmphasis "灼眼のシャナ"
+
+      it "does not emphasise multi-line strings" $ do
+        " /foo\nbar/" `shouldParseTo` "/foo\nbar/"
+
+      it "does not emphasise the empty string" $ do
+        "//" `shouldParseTo` "//"
+
+      it "parses escaped slashes literally" $ do
+        "/foo\\/bar/" `shouldParseTo` DocEmphasis "foo/bar"
+
+      it "recognizes other markup constructs within emphasised text" $ do
+        "/foo @bar@ baz/"
+          `shouldParseTo` DocEmphasis ("foo " <> DocMonospaced "bar" <> " baz")
+
+      it "allows other markup inside of emphasis" $ do
+        "/__inner bold__/" `shouldParseTo` DocEmphasis (DocBold "inner bold")
+
+      it "doesn't mangle inner markup unicode" $ do
+        "/__灼眼のシャナ &#65;__/" `shouldParseTo` DocEmphasis (DocBold "灼眼のシャナ A")
+
+      it "properly converts HTML escape sequences" $ do
+        "/&#65;&#65;&#65;&#65;/" `shouldParseTo` DocEmphasis "AAAA"
+
+      it "allows to escape the emphasis delimiter inside of emphasis" $ do
+        "/empha\\/sis/" `shouldParseTo` DocEmphasis "empha/sis"
+
+    context "when parsing monospaced text" $ do
+      it "parses simple monospaced text" $ do
+        "@foo@" `shouldParseTo` DocMonospaced "foo"
+
+      it "parses inline monospaced text" $ do
+        "foo @bar@ baz" `shouldParseTo` "foo " <> DocMonospaced "bar" <> " baz"
+
+      it "allows to escape @" $ do
+        "@foo \\@ bar@" `shouldParseTo` DocMonospaced "foo @ bar"
+
+      it "accepts unicode" $ do
+        "@foo 灼眼のシャナ bar@" `shouldParseTo` DocMonospaced "foo 灼眼のシャナ bar"
+
+      it "accepts other markup in monospaced text" $ do
+        "@/foo/@" `shouldParseTo` DocMonospaced (DocEmphasis "foo")
+
+      it "requires the closing @" $ do
+        "@foo /bar/ baz" `shouldParseTo` "@foo " <> DocEmphasis "bar" <> " baz"
+
+    context "when parsing bold strings" $ do
+      it "allows for a bold string on its own" $ do
+        "__bold string__"
+          `shouldParseTo` DocBold "bold string"
+
+      it "bolds inline correctly" $ do
+        "hello __everyone__ there"
+          `shouldParseTo` "hello "
+          <> DocBold "everyone"
+          <> " there"
+
+      it "bolds unicode" $ do
+        "__灼眼のシャナ__"
+          `shouldParseTo` DocBold "灼眼のシャナ"
+
+      it "does not do __multi-line\\n bold__" $ do
+        " __multi-line\n bold__" `shouldParseTo` "__multi-line\n bold__"
+
+      it "allows other markup inside of bold" $ do
+        "__/inner emphasis/__"
+          `shouldParseTo` (DocBold $ DocEmphasis "inner emphasis")
+
+      it "doesn't mangle inner markup unicode" $ do
+        "__/灼眼のシャナ &#65;/__"
+          `shouldParseTo` (DocBold $ DocEmphasis "灼眼のシャナ A")
+
+      it "properly converts HTML escape sequences" $ do
+        "__&#65;&#65;&#65;&#65;__"
+          `shouldParseTo` DocBold "AAAA"
+
+      it "allows to escape the bold delimiter inside of bold" $ do
+        "__bo\\__ld__"
+          `shouldParseTo` DocBold "bo__ld"
+
+      it "doesn't allow for empty bold" $ do
+        "____" `shouldParseTo` "____"
+
+    context "when parsing module strings" $ do
+      it "should parse a module on its own" $ do
+        "\"Module\""
+          `shouldParseTo` DocModule (ModLink "Module" Nothing)
+
+      it "should parse a module inline" $ do
+        "This is a \"Module\"."
+          `shouldParseTo` "This is a "
+          <> DocModule (ModLink "Module" Nothing)
+          <> "."
+
+      it "can accept a simple module name" $ do
+        "\"Hello\"" `shouldParseTo` DocModule (ModLink "Hello" Nothing)
+
+      it "can accept a module name with dots" $ do
+        "\"Hello.World\"" `shouldParseTo` DocModule (ModLink "Hello.World" Nothing)
+
+      it "can accept a module name with unicode" $ do
+        "\"Hello.Worldλ\"" `shouldParseTo` DocModule (ModLink "Hello.Worldλ" Nothing)
+
+      it "parses a module name with a trailing dot as regular quoted string" $ do
+        "\"Hello.\"" `shouldParseTo` "\"Hello.\""
+
+      it "parses a module name with a space as regular quoted string" $ do
+        "\"Hello World\"" `shouldParseTo` "\"Hello World\""
+
+      it "parses a module name with invalid characters as regular quoted string" $ do
+        "\"Hello&[{}(=*)+]!\"" `shouldParseTo` "\"Hello&[{}(=*)+]!\""
+
+      it "accepts a module name with unicode" $ do
+        "\"Foo.Barλ\"" `shouldParseTo` DocModule (ModLink "Foo.Barλ" Nothing)
+
+      it "treats empty module name as regular double quotes" $ do
+        "\"\"" `shouldParseTo` "\"\""
+
+      it "accepts anchor reference syntax as DocModule" $ do
+        "\"Foo#bar\"" `shouldParseTo` DocModule (ModLink "Foo#bar" Nothing)
+
+      it "accepts anchor with hyphen as DocModule" $ do
+        "\"Foo#bar-baz\"" `shouldParseTo` DocModule (ModLink "Foo#bar-baz" Nothing)
+
+      it "accepts old anchor reference syntax as DocModule" $ do
+        "\"Foo\\#bar\"" `shouldParseTo` DocModule (ModLink "Foo\\#bar" Nothing)
+
+    context "when parsing labeled module links" $ do
+      it "parses a simple labeled module link" $ do
+        "[some label](\"Some.Module\")"
+          `shouldParseTo` DocModule (ModLink "Some.Module" (Just "some label"))
+
+      it "allows escaping in label" $ do
+        "[some\\] label](\"Some.Module\")"
+          `shouldParseTo` DocModule (ModLink "Some.Module" (Just "some] label"))
+
+      it "strips leading and trailing whitespace from label" $ do
+        "[  some label  ](\"Some.Module\")"
+          `shouldParseTo` DocModule (ModLink "Some.Module" (Just "some label"))
+
+      it "allows whitespace in module name link" $ do
+        "[some label]( \"Some.Module\"\t )"
+          `shouldParseTo` DocModule (ModLink "Some.Module" (Just "some label"))
+
+      it "allows inline markup in the label" $ do
+        "[something /emphasized/](\"Some.Module\")"
+          `shouldParseTo` DocModule (ModLink "Some.Module" (Just ("something " <> DocEmphasis "emphasized")))
+
+      it "should parse a labeled module on its own" $ do
+        "[label](\"Module\")"
+          `shouldParseTo` DocModule (ModLink "Module" (Just "label"))
+
+      it "should parse a labeled module inline" $ do
+        "This is a [label](\"Module\")."
+          `shouldParseTo` "This is a "
+          <> DocModule (ModLink "Module" (Just "label"))
+          <> "."
+
+      it "can accept a labeled module name with dots" $ do
+        "[label](\"Hello.World\")" `shouldParseTo` DocModule (ModLink "Hello.World" (Just "label"))
+
+      it "can accept a labeled module name with unicode" $ do
+        "[label](\"Hello.Worldλ\")" `shouldParseTo` DocModule (ModLink "Hello.Worldλ" (Just "label"))
+
+      it "parses a labeled module name with a trailing dot as a hyperlink" $ do
+        "[label](\"Hello.\")"
+          `shouldParseTo` hyperlink "\"Hello.\"" (Just "label")
+
+      it "parses a labeled module name with a space as a regular string" $ do
+        "[label](\"Hello World\")" `shouldParseTo` "[label](\"Hello World\")"
+
+      it "parses a module name with invalid characters as a hyperlink" $ do
+        "[label](\"Hello&[{}(=*+]!\")"
+          `shouldParseTo` hyperlink "\"Hello&[{}(=*+]!\"" (Just "label")
+
+      it "accepts a labeled module name with unicode" $ do
+        "[label](\"Foo.Barλ\")"
+          `shouldParseTo` DocModule (ModLink "Foo.Barλ" (Just "label"))
+
+      it "treats empty labeled module name as empty hyperlink" $ do
+        "[label](\"\")"
+          `shouldParseTo` hyperlink "\"\"" (Just "label")
+
+      it "accepts anchor reference syntax for labeled module name" $ do
+        "[label](\"Foo#bar\")"
+          `shouldParseTo` DocModule (ModLink "Foo#bar" (Just "label"))
+
+      it "accepts old anchor reference syntax for labeled module name" $ do
+        "[label](\"Foo\\#bar\")"
+          `shouldParseTo` DocModule (ModLink "Foo\\#bar" (Just "label"))
+
+      it "interprets empty label as a unlabeled module name" $ do
+        "[](\"Module.Name\")"
+          `shouldParseTo` "[]("
+          <> DocModule (ModLink "Module.Name" Nothing)
+          <> ")"
+
+  describe "parseParas" $ do
+    let infix 1 `shouldParseTo`
+        shouldParseTo :: String -> Doc String -> Expectation
+        shouldParseTo input ast = _doc (parseParas input) `shouldBe` ast
+
+    it "is total" $ do
+      property $ \xs ->
+        (length . show . parseParas) xs `shouldSatisfy` (> 0)
+
+    -- See <https://github.com/haskell/haddock/issues/1142>
+    it "doesn't crash on unicode whitespace" $ do
+      "\8197" `shouldParseTo` DocEmpty
+
+    context "when parsing @since" $ do
+      it "adds specified version to the result" $ do
+        parseParas "@since 0.5.0"
+          `shouldBe` MetaDoc
+            { _meta = emptyMeta{_version = Just [0, 5, 0]}
+            , _doc = DocEmpty
+            }
+
+      it "ignores trailing whitespace" $ do
+        parseParas "@since 0.5.0 \t "
+          `shouldBe` MetaDoc
+            { _meta = emptyMeta{_version = Just [0, 5, 0]}
+            , _doc = DocEmpty
+            }
+
+      it "does not allow trailing input" $ do
+        parseParas "@since 0.5.0 foo"
+          `shouldBe` MetaDoc
+            { _meta = emptyMeta{_version = Nothing}
+            , _doc = DocParagraph "@since 0.5.0 foo"
+            }
+
+      it "parses package name" $ do
+        parseParas "@since foo-bar-0.5.0"
+          `shouldBe` MetaDoc
+            { _meta =
+                emptyMeta
+                  { _metaSince =
+                      Just $
+                        MetaSince
+                          { sincePackage = Just "foo-bar"
+                          , sinceVersion = [0, 5, 0]
+                          }
+                  }
+            , _doc = DocParagraph "@since 0.5.0 foo"
+            }
+
+      context "when given multiple times" $ do
+        it "gives last occurrence precedence" $
+          do
+            (parseParas . unlines)
+              [ "@since 0.5.0"
+              , "@since 0.6.0"
+              , "@since 0.7.0"
+              ]
+            `shouldBe` MetaDoc
+              { _meta =
+                  emptyMeta
+                    { _metaSince =
+                        Just $
+                          MetaSince
+                            { sincePackage = Nothing
+                            , sinceVersion = [0, 7, 0]
+                            }
+                    }
+              , _doc = DocEmpty
+              }
+
+    context "when parsing text paragraphs" $ do
+      let isSpecial c = isSpace c || c `elem` (".(=#-[*`\\\"'_/@<>" :: String)
+          filterSpecial = filter (not . isSpecial)
+
+      it "parses an empty paragraph" $ do
+        "" `shouldParseTo` DocEmpty
+
+      it "parses a simple text paragraph" $ do
+        "foo bar baz" `shouldParseTo` DocParagraph "foo bar baz"
+
+      it "accepts markup in text paragraphs" $ do
+        "foo /bar/ baz" `shouldParseTo` DocParagraph ("foo " <> DocEmphasis "bar" <> " baz")
+
+      it "preserve all regular characters" $ do
+        property $ \xs ->
+          let input = filterSpecial xs
+           in (not . null) input ==>
+                input `shouldParseTo` DocParagraph (DocString input)
+
+      it "separates paragraphs by empty lines" $ do
+        unlines
+          [ "foo"
+          , " \t "
+          , "bar"
+          ]
+          `shouldParseTo` DocParagraph "foo"
+          <> DocParagraph "bar"
+
+      context "when a pragraph only contains monospaced text" $ do
+        it "turns it into a code block" $ do
+          "@foo@" `shouldParseTo` DocCodeBlock "foo"
+
+      context "when a paragraph contains a markdown link" $ do
+        it "correctly parses the link" $ do
+          "Blah [label](url)"
+            `shouldParseTo` DocParagraph ("Blah " <> hyperlink "url" "label")
+
+        context "when the paragraph starts with the markdown link" $ do
+          it "correctly parses it as a text paragraph (not a definition list)" $ do
+            "[label](url)"
+              `shouldParseTo` DocParagraph (hyperlink "url" "label")
+
+          it "can be followed by an other paragraph" $ do
+            "[label](url)\n\nfoobar"
+              `shouldParseTo` DocParagraph (hyperlink "url" "label")
+              <> DocParagraph "foobar"
+
+          context "when paragraph contains additional text" $ do
+            it "accepts more text after the link" $ do
+              "[label](url) foo bar baz"
+                `shouldParseTo` DocParagraph (hyperlink "url" "label" <> " foo bar baz")
+
+            it "accepts a newline right after the markdown link" $ do
+              "[label](url)\nfoo bar baz"
+                `shouldParseTo` DocParagraph (hyperlink "url" "label" <> " foo bar baz")
+
+            it "can be followed by an other paragraph" $ do
+              "[label](url)foo\n\nbar"
+                `shouldParseTo` DocParagraph (hyperlink "url" "label" <> "foo")
+                <> DocParagraph "bar"
+
+        context "when the link starts on a new line not at the beginning of the paragraph" $ do
+          it "correctly parses the link" $ do
+            "Bla\n[label](url)"
+              `shouldParseTo` DocParagraph ("Bla\n" <> hyperlink "url" "label")
+
+    context "when parsing birdtracks" $ do
+      it "parses them as a code block" $ do
+        unlines
+          [ ">foo"
+          , ">bar"
+          , ">baz"
+          ]
+          `shouldParseTo` DocCodeBlock "foo\nbar\nbaz"
+
+      it "ignores leading whitespace" $
+        do
+          unlines
+            [ " >foo"
+            , " \t >bar"
+            , " >baz"
+            ]
+          `shouldParseTo` DocCodeBlock "foo\nbar\nbaz"
+
+      it "strips one leading space from each line of the block" $ do
+        unlines
+          [ "> foo"
+          , ">  bar"
+          , "> baz"
+          ]
+          `shouldParseTo` DocCodeBlock "foo\n bar\nbaz"
+
+      it "ignores empty lines when stripping spaces" $ do
+        unlines
+          [ "> foo"
+          , ">"
+          , "> bar"
+          ]
+          `shouldParseTo` DocCodeBlock "foo\n\nbar"
+
+      context "when any non-empty line does not start with a space" $ do
+        it "does not strip any spaces" $ do
+          unlines
+            [ ">foo"
+            , ">  bar"
+            ]
+            `shouldParseTo` DocCodeBlock "foo\n  bar"
+
+      it "ignores nested markup" $ do
+        unlines
+          [ ">/foo/"
+          ]
+          `shouldParseTo` DocCodeBlock "/foo/"
+
+      it "treats them as regular text inside text paragraphs" $ do
+        unlines
+          [ "foo"
+          , ">bar"
+          ]
+          `shouldParseTo` DocParagraph "foo\n>bar"
+
+    context "when parsing code blocks" $ do
+      it "accepts a simple code block" $ do
+        unlines
+          [ "@"
+          , "foo"
+          , "bar"
+          , "baz"
+          , "@"
+          ]
+          `shouldParseTo` DocCodeBlock "foo\nbar\nbaz\n"
+
+      it "ignores trailing whitespace after the opening @" $ do
+        unlines
+          [ "@   "
+          , "foo"
+          , "@"
+          ]
+          `shouldParseTo` DocCodeBlock "foo\n"
+
+      it "rejects code blocks that are not closed" $ do
+        unlines
+          [ "@"
+          , "foo"
+          ]
+          `shouldParseTo` DocParagraph "@\nfoo"
+
+      it "accepts nested markup" $ do
+        unlines
+          [ "@"
+          , "/foo/"
+          , "@"
+          ]
+          `shouldParseTo` DocCodeBlock (DocEmphasis "foo" <> "\n")
+
+      it "allows to escape the @" $ do
+        unlines
+          [ "@"
+          , "foo"
+          , "\\@"
+          , "bar"
+          , "@"
+          ]
+          `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
+          [ " @"
+          , " hello"
+          , " world"
+          , " @"
+          ]
+          `shouldParseTo` DocCodeBlock "hello\nworld\n"
+
+        unlines
+          [ " @"
+          , " hello"
+          , ""
+          , " world"
+          , " @"
+          ]
+          `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"
+
+      it "requires the closing @" $ do
+        "@foo /bar/ baz"
+          `shouldParseTo` DocParagraph ("@foo " <> DocEmphasis "bar" <> " baz")
+
+    context "when parsing examples" $ do
+      it "parses a simple example" $ do
+        ">>> foo" `shouldParseTo` DocExamples [Example "foo" []]
+
+      it "parses an example with result" $ do
+        unlines
+          [ ">>> foo"
+          , "bar"
+          , "baz"
+          ]
+          `shouldParseTo` DocExamples [Example "foo" ["bar", "baz"]]
+
+      it "parses consecutive examples" $ do
+        unlines
+          [ ">>> fib 5"
+          , "5"
+          , ">>> fib 10"
+          , "55"
+          ]
+          `shouldParseTo` DocExamples
+            [ Example "fib 5" ["5"]
+            , Example "fib 10" ["55"]
+            ]
+
+      it
+        ( "requires an example to be separated"
+            ++ " from a previous paragraph by an empty line"
+        )
+        $ do
+          "foobar\n\n>>> fib 10\n55"
+            `shouldParseTo` DocParagraph "foobar"
+            <> DocExamples [Example "fib 10" ["55"]]
+
+      it "parses bird-tracks inside of paragraphs as plain strings" $ do
+        let xs = "foo\n>>> bar"
+        xs `shouldParseTo` DocParagraph (DocString xs)
+
+      it "skips empty lines in front of an example" $ do
+        "\n   \n\n>>> foo" `shouldParseTo` DocExamples [Example "foo" []]
+
+      it "terminates example on empty line" $
+        do
+          unlines
+            [ ">>> foo"
+            , "bar"
+            , "    "
+            , "baz"
+            ]
+          `shouldParseTo` DocExamples [Example "foo" ["bar"]]
+          <> DocParagraph "baz"
+
+      it "parses a <BLANKLINE> result as an empty result" $
+        do
+          unlines
+            [ ">>> foo"
+            , "bar"
+            , "<BLANKLINE>"
+            , "baz"
+            ]
+          `shouldParseTo` DocExamples [Example "foo" ["bar", "", "baz"]]
+
+      it "accepts unicode in examples" $ do
+        ">>> 灼眼\nシャナ" `shouldParseTo` DocExamples [Example "灼眼" ["シャナ"]]
+
+      context "when prompt is prefixed by whitespace" $ do
+        it "strips the exact same amount of whitespace from result lines" $ do
+          unlines
+            [ "   >>> foo"
+            , "   bar"
+            , "   baz"
+            ]
+            `shouldParseTo` DocExamples [Example "foo" ["bar", "baz"]]
+
+        it "preserves additional whitespace" $ do
+          unlines
+            [ "   >>> foo"
+            , "    bar"
+            ]
+            `shouldParseTo` DocExamples [Example "foo" [" bar"]]
+
+        it "keeps original if stripping is not possible" $ do
+          unlines
+            [ "   >>> foo"
+            , " bar"
+            ]
+            `shouldParseTo` DocExamples [Example "foo" [" bar"]]
+
+    context "when parsing paragraphs nested in lists" $ do
+      it "can nest the same type of list" $ do
+        "* foo\n\n    * bar"
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "foo"
+                <> DocUnorderedList [DocParagraph "bar"]
+            ]
+
+      it "can nest another type of list inside" $ do
+        "* foo\n\n    1. bar"
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "foo"
+                <> DocOrderedList [(1, DocParagraph "bar")]
+            ]
+
+      it "can nest a code block inside" $ do
+        "* foo\n\n    @foo bar baz@"
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "foo"
+                <> DocCodeBlock "foo bar baz"
+            ]
+
+        "* foo\n\n    @\n    foo bar baz\n    @"
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "foo"
+                <> DocCodeBlock "foo bar baz\n"
+            ]
+
+      it "can nest more than one level" $ do
+        "* foo\n\n    * bar\n\n        * baz\n        qux"
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "foo"
+                <> DocUnorderedList
+                  [ DocParagraph "bar"
+                      <> DocUnorderedList [DocParagraph "baz\nqux"]
+                  ]
+            ]
+
+      it "won't fail on not fully indented paragraph" $ do
+        "* foo\n\n    * bar\n\n        * qux\nquux"
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "foo"
+                <> DocUnorderedList [DocParagraph "bar"]
+            , DocParagraph "qux\nquux"
+            ]
+
+      it "can nest definition lists" $ do
+        "[a]: foo\n\n    [b]: bar\n\n        [c]: baz\n        qux"
+          `shouldParseTo` DocDefList
+            [
+              ( "a"
+              , "foo"
+                  <> DocDefList
+                    [
+                      ( "b"
+                      , "bar"
+                          <> DocDefList [("c", "baz\nqux")]
+                      )
+                    ]
+              )
+            ]
+
+      it "can come back to top level with a different list" $ do
+        "* foo\n\n    * bar\n\n1. baz"
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "foo"
+                <> DocUnorderedList [DocParagraph "bar"]
+            ]
+          <> DocOrderedList [(1, DocParagraph "baz")]
+
+      it "allows arbitrary initial indent of a list" $
+        do
+          unlines
+            [ "     * foo"
+            , "     * bar"
+            , ""
+            , "         * quux"
+            , ""
+            , "     * baz"
+            ]
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "foo"
+            , DocParagraph "bar"
+                <> DocUnorderedList [DocParagraph "quux"]
+            , DocParagraph "baz"
+            ]
+
+      it "definition lists can come back to top level with a different list" $ do
+        "[foo]: foov\n\n    [bar]: barv\n\n1. baz"
+          `shouldParseTo` DocDefList
+            [
+              ( "foo"
+              , "foov"
+                  <> DocDefList [("bar", "barv")]
+              )
+            ]
+          <> DocOrderedList [(1, DocParagraph "baz")]
+
+      it "list order is preserved in presence of nesting + extra text" $ do
+        "1. Foo\n\n    > Some code\n\n2. Bar\n\nSome text"
+          `shouldParseTo` DocOrderedList
+            [ (1, DocParagraph "Foo" <> DocCodeBlock "Some code")
+            , (2, DocParagraph "Bar")
+            ]
+          <> DocParagraph (DocString "Some text")
+
+        "1. Foo\n\n2. Bar\n\nSome text"
+          `shouldParseTo` DocOrderedList
+            [ (1, DocParagraph "Foo")
+            , (2, DocParagraph "Bar")
+            ]
+          <> DocParagraph (DocString "Some text")
+
+    context "when parsing properties" $ do
+      it "can parse a single property" $ do
+        "prop> 23 == 23" `shouldParseTo` DocProperty "23 == 23"
+
+      it "can parse multiple subsequent properties" $
+        do
+          unlines
+            [ "prop> 23 == 23"
+            , "prop> 42 == 42"
+            ]
+          `shouldParseTo` DocProperty "23 == 23"
+          <> DocProperty "42 == 42"
+
+      it "accepts unicode in properties" $ do
+        "prop> 灼眼のシャナ ≡ 愛"
+          `shouldParseTo` DocProperty "灼眼のシャナ ≡ 愛"
+
+      it "can deal with whitespace before and after the prop> prompt" $ do
+        "  prop>     xs == (reverse $ reverse xs)  "
+          `shouldParseTo` DocProperty "xs == (reverse $ reverse xs)"
+
+    context "when parsing unordered lists" $ do
+      it "parses a simple list" $
+        do
+          unlines
+            [ " * one"
+            , " * two"
+            , " * three"
+            ]
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "one"
+            , DocParagraph "two"
+            , DocParagraph "three"
+            ]
+
+      it "ignores empty lines between list items" $
+        do
+          unlines
+            [ "* one"
+            , ""
+            , "* two"
+            ]
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "one"
+            , DocParagraph "two"
+            ]
+
+      it "accepts an empty list item" $ do
+        "*" `shouldParseTo` DocUnorderedList [DocParagraph DocEmpty]
+
+      it "accepts multi-line list items" $
+        do
+          unlines
+            [ "* point one"
+            , "  more one"
+            , "* point two"
+            , "more two"
+            ]
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "point one\n  more one"
+            , DocParagraph "point two\nmore two"
+            ]
+
+      it "accepts markup in list items" $ do
+        "* /foo/" `shouldParseTo` DocUnorderedList [DocParagraph (DocEmphasis "foo")]
+
+      it "requires empty lines between list and other paragraphs" $
+        do
+          unlines
+            [ "foo"
+            , ""
+            , "* bar"
+            , ""
+            , "baz"
+            ]
+          `shouldParseTo` DocParagraph "foo"
+          <> DocUnorderedList [DocParagraph "bar"]
+          <> DocParagraph "baz"
+
+    context "when parsing ordered lists" $ do
+      it "parses a simple list" $
+        do
+          unlines
+            [ " 1. one"
+            , " (1) two"
+            , " 3. three"
+            ]
+          `shouldParseTo` DocOrderedList
+            [ (1, DocParagraph "one")
+            , (1, DocParagraph "two")
+            , (3, DocParagraph "three")
+            ]
+
+      it "ignores empty lines between list items" $
+        do
+          unlines
+            [ "1. one"
+            , ""
+            , "2. two"
+            ]
+          `shouldParseTo` DocOrderedList
+            [ (1, DocParagraph "one")
+            , (2, DocParagraph "two")
+            ]
+
+      it "accepts an empty list item" $ do
+        "1." `shouldParseTo` DocOrderedList [(1, DocParagraph DocEmpty)]
+
+      it "accepts multi-line list items" $
+        do
+          unlines
+            [ "1. point one"
+            , "  more one"
+            , "1. point two"
+            , "more two"
+            ]
+          `shouldParseTo` DocOrderedList
+            [ (1, DocParagraph "point one\n  more one")
+            , (1, DocParagraph "point two\nmore two")
+            ]
+
+      it "accepts markup in list items" $ do
+        "1. /foo/" `shouldParseTo` DocOrderedList [(1, DocParagraph (DocEmphasis "foo"))]
+
+      it "requires empty lines between list and other paragraphs" $
+        do
+          unlines
+            [ "foo"
+            , ""
+            , "1. bar"
+            , ""
+            , "baz"
+            ]
+          `shouldParseTo` DocParagraph "foo"
+          <> DocOrderedList [(1, DocParagraph "bar")]
+          <> DocParagraph "baz"
+
+    context "when parsing definition lists" $ do
+      it "parses a simple list" $
+        do
+          unlines
+            [ " [foo]: one"
+            , " [bar]: two"
+            , " [baz]: three"
+            ]
+          `shouldParseTo` DocDefList
+            [ ("foo", "one")
+            , ("bar", "two")
+            , ("baz", "three")
+            ]
+
+      it "ignores empty lines between list items" $
+        do
+          unlines
+            [ "[foo]: one"
+            , ""
+            , "[bar]: two"
+            ]
+          `shouldParseTo` DocDefList
+            [ ("foo", "one")
+            , ("bar", "two")
+            ]
+
+      it "accepts an empty list item" $ do
+        "[foo]:" `shouldParseTo` DocDefList [("foo", DocEmpty)]
+
+      it "accepts multi-line list items" $
+        do
+          unlines
+            [ "[foo]: point one"
+            , "  more one"
+            , "[bar]: point two"
+            , "more two"
+            ]
+          `shouldParseTo` DocDefList
+            [ ("foo", "point one\n  more one")
+            , ("bar", "point two\nmore two")
+            ]
+
+      it "accepts markup in list items" $ do
+        "[foo]: /foo/" `shouldParseTo` DocDefList [("foo", DocEmphasis "foo")]
+
+      it "accepts markup for the label" $ do
+        "[/foo/]: bar" `shouldParseTo` DocDefList [(DocEmphasis "foo", "bar")]
+
+      it "requires empty lines between list and other paragraphs" $
+        do
+          unlines
+            [ "foo"
+            , ""
+            , "[foo]: bar"
+            , ""
+            , "baz"
+            ]
+          `shouldParseTo` DocParagraph "foo"
+          <> DocDefList [("foo", "bar")]
+          <> DocParagraph "baz"
+
+      it "dose not require the colon (deprecated - this will be removed in a future release)" $
+        do
+          unlines
+            [ " [foo] one"
+            , " [bar] two"
+            , " [baz] three"
+            ]
+          `shouldParseTo` DocDefList
+            [ ("foo", "one")
+            , ("bar", "two")
+            , ("baz", "three")
+            ]
+
+    context "when parsing consecutive paragraphs" $ do
+      it "will not capture irrelevant consecutive lists" $ do
+        unlines
+          [ "   * bullet"
+          , ""
+          , ""
+          , "   - different bullet"
+          , ""
+          , ""
+          , "   (1) ordered"
+          , " "
+          , "   2. different bullet"
+          , "   "
+          , "   [cat]: kitten"
+          , "   "
+          , "   [pineapple]: fruit"
+          ]
+          `shouldParseTo` DocUnorderedList
+            [ DocParagraph "bullet"
+            , DocParagraph "different bullet"
+            ]
+          <> DocOrderedList
+            [ (1, DocParagraph "ordered")
+            , (2, DocParagraph "different bullet")
+            ]
+          <> DocDefList
+            [ ("cat", "kitten")
+            , ("pineapple", "fruit")
+            ]
+
+    context "when parsing function documentation headers" $ do
+      it "can parse a simple header" $ do
+        "= Header 1\nHello."
+          `shouldParseTo` (DocHeader (Header 1 "Header 1"))
+          <> DocParagraph "Hello."
+
+      it "allow consecutive headers" $ do
+        "= Header 1\n== Header 2"
+          `shouldParseTo` DocHeader (Header 1 "Header 1")
+          <> DocHeader (Header 2 "Header 2")
+
+      it "accepts markup in the header" $ do
+        "= /Header/ __1__\nFoo"
+          `shouldParseTo` DocHeader (Header 1 (DocEmphasis "Header" <> " " <> DocBold "1"))
+          <> DocParagraph "Foo"
diff --git a/utils/haddock/haddock-library/test/Spec.hs b/utils/haddock/haddock-library/test/Spec.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a824f8c30c8d0402a34ed34ad58153e59f95b76f
--- /dev/null
+++ b/utils/haddock/haddock-library/test/Spec.hs
@@ -0,0 +1 @@
+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
diff --git a/utils/haddock/haddock-test/Setup.lhs b/utils/haddock/haddock-test/Setup.lhs
new file mode 100755
index 0000000000000000000000000000000000000000..5bde0de962274e26328ecffabb4e9f6430a10cc9
--- /dev/null
+++ b/utils/haddock/haddock-test/Setup.lhs
@@ -0,0 +1,3 @@
+#!/usr/bin/env runhaskell
+> import Distribution.Simple
+> main = defaultMain
diff --git a/utils/haddock/haddock-test/haddock-test.cabal b/utils/haddock/haddock-test/haddock-test.cabal
new file mode 100644
index 0000000000000000000000000000000000000000..56bbfbcec34c29d7a79aee41f489a2ca5ce4354a
--- /dev/null
+++ b/utils/haddock/haddock-test/haddock-test.cabal
@@ -0,0 +1,29 @@
+cabal-version:        3.0
+name:                 haddock-test
+version:              0.0.1
+synopsis:             Test utilities for Haddock
+license:              BSD-2-Clause
+author:               Simon Marlow, David Waern
+maintainer:           Simon Hengel <sol@typeful.net>, Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>
+homepage:             http://www.haskell.org/haddock/
+bug-reports:          https://github.com/haskell/haddock/issues
+copyright:            (c) Simon Marlow, David Waern
+category:             Documentation
+build-type:           Simple
+tested-with:          GHC==9.6.*
+stability:            experimental
+
+library
+  default-language: Haskell2010
+  ghc-options: -Wall
+  hs-source-dirs:   src
+  build-depends:    base >= 4.3 && < 4.20, bytestring, directory, process, filepath, Cabal
+
+  exposed-modules:
+    Test.Haddock
+    Test.Haddock.Config
+    Test.Haddock.Utils
+    Test.Haddock.Xhtml
+
+  other-modules:
+    Test.Haddock.Process
diff --git a/utils/haddock/haddock-test/src/Test/Haddock.hs b/utils/haddock/haddock-test/src/Test/Haddock.hs
new file mode 100644
index 0000000000000000000000000000000000000000..82e8ef20391011a3b854420ea764ea969b12bc72
--- /dev/null
+++ b/utils/haddock/haddock-test/src/Test/Haddock.hs
@@ -0,0 +1,192 @@
+{-# LANGUAGE RecordWildCards #-}
+
+module Test.Haddock
+  ( module Test.Haddock.Config
+  , runAndCheck
+  , runHaddock
+  , checkFiles
+  ) where
+
+import Control.Monad
+
+import Data.Maybe
+
+import qualified Data.ByteString.Char8 as BS
+import System.Directory
+import System.Exit
+import System.FilePath
+import System.IO
+import System.Process
+
+import Test.Haddock.Config
+import Test.Haddock.Process
+import Test.Haddock.Utils
+
+data CheckResult
+  = Fail
+  | Pass
+  | NoRef
+  | Error String
+  | Accepted
+  deriving (Eq)
+
+runAndCheck :: Config c -> IO ()
+runAndCheck cfg = do
+  crashed <- runHaddock cfg
+  checkFiles cfg crashed
+
+checkFiles :: Config c -> Bool -> IO ()
+checkFiles cfg@(Config{..}) somethingCrashed = do
+  putStrLn "Testing output files..."
+
+  createDirectoryIfMissing True (cfgOutDir cfg)
+  files <- ignore <$> getDirectoryTree (cfgOutDir cfg)
+  failed <- liftM catMaybes . forM files $ \file -> do
+    putStr $ "Checking \"" ++ file ++ "\"... "
+
+    status <- maybeAcceptFile cfg file =<< checkFile cfg file
+    case status of
+      Fail -> putStrLn "FAIL" >> (return $ Just file)
+      Pass -> putStrLn "PASS" >> (return Nothing)
+      NoRef -> putStrLn "PASS [no .ref]" >> (return Nothing)
+      Error msg -> putStrLn ("ERROR (" ++ msg ++ ")") >> return Nothing
+      Accepted -> putStrLn "ACCEPTED" >> return Nothing
+
+  if (null failed && not somethingCrashed)
+    then do
+      putStrLn "All tests passed!"
+      exitSuccess
+    else do
+      unless (null failed) $ maybeDiff cfg failed
+      when somethingCrashed $ putStrLn "Some tests crashed."
+      exitFailure
+  where
+    ignore = filter (not . dcfgCheckIgnore cfgDirConfig)
+
+maybeDiff :: Config c -> [FilePath] -> IO ()
+maybeDiff (Config{cfgDiffTool = Nothing}) _ = pure ()
+maybeDiff cfg@(Config{cfgDiffTool = (Just diff)}) files = do
+  putStrLn "Diffing failed cases..."
+  forM_ files $ diffFile cfg diff
+
+-- | Runs Haddock on all of the test packages, and returns whether 'True' if
+-- any of them caused Haddock to crash.
+runHaddock :: Config c -> IO Bool
+runHaddock cfg@(Config{..}) = do
+  createEmptyDirectory $ cfgOutDir cfg
+
+  putStrLn "Generating documentation..."
+  successes <- forM cfgPackages $ \tpkg -> do
+    haddockStdOut <- openFile cfgHaddockStdOut WriteMode
+    let pc =
+          processConfig
+            { pcArgs =
+                concat
+                  [ cfgHaddockArgs
+                  , pure $ "--odir=" ++ outDir cfgDirConfig tpkg
+                  , tpkgFiles tpkg
+                  ]
+            , pcEnv = Just cfgEnv
+            , pcStdOut = Just haddockStdOut
+            , pcStdErr = Just haddockStdOut
+            }
+
+    let msg = "Failed to run Haddock on test package '" ++ tpkgName tpkg ++ "'"
+    succeeded <- waitForSuccess msg stdout =<< runProcess' cfgHaddockPath pc
+    unless succeeded $ removeDirectoryRecursive (outDir cfgDirConfig tpkg)
+
+    pure succeeded
+
+  let somethingFailed = any not successes
+  when somethingFailed $
+    putStrLn
+      ( "Haddock output is at '"
+          ++ cfgHaddockStdOut
+          ++ "'. "
+          ++ "This file can be set with `--haddock-stdout`."
+      )
+  pure somethingFailed
+
+checkFile :: Config c -> FilePath -> IO CheckResult
+checkFile cfg file = do
+  hasRef <- doesFileExist $ refFile dcfg file
+  if hasRef
+    then do
+      mout <- readOut cfg file
+      mref <- readRef cfg file
+      return $ case (mout, mref) of
+        (Just out, Just ref)
+          | ccfgEqual ccfg out ref -> Pass
+          | otherwise -> Fail
+        _ -> Error "Failed to parse input files"
+    else return NoRef
+  where
+    ccfg = cfgCheckConfig cfg
+    dcfg = cfgDirConfig cfg
+
+-- We use ByteString here to ensure that no lazy I/O is performed.
+-- This way to ensure that the reference file isn't held open in
+-- case after `diffFile` (which is problematic if we need to rewrite
+-- the reference file in `maybeAcceptFile`)
+
+-- | Read the reference artifact for a test
+readRef :: Config c -> FilePath -> IO (Maybe c)
+readRef cfg file =
+  ccfgRead ccfg . BS.unpack
+    <$> BS.readFile (refFile dcfg file)
+  where
+    ccfg = cfgCheckConfig cfg
+    dcfg = cfgDirConfig cfg
+
+-- | Read (and clean) the test output artifact for a test
+readOut :: Config c -> FilePath -> IO (Maybe c)
+readOut cfg file =
+  fmap (ccfgClean ccfg file) . ccfgRead ccfg . BS.unpack
+    <$> BS.readFile (outFile dcfg file)
+  where
+    ccfg = cfgCheckConfig cfg
+    dcfg = cfgDirConfig cfg
+
+diffFile :: Config c -> FilePath -> FilePath -> IO ()
+diffFile cfg diff file = do
+  Just out <- readOut cfg file
+  Just ref <- readRef cfg file
+  writeFile outFile' $ ccfgDump ccfg out
+  writeFile refFile' $ ccfgDump ccfg ref
+
+  putStrLn $ "Diff for file \"" ++ file ++ "\":"
+  hFlush stdout
+  handle <-
+    runProcess' diff $
+      processConfig
+        { pcArgs = [outFile', refFile']
+        , pcStdOut = Just stdout
+        }
+  waitForProcess handle >> return ()
+  where
+    dcfg = cfgDirConfig cfg
+    ccfg = cfgCheckConfig cfg
+    outFile' = outFile dcfg file <.> "dump"
+    refFile' = outFile dcfg file <.> "ref" <.> "dump"
+
+maybeAcceptFile :: Config c -> FilePath -> CheckResult -> IO CheckResult
+maybeAcceptFile cfg file result
+  | cfgAccept cfg && result `elem` [NoRef, Fail] = do
+      Just out <- readOut cfg file
+      let ref = refFile dcfg file
+      createDirectoryIfMissing True (takeDirectory ref)
+      writeFile ref $ ccfgDump ccfg out
+      pure Accepted
+  where
+    dcfg = cfgDirConfig cfg
+    ccfg = cfgCheckConfig cfg
+maybeAcceptFile _ _ result = pure result
+
+outDir :: DirConfig -> TestPackage -> FilePath
+outDir dcfg tpkg = dcfgOutDir dcfg </> tpkgName tpkg
+
+outFile :: DirConfig -> FilePath -> FilePath
+outFile dcfg file = dcfgOutDir dcfg </> file
+
+refFile :: DirConfig -> FilePath -> FilePath
+refFile dcfg file = dcfgRefDir dcfg </> file
diff --git a/utils/haddock/haddock-test/src/Test/Haddock/Config.hs b/utils/haddock/haddock-test/src/Test/Haddock/Config.hs
new file mode 100644
index 0000000000000000000000000000000000000000..2905dc8f059792c4f411305b710fd227c2aa9335
--- /dev/null
+++ b/utils/haddock/haddock-test/src/Test/Haddock/Config.hs
@@ -0,0 +1,365 @@
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE CPP #-}
+
+module Test.Haddock.Config
+    ( TestPackage(..), CheckConfig(..), DirConfig(..), Config(..)
+    , defaultDirConfig
+    , cfgSrcDir, cfgRefDir, cfgOutDir, cfgResDir
+    , parseArgs, checkOpt, loadConfig
+    ) where
+
+
+import Control.Applicative
+import Control.Monad
+
+import qualified Data.List as List
+import Data.Maybe
+
+import Distribution.Text
+import Distribution.Types.PackageName
+import Distribution.InstalledPackageInfo
+import Distribution.Simple.Compiler (PackageDB(..))
+import Distribution.Simple.GHC
+import Distribution.Simple.PackageIndex
+import Distribution.Simple.Program
+import Distribution.Simple.Utils
+import Distribution.Verbosity
+
+import System.Console.GetOpt
+import System.Directory
+import System.Exit
+import System.Environment
+import System.FilePath
+import System.IO
+
+import Test.Haddock.Process
+import Test.Haddock.Utils
+
+
+data TestPackage = TestPackage
+    { tpkgName :: String
+    , tpkgFiles :: [FilePath]
+    }
+
+
+data CheckConfig c = CheckConfig
+    { ccfgRead :: String -> Maybe c
+      -- ^ @f contents@ parses file contents @contents@ to
+      -- produce a thing to be compared.
+    , ccfgClean :: String -> c -> c
+      -- ^ @f fname x@ cleans @x@ to such that it can be compared
+    , ccfgDump :: c -> String
+    , ccfgEqual :: c -> c -> Bool
+    }
+
+
+data DirConfig = DirConfig
+    { dcfgSrcDir :: FilePath
+    , dcfgRefDir :: FilePath
+    , dcfgOutDir :: FilePath
+    , dcfgResDir :: FilePath
+    , dcfgCheckIgnore :: FilePath -> Bool
+    }
+
+
+defaultDirConfig :: FilePath -> DirConfig
+defaultDirConfig baseDir = DirConfig
+    { dcfgSrcDir = baseDir </> "src"
+    , dcfgRefDir = baseDir </> "ref"
+    , dcfgOutDir = baseDir </> "out"
+    , dcfgResDir = rootDir </> "resources"
+    , dcfgCheckIgnore = const False
+    }
+  where
+    rootDir = baseDir </> ".."
+
+
+data Config c = Config
+    { cfgHaddockPath :: FilePath
+    , cfgPackages :: [TestPackage]
+    , cfgHaddockArgs :: [String]
+    , cfgHaddockStdOut :: FilePath
+    , cfgDiffTool :: Maybe FilePath
+    , cfgEnv :: Environment
+    , cfgAccept :: Bool
+    , cfgCheckConfig :: CheckConfig c
+    , cfgDirConfig :: DirConfig
+    }
+
+
+cfgSrcDir, cfgRefDir, cfgOutDir, cfgResDir :: Config c -> FilePath
+cfgSrcDir = dcfgSrcDir . cfgDirConfig
+cfgRefDir = dcfgRefDir . cfgDirConfig
+cfgOutDir = dcfgOutDir . cfgDirConfig
+cfgResDir = dcfgResDir . cfgDirConfig
+
+
+
+data Flag
+    = FlagHaddockPath FilePath
+    | FlagHaddockOptions String
+    | FlagHaddockStdOut FilePath
+    | FlagGhcPath FilePath
+    | FlagDiffTool FilePath
+    | FlagNoDiff
+    | FlagAccept
+    | FlagHelp
+    deriving Eq
+
+
+flagsHaddockPath :: [Flag] -> Maybe FilePath
+flagsHaddockPath flags = mlast [ path | FlagHaddockPath path <- flags ]
+
+flagsGhcPath :: [Flag] -> Maybe FilePath
+flagsGhcPath flags = mlast [ path | FlagGhcPath path <- flags ]
+
+flagsHaddockOptions :: [Flag] -> [String]
+flagsHaddockOptions flags = concat
+    [ words opts | FlagHaddockOptions opts <- flags ]
+
+
+flagsHaddockStdOut :: [Flag] -> Maybe FilePath
+flagsHaddockStdOut flags = mlast [ path | FlagHaddockStdOut path <- flags ]
+
+
+flagsDiffTool :: [Flag] -> Maybe FilePath
+flagsDiffTool flags = mlast [ path | FlagDiffTool path <- flags ]
+
+
+options :: [OptDescr Flag]
+options =
+    [ Option [] ["haddock-path"] (ReqArg FlagHaddockPath "FILE")
+        "path to Haddock executable to exectue tests with"
+    , Option [] ["haddock-options"] (ReqArg FlagHaddockOptions "OPTS")
+        "additional options to run Haddock with"
+    , Option [] ["haddock-stdout"] (ReqArg FlagHaddockStdOut "FILE")
+        "where to redirect Haddock output"
+    , Option [] ["ghc-path"] (ReqArg FlagGhcPath "FILE")
+        "path ghc executable"
+    , Option [] ["diff-tool"] (ReqArg FlagDiffTool "PATH")
+        "diff tool to use when printing failed cases"
+    , Option ['a'] ["accept"] (NoArg FlagAccept)
+        "accept generated output"
+    , Option [] ["no-diff"] (NoArg FlagNoDiff)
+        "do not print diff for failed cases"
+    , Option ['h'] ["help"] (NoArg FlagHelp)
+        "display this help end exit"
+    ]
+
+
+parseArgs :: CheckConfig c -> DirConfig -> [String] -> IO (Config c)
+parseArgs ccfg dcfg args = uncurry (loadConfig ccfg dcfg) =<< checkOpt args
+
+
+checkOpt :: [String] -> IO ([Flag], [String])
+checkOpt args = do
+    let (flags, files, errors) = getOpt Permute options args
+
+    unless (null errors) $ do
+        hPutStr stderr $ concat errors
+        exitFailure
+
+    when (FlagHelp `elem` flags) $ do
+        hPutStrLn stderr $ usageInfo "" options
+        exitSuccess
+
+    return (flags, files)
+
+
+loadConfig :: CheckConfig c -> DirConfig -> [Flag] -> [String] -> IO (Config c)
+loadConfig ccfg dcfg flags files = do
+    cfgEnv <- (:) ("haddock_datadir", dcfgResDir dcfg) <$> getEnvironment
+
+    -- Find Haddock executable
+    systemHaddockPath <- List.lookup "HADDOCK_PATH" <$> getEnvironment
+    haddockOnPath <- findExecutable "haddock"
+
+    let haddock_path = msum [ flagsHaddockPath flags
+                            , systemHaddockPath
+                            , haddockOnPath
+                            ]
+
+    cfgHaddockPath <- case haddock_path of
+        Just path -> pure path
+        Nothing   -> do
+          hPutStrLn stderr "Haddock executable not found; consider using the `--haddock-path` flag."
+          exitFailure
+
+    -- Perhaps Haddock knows where you can find GHC?
+    queriedGhcPath <- do
+      p <- init <$> rawSystemStdout normal cfgHaddockPath ["--print-ghc-path"]
+      exists <- doesFileExist p
+      pure $ if exists then Just p else Nothing
+
+
+    let ghc_path = msum [ flagsGhcPath flags
+                        , queriedGhcPath
+                        ]
+
+    ghcPath <- case ghc_path of
+        Just path -> pure path
+        Nothing   -> do
+          hPutStrLn stderr "GHC executable not found; consider using the `--ghc-path` flag."
+          exitFailure
+
+    printVersions cfgEnv cfgHaddockPath
+
+    cfgPackages <- processFileArgs dcfg files
+
+    cfgHaddockArgs <- liftM concat . sequence $
+        [ pure ["--no-warnings"]
+        , pure ["--bypass-interface-version-check"]
+        , pure ["--odir=" ++ dcfgOutDir dcfg]
+        , pure ["--optghc=-w"]
+        , pure ["--optghc=-hide-all-packages"]
+        , pure $ flagsHaddockOptions flags
+        , baseDependencies ghcPath
+        ]
+
+    let cfgHaddockStdOut = fromMaybe defaultStdOut (flagsHaddockStdOut flags)
+
+    cfgDiffTool <- if FlagNoDiff `elem` flags
+        then pure Nothing
+        else (<|>) <$> pure (flagsDiffTool flags) <*> defaultDiffTool
+
+    let cfgAccept = FlagAccept `elem` flags
+
+    let cfgCheckConfig = ccfg
+    let cfgDirConfig   = dcfg
+
+    return $ Config { .. }
+
+
+printVersions :: Environment -> FilePath -> IO ()
+printVersions env haddockPath = do
+    handleHaddock <- runProcess' haddockPath $ processConfig
+        { pcEnv = Just env
+        , pcArgs = ["--version"]
+        }
+    void $ waitForSuccess "Failed to run `haddock --version`" stderr handleHaddock
+
+    handleGhc <- runProcess' haddockPath $ processConfig
+        { pcEnv = Just env
+        , pcArgs = ["--ghc-version"]
+        }
+    void $ waitForSuccess "Failed to run `haddock --ghc-version`" stderr handleGhc
+
+
+baseDependencies :: FilePath -> IO [String]
+baseDependencies ghcPath = do
+    -- The 'getInstalledPackages' crashes if used when "GHC_PACKAGE_PATH" is
+    -- set to some value. I am not sure why is that happening and what are the
+    -- consequences of unsetting it - but looks like it works (for now).
+    unsetEnv "GHC_PACKAGE_PATH"
+
+    (comp, _, cfg) <- configure normal (Just ghcPath) Nothing
+        defaultProgramDb
+#if MIN_VERSION_Cabal(1,23,0)
+    pkgIndex <- getInstalledPackages normal comp [GlobalPackageDB] cfg
+#else
+    pkgIndex <- getInstalledPackages normal [GlobalPackageDB] cfg
+#endif
+    let
+      pkgs =
+        [ "array"
+        , "base"
+        , "ghc-prim"
+        , "process"
+        , "template-haskell"
+        ]
+    concat `fmap` mapM (getDependency pkgIndex) pkgs
+  where
+    getDependency pkgIndex name = case ifaces pkgIndex name of
+      [] -> do
+        hPutStrLn stderr $ "Couldn't find base test dependency: " ++ name
+        exitFailure
+
+      (unit, ifaceOpt, htmlOpt) : alts -> do
+        when (not . null $ alts) $
+          hPutStr stderr $ unlines
+            [ "Multiple options found for base test dependency: " ++ name
+            , "Choosing the first of these, which has unit id: " ++ unit
+            ]
+
+        case (ifaceOpt, htmlOpt) of
+          (Nothing, _) -> do
+            hPutStr stderr $
+              "No '.haddock' file found for base test dependency: " ++ name
+            exitFailure
+
+          (Just iface, Nothing) -> do
+            hPutStrLn stderr $
+              "No HTML directory found for base test dependency: " ++ name
+            pure [ "--optghc=-package" ++ name
+                 , "--read-interface=" ++ iface
+                 ]
+
+          (Just iface, Just html) ->
+            pure [ "--optghc=-package" ++ name
+                 , "--read-interface=" ++ html ++ "," ++ iface
+                 ]
+
+    ifaces pkgIndex name = do
+        pkg <- join $ snd <$> lookupPackageName pkgIndex (mkPackageName name)
+
+        let unitId = display (installedUnitId pkg)
+            ifaceOpt = listToMaybe (haddockInterfaces pkg)
+            htmlDirOpt = listToMaybe (haddockHTMLs pkg)
+
+        pure (unitId, ifaceOpt, htmlDirOpt)
+    
+
+defaultDiffTool :: IO (Maybe FilePath)
+defaultDiffTool =
+    liftM listToMaybe . filterM isAvailable $ ["colordiff", "diff"]
+  where
+    isAvailable = liftM isJust . findExecutable
+
+
+defaultStdOut :: FilePath
+#ifdef mingw32_HOST_OS
+defaultStdOut = "nul"
+#else
+defaultStdOut = "/dev/null"
+#endif
+
+
+processFileArgs :: DirConfig -> [String] -> IO [TestPackage]
+processFileArgs dcfg [] =
+    processFileArgs' dcfg . filter isValidEntry =<< getDirectoryContents srcDir
+  where
+    isValidEntry entry
+        | hasExtension entry = isSourceFile entry
+        | otherwise = isRealDir entry
+    srcDir = dcfgSrcDir dcfg
+processFileArgs dcfg args = processFileArgs' dcfg args
+
+
+processFileArgs' :: DirConfig -> [String] -> IO [TestPackage]
+processFileArgs' dcfg args = do
+    (dirs, mdls) <- partitionM doesDirectoryExist' . map takeBaseName $ args
+    rootPkg <- pure $ TestPackage
+        { tpkgName = ""
+        , tpkgFiles = map (srcDir </>) mdls
+        }
+    otherPkgs <- forM dirs $ \dir -> do
+        let srcDir' = srcDir </> dir
+        files <- filterM (isModule dir) =<< getDirectoryContents srcDir'
+        pure $ TestPackage
+            { tpkgName = dir
+            , tpkgFiles = map (srcDir' </>) files
+            }
+    pure . filter (not . null . tpkgFiles) $ rootPkg:otherPkgs
+  where
+    doesDirectoryExist' path = doesDirectoryExist (srcDir </> path)
+    isModule dir file = (isSourceFile file &&) <$>
+        doesFileExist (srcDir </> dir </> file)
+    srcDir = dcfgSrcDir dcfg
+
+
+isSourceFile :: FilePath -> Bool
+isSourceFile file = takeExtension file `elem` [".hs", ".lhs"]
+
+
+isRealDir :: FilePath -> Bool
+isRealDir dir = not $ dir `elem` [".", ".."]
diff --git a/utils/haddock/haddock-test/src/Test/Haddock/Process.hs b/utils/haddock/haddock-test/src/Test/Haddock/Process.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a9b0c99e146931dc6ac3637b31bc633d899bae43
--- /dev/null
+++ b/utils/haddock/haddock-test/src/Test/Haddock/Process.hs
@@ -0,0 +1,51 @@
+{-# LANGUAGE RecordWildCards #-}
+
+module Test.Haddock.Process where
+
+import Control.Monad
+
+import System.Exit
+import System.IO
+import System.Process
+
+type Environment = [(String, String)]
+
+data ProcessConfig = ProcessConfig
+  { pcArgs :: [String]
+  , pcWorkDir :: Maybe FilePath
+  , pcEnv :: Maybe Environment
+  , pcStdIn :: Maybe Handle
+  , pcStdOut :: Maybe Handle
+  , pcStdErr :: Maybe Handle
+  }
+  deriving (Show)
+
+processConfig :: ProcessConfig
+processConfig =
+  ProcessConfig
+    { pcArgs = []
+    , pcWorkDir = Nothing
+    , pcEnv = Nothing
+    , pcStdIn = Nothing
+    , pcStdOut = Nothing
+    , pcStdErr = Nothing
+    }
+
+runProcess' :: FilePath -> ProcessConfig -> IO ProcessHandle
+runProcess' path (ProcessConfig{..}) =
+  runProcess
+    path
+    pcArgs
+    pcWorkDir
+    pcEnv
+    pcStdIn
+    pcStdOut
+    pcStdErr
+
+-- | Wait for a process to finish running. If it ends up failing, print out the
+-- error message.
+waitForSuccess :: String -> Handle -> ProcessHandle -> IO Bool
+waitForSuccess msg out handle = do
+  succeeded <- fmap (== ExitSuccess) $ waitForProcess handle
+  unless succeeded $ hPutStrLn out msg
+  pure succeeded
diff --git a/utils/haddock/haddock-test/src/Test/Haddock/Utils.hs b/utils/haddock/haddock-test/src/Test/Haddock/Utils.hs
new file mode 100644
index 0000000000000000000000000000000000000000..44a5589287f7cc6143ae12224c1cb6544f26e274
--- /dev/null
+++ b/utils/haddock/haddock-test/src/Test/Haddock/Utils.hs
@@ -0,0 +1,49 @@
+module Test.Haddock.Utils where
+
+import Control.Monad
+
+import Data.Maybe
+
+import System.Directory
+import System.FilePath
+
+mlast :: [a] -> Maybe a
+mlast = listToMaybe . reverse
+
+partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])
+partitionM _ [] = pure ([], [])
+partitionM p (x : xs) = do
+  (ss, fs) <- partitionM p xs
+  b <- p x
+  pure $ if b then (x : ss, fs) else (ss, x : fs)
+
+whenM :: Monad m => m Bool -> m () -> m ()
+whenM mb action = mb >>= \b -> when b action
+
+getDirectoryTree :: FilePath -> IO [FilePath]
+getDirectoryTree path = do
+  (dirs, files) <- partitionM isDirectory =<< contents
+  subfiles <- fmap concat . forM dirs $ \dir ->
+    map (dir </>) <$> getDirectoryTree (path </> dir)
+  pure $ files ++ subfiles
+  where
+    contents = filter realEntry <$> getDirectoryContents path
+    isDirectory entry = doesDirectoryExist $ path </> entry
+    realEntry entry = not $ entry == "." || entry == ".."
+
+createEmptyDirectory :: FilePath -> IO ()
+createEmptyDirectory path = do
+  whenM (doesDirectoryExist path) $ removeDirectoryRecursive path
+  createDirectory path
+
+-- | Just like 'copyFile' but output directory path is not required to exist.
+copyFile' :: FilePath -> FilePath -> IO ()
+copyFile' old new = do
+  createDirectoryIfMissing True $ takeDirectory new
+  copyFile old new
+
+crlfToLf :: String -> String
+crlfToLf "" = ""
+crlfToLf ('\r' : '\n' : rest) = '\n' : crlfToLf rest
+crlfToLf ('\r' : rest) = '\n' : crlfToLf rest
+crlfToLf (other : rest) = other : crlfToLf rest
diff --git a/utils/haddock/haddock-test/src/Test/Haddock/Xhtml.hs b/utils/haddock/haddock-test/src/Test/Haddock/Xhtml.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8e2462eebbe3e75a7acc747f3c5e7180d76a3acd
--- /dev/null
+++ b/utils/haddock/haddock-test/src/Test/Haddock/Xhtml.hs
@@ -0,0 +1,130 @@
+module Test.Haddock.Xhtml
+  ( Xml
+  , parseXml
+  , dumpXml
+  , stripLinks
+  , stripLinksWhen
+  , stripAnchorsWhen
+  , stripIdsWhen
+  , stripFooter
+  ) where
+
+{-
+This module used to actually parse the HTML (using the `xml` parsing library)
+which made it was possible to do more proper normalization of things like ids or
+names.
+
+However, in the interests of being able to run this from within the GHC
+testsuite (where non-bootlib dependencies are a liability), this was swapped
+out for some simple string manipulation. Since the test cases aren't very
+and since the `xhtml` library already handles the pretty-printing aspect,
+this would appear to be a reasonable compromise for now.
+-}
+
+import Data.Char (isSpace)
+import Data.List (isPrefixOf, stripPrefix)
+
+-- | Simple wrapper around the pretty-printed HTML source
+newtype Xml = Xml {unXml :: String}
+
+-- | Part of parsing involves dropping the @DOCTYPE@ line
+-- and windows newline endings
+parseXml :: String -> Maybe Xml
+parseXml = Just . Xml . filter (/= '\r') . dropDocTypeLine
+  where
+    dropDocTypeLine bs
+      | "<!DOCTYPE" `isPrefixOf` bs =
+          drop 1 (dropWhile (/= '\n') bs)
+      | otherwise =
+          bs
+
+dumpXml :: Xml -> String
+dumpXml = unXml
+
+type Attr = String
+type Value = String
+
+-- | Almost all sanitization operations take the form of:
+--
+--    * match an attribute key
+--    * check something about the value
+--    * if the check succeeded, replace the value with a dummy value
+stripAttrValueWhen
+  :: Attr
+  -- ^ attribute key
+  -> Value
+  -- ^ dummy attribute value
+  -> (Value -> Bool)
+  -- ^ determine whether we should modify the attribute
+  -> Xml
+  -- ^ input XML
+  -> Xml
+  -- ^ output XML
+stripAttrValueWhen key fallback p (Xml body) = Xml (filterAttrs body)
+  where
+    keyEq = key ++ "=\""
+
+    filterAttrs "" = ""
+    filterAttrs b@(c : cs)
+      | Just valRest <- stripPrefix keyEq b
+      , Just (val, rest) <- spanToEndOfString valRest =
+          if p val
+            then keyEq ++ fallback ++ "\"" ++ filterAttrs rest
+            else keyEq ++ val ++ "\"" ++ filterAttrs rest
+      | otherwise =
+          c : filterAttrs cs
+
+-- | Spans to the next (unescaped) @\"@ character.
+--
+-- >>> spanToEndOfString "no closing quotation"
+-- Nothing
+-- >>> spanToEndOfString "foo\" bar \"baz\""
+-- Just ("foo", " bar \"baz\"")
+-- >>> spanToEndOfString "foo\\\" bar \"baz\""
+-- Just ("foo\\\" bar ", "baz\"")
+spanToEndOfString :: String -> Maybe (String, String)
+spanToEndOfString ('"' : rest) = Just ("", rest)
+spanToEndOfString ('\\' : c : rest)
+  | Just (str, rest') <- spanToEndOfString rest =
+      Just ('\\' : c : str, rest')
+spanToEndOfString (c : rest)
+  | Just (str, rest') <- spanToEndOfString rest =
+      Just (c : str, rest')
+spanToEndOfString _ = Nothing
+
+-- | Replace hyperlink targets with @\"#\"@ if they match a predicate
+stripLinksWhen :: (Value -> Bool) -> Xml -> Xml
+stripLinksWhen = stripAttrValueWhen "href" "#"
+
+-- | Replace all hyperlink targets with @\"#\"@
+stripLinks :: Xml -> Xml
+stripLinks = stripLinksWhen (const True)
+
+-- | Replace id's with @\"\"@ if they match a predicate
+stripIdsWhen :: (Value -> Bool) -> Xml -> Xml
+stripIdsWhen = stripAttrValueWhen "id" ""
+
+-- | Replace names's with @\"\"@ if they match a predicate
+stripAnchorsWhen :: (Value -> Bool) -> Xml -> Xml
+stripAnchorsWhen = stripAttrValueWhen "name" ""
+
+-- | Remove the @div@ which has @id=\"footer\"@
+stripFooter :: Xml -> Xml
+stripFooter (Xml body) = Xml (findDiv body)
+  where
+    findDiv "" = ""
+    findDiv b@(c : cs)
+      | Just divRest <- stripPrefix "<div id=\"footer\"" b
+      , Just rest <- dropToDiv divRest =
+          rest
+      | otherwise =
+          c : findDiv cs
+
+    dropToDiv "" = Nothing
+    dropToDiv b@(_ : cs)
+      | Just valRest <- stripPrefix "</div" b
+      , valRest' <- dropWhile isSpace valRest
+      , Just valRest'' <- stripPrefix ">" valRest' =
+          Just valRest''
+      | otherwise =
+          dropToDiv cs
diff --git a/utils/haddock/haddock.cabal b/utils/haddock/haddock.cabal
new file mode 100644
index 0000000000000000000000000000000000000000..b6ec40f95d6ddf70d161bc96351590cdb204faca
--- /dev/null
+++ b/utils/haddock/haddock.cabal
@@ -0,0 +1,193 @@
+cabal-version:        3.0
+name:                 haddock
+version:              2.28.0
+synopsis:             A documentation-generation tool for Haskell libraries
+description:
+  This is Haddock, a tool for automatically generating documentation
+  from annotated Haskell source code. It is primary intended for documenting
+  library interfaces, but it should be useful for any kind of Haskell code.
+  .
+  Haddock lets you write documentation annotations next to the definitions of
+  functions and types in the source code, in a syntax that is easy on the eye
+  when writing the source code (no heavyweight mark-up).
+  .
+  Haddock understands Haskell's module system, so you can structure your code
+  however you like without worrying that internal structure will be exposed in
+  the generated documentation. For example, it is common to implement a library
+  in several modules, but define the external API by having a single module
+  which re-exports parts of these implementation modules. Using Haddock, you can
+  still write documentation annotations next to the actual definitions of the
+  functions and types in the library, but the documentation annotations from the
+  implementation will be propagated to the external API when the documentation is
+  generated. Abstract types and classes are handled correctly. In fact, even
+  without any documentation annotations, Haddock can generate useful documentation
+  from your source code.
+  .
+  Documentation for the haddock binary is available at [readthedocs](https://haskell-haddock.readthedocs.io/en/latest/).
+  .
+  <<https://cdn.rawgit.com/haskell/haddock/ghc-8.10/doc/cheatsheet/haddocks.svg>>
+license:              BSD-3-Clause
+license-file:         LICENSE
+author:               Simon Marlow, David Waern
+maintainer:           Alec Theriault <alec.theriault@gmail.com>, Alex Biehl <alexbiehl@gmail.com>, Simon Hengel <sol@typeful.net>, Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>
+homepage:             http://www.haskell.org/haddock/
+bug-reports:          https://github.com/haskell/haddock/issues
+copyright:            (c) Simon Marlow, David Waern
+category:             Documentation
+build-type:           Simple
+tested-with:          GHC==9.6.*
+
+extra-source-files:
+  CHANGES.md
+  README.md
+  doc/Makefile
+  doc/README.md
+  doc/*.rst
+  doc/conf.py
+  haddock-api/src/haddock.sh
+  html-test/src/*.hs
+  html-test/ref/*.html
+  hypsrc-test/src/*.hs
+  hypsrc-test/src/*.h
+  hypsrc-test/ref/src/*.html
+  latex-test/src/**/*.hs
+  latex-test/ref/**/*.tex
+  hoogle-test/src/**/*.hs
+  hoogle-test/ref/**/*.txt
+
+flag in-ghc-tree
+  description: Are we in a GHC tree?
+  default: False
+  manual: True
+
+executable haddock
+  default-language:     Haskell2010
+  main-is:              Main.hs
+  hs-source-dirs:       driver
+  ghc-options:          -funbox-strict-fields -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -O2 -threaded
+
+  -- haddock typically only supports a single GHC major version
+  build-depends:
+    base ^>= 4.13.0.0 || ^>= 4.14.0.0 || ^>= 4.15.0.0 || ^>= 4.16.0.0 || ^>= 4.17.0.0 || ^>= 4.18.0.0 || ^>= 4.19.0.0 || ^>= 4.20.0.0
+
+  if flag(in-ghc-tree)
+    hs-source-dirs: haddock-api/src,  haddock-library/src
+    cpp-options: -DIN_GHC_TREE
+    build-depends:
+      filepath,
+      directory,
+      containers,
+      deepseq,
+      exceptions,
+      array,
+      xhtml >= 3000.2 && < 3000.3,
+      ghc-boot,
+      ghc-boot-th,
+      ghc == 9.11.*,
+      bytestring,
+      parsec,
+      text,
+      transformers,
+      mtl
+
+    other-modules:
+      CompatPrelude
+      Documentation.Haddock.Parser
+      Documentation.Haddock.Parser.Monad
+      Documentation.Haddock.Parser.Identifier
+      Documentation.Haddock.Types
+      Documentation.Haddock.Doc
+      Documentation.Haddock.Parser.Util
+      Documentation.Haddock.Markup
+
+      Documentation.Haddock
+      Haddock
+      Haddock.Interface
+      Haddock.Interface.Json
+      Haddock.Interface.Rename
+      Haddock.Interface.Create
+      Haddock.Interface.AttachInstances
+      Haddock.Interface.LexParseRn
+      Haddock.Interface.ParseModuleHeader
+      Haddock.Interface.RenameType
+      Haddock.Parser
+      Haddock.Utils
+      Haddock.Utils.Json
+      Haddock.Utils.Json.Parser
+      Haddock.Utils.Json.Types
+      Haddock.Backends.Xhtml
+      Haddock.Backends.Xhtml.Decl
+      Haddock.Backends.Xhtml.DocMarkup
+      Haddock.Backends.Xhtml.Layout
+      Haddock.Backends.Xhtml.Meta
+      Haddock.Backends.Xhtml.Names
+      Haddock.Backends.Xhtml.Themes
+      Haddock.Backends.Xhtml.Types
+      Haddock.Backends.Xhtml.Utils
+      Haddock.Backends.LaTeX
+      Haddock.Backends.HaddockDB
+      Haddock.Backends.Hoogle
+      Haddock.Backends.Hyperlinker
+      Haddock.Backends.Hyperlinker.Parser
+      Haddock.Backends.Hyperlinker.Renderer
+      Haddock.Backends.Hyperlinker.Types
+      Haddock.Backends.Hyperlinker.Utils
+      Haddock.ModuleTree
+      Haddock.Types
+      Haddock.Doc
+      Haddock.Version
+      Haddock.InterfaceFile
+      Haddock.Options
+      Haddock.GhcUtils
+      Haddock.Convert
+
+      Paths_haddock
+
+    autogen-modules:
+      Paths_haddock
+
+  else
+    -- in order for haddock's advertised version number to have proper meaning,
+    -- we pin down to a single haddock-api version.
+    build-depends:  haddock-api == 2.28.0
+
+test-suite html-test
+  type:             exitcode-stdio-1.0
+  -- This tells cabal that this test depends on the executable
+  -- component 'haddock' from this very same package, as well
+  -- as adding the build-folder where the `haddock`
+  -- executable can be found in front of $PATH
+  build-tool-depends: haddock:haddock
+  default-language:   Haskell2010
+  main-is:            Main.hs
+  hs-source-dirs:     html-test
+  build-depends:      base, filepath, haddock-test == 0.0.1
+
+test-suite hypsrc-test
+  type:               exitcode-stdio-1.0
+  build-tool-depends: haddock:haddock
+  default-language:   Haskell2010
+  main-is:            Main.hs
+  hs-source-dirs:     hypsrc-test
+  build-depends:      base, filepath, haddock-test == 0.0.1
+  ghc-options:        -Wall -fwarn-tabs
+
+test-suite latex-test
+  type:               exitcode-stdio-1.0
+  build-tool-depends: haddock:haddock
+  default-language:   Haskell2010
+  main-is:            Main.hs
+  hs-source-dirs:     latex-test
+  build-depends:      base, filepath, haddock-test == 0.0.1
+
+test-suite hoogle-test
+  type:               exitcode-stdio-1.0
+  build-tool-depends: haddock:haddock
+  default-language:   Haskell2010
+  main-is:            Main.hs
+  hs-source-dirs:     hoogle-test
+  build-depends:      base, filepath, haddock-test == 0.0.1
+
+source-repository head
+  type:     git
+  location: https://github.com/haskell/haddock.git
diff --git a/utils/haddock/haddock.wrapper b/utils/haddock/haddock.wrapper
new file mode 100644
index 0000000000000000000000000000000000000000..a0fbda305714ca094c1502acb66bbb2785f351c6
--- /dev/null
+++ b/utils/haddock/haddock.wrapper
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec "$executablename" -B"$topdir" -l"$topdir" ${1+"$@"}
diff --git a/utils/haddock/hoogle-test/Main.hs b/utils/haddock/hoogle-test/Main.hs
new file mode 100644
index 0000000000000000000000000000000000000000..d19ae585daed7dd7c8c1579d970919527e0afc0f
--- /dev/null
+++ b/utils/haddock/hoogle-test/Main.hs
@@ -0,0 +1,34 @@
+{-# LANGUAGE CPP #-}
+
+
+import Data.Function
+import System.Environment
+import System.FilePath
+
+import Test.Haddock
+import Test.Haddock.Utils
+
+
+checkConfig :: CheckConfig String
+checkConfig = CheckConfig
+    { ccfgRead = Just
+    , ccfgClean = \_ -> id
+    , ccfgDump = id
+    , ccfgEqual = (==) `on` crlfToLf
+    }
+
+
+dirConfig :: DirConfig
+dirConfig = defaultDirConfig $ takeDirectory __FILE__
+
+
+main :: IO ()
+main = do
+    cfg <- parseArgs checkConfig dirConfig =<< getArgs
+    runAndCheck $ cfg
+        { cfgHaddockArgs = cfgHaddockArgs cfg ++
+            [ "--package-name=test"
+            , "--package-version=0.0.0"
+            , "--hoogle"
+            ]
+        }
diff --git a/utils/haddock/hoogle-test/ref/Bug722/test.txt b/utils/haddock/hoogle-test/ref/Bug722/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..052c6e950f32cb9fbaa7bcb41b65086d5e63562d
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/Bug722/test.txt
@@ -0,0 +1,16 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module Bug722
+class Foo a
+(!@#) :: Foo a => a -> a -> a
+infixl 4 !@#
+type family (&*) :: Type -> Type -> Type
+infixr 3 &*
+data a :-& b
+(:^&) :: a -> b -> (:-&) a b
+infixl 6 :-&
+infixl 6 :^&
diff --git a/utils/haddock/hoogle-test/ref/Bug806/test.txt b/utils/haddock/hoogle-test/ref/Bug806/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..222f6cfdae515ec29f061ed84e1a4dcc186914ee
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/Bug806/test.txt
@@ -0,0 +1,25 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module Bug806
+
+-- | <a>F1</a> docs
+type family F1 a b :: Type -> Type
+
+-- | <a>F2</a> docs
+type family F2 a b :: Type -> Type
+
+-- | <a>D</a> docs
+data family D a :: Type -> Type
+v :: Int
+
+-- | <a>C</a> docs
+class C a where {
+    
+    -- | <a>AT</a> docs
+    type AT a;
+    type AT a = Proxy Proxy Proxy Proxy Proxy Proxy Proxy Proxy Proxy Proxy :: Type -> Type;
+}
diff --git a/utils/haddock/hoogle-test/ref/Bug825/test.txt b/utils/haddock/hoogle-test/ref/Bug825/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..a800c10baa235f434f2ba317d0b9e9f871e41ada
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/Bug825/test.txt
@@ -0,0 +1,9 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module Bug825
+data a :~: b
+data a :~~: b
diff --git a/utils/haddock/hoogle-test/ref/Bug946/test.txt b/utils/haddock/hoogle-test/ref/Bug946/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..ff63a7661400660ba344f7531c0fb2d90065b877
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/Bug946/test.txt
@@ -0,0 +1,19 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module Bug946
+
+-- | A wrapper around <a>Int</a>
+data AnInt
+
+-- | some <a>Int</a>
+AnInt :: Int -> AnInt
+
+-- | The <a>Int</a> 0
+pattern Zero :: AnInt
+
+-- | The double 2.5
+pattern TwoPointFive :: Double
diff --git a/utils/haddock/hoogle-test/ref/Bug992/test.txt b/utils/haddock/hoogle-test/ref/Bug992/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..def969eadb0dc8db604bac739417d007f46bc8c8
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/Bug992/test.txt
@@ -0,0 +1,9 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module Bug992
+data K (m :: Type -> Type)
+K :: K (m :: Type -> Type)
diff --git a/utils/haddock/hoogle-test/ref/assoc-types/test.txt b/utils/haddock/hoogle-test/ref/assoc-types/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..0d2aa4a96377a19855fd26fda866ffb0267b0c7d
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/assoc-types/test.txt
@@ -0,0 +1,14 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module AssocTypes
+class Foo a where {
+    type Bar a b;
+    type Baz a;
+    type Baz a = [(a, a)];
+}
+bar :: Foo a => Bar a a
+instance AssocTypes.Foo [a]
diff --git a/utils/haddock/hoogle-test/ref/classes/test.txt b/utils/haddock/hoogle-test/ref/classes/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..98ef48e98be9de9b260a7a43f1c81a2632f56888
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/classes/test.txt
@@ -0,0 +1,17 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module Classes
+class Foo (f :: Type -> Type)
+bar :: Foo f => f a -> f b -> f (a, b)
+baz :: Foo f => f ()
+class Quux q
+(+++) :: Quux q => q -> q -> q
+(///) :: Quux q => q -> q -> q
+(***) :: Quux q => q -> q -> q
+logBase :: Quux q => q -> q -> q
+foo :: Quux q => q -> q -> q
+quux :: Quux q => q -> q -> q
diff --git a/utils/haddock/hoogle-test/ref/fixity/test.txt b/utils/haddock/hoogle-test/ref/fixity/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..6f6095391ea0aa913d77c7425f11ea942771f6c8
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/fixity/test.txt
@@ -0,0 +1,13 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module Fixity
+(+++) :: a -> a -> a
+infix 6 +++
+(***) :: a -> a -> a
+infixl 7 ***
+(///) :: a -> a -> a
+infixr 8 ///
diff --git a/utils/haddock/hoogle-test/ref/modules/test.txt b/utils/haddock/hoogle-test/ref/modules/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..6705b79059cb4608fc637ef17f7fbf1feaec406a
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/modules/test.txt
@@ -0,0 +1,13 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module Foo
+foo :: Int -> Int
+foo' :: Int -> Int -> Int
+
+module Bar
+bar :: Int -> Int
+bar' :: Int -> Int -> Int
diff --git a/utils/haddock/hoogle-test/ref/type-sigs/test.txt b/utils/haddock/hoogle-test/ref/type-sigs/test.txt
new file mode 100644
index 0000000000000000000000000000000000000000..b07d623fb7d8210d853ff4c93ce45a6c6ec16756
--- /dev/null
+++ b/utils/haddock/hoogle-test/ref/type-sigs/test.txt
@@ -0,0 +1,16 @@
+-- Hoogle documentation, generated by Haddock
+-- See Hoogle, http://www.haskell.org/hoogle/
+
+@package test
+@version 0.0.0
+
+module ReaderT
+newtype ReaderT r (m :: Type -> Type) a
+ReaderT :: (r -> m a) -> ReaderT r (m :: Type -> Type) a
+[runReaderT] :: ReaderT r (m :: Type -> Type) a -> r -> m a
+
+module ReaderTReexport
+newtype ReaderT r (m :: Type -> Type) a
+ReaderT :: (r -> m a) -> ReaderT r (m :: Type -> Type) a
+[runReaderT] :: ReaderT r (m :: Type -> Type) a -> r -> m a
+runReaderT :: ReaderT r m a -> r -> m a
diff --git a/utils/haddock/hoogle-test/run b/utils/haddock/hoogle-test/run
new file mode 100755
index 0000000000000000000000000000000000000000..3e72be809736d303b1a9c9fabc65d7ae7a177683
--- /dev/null
+++ b/utils/haddock/hoogle-test/run
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+export HADDOCK_PATH=$(which haddock)
+LIB_PATH="$(dirname "$BASH_SOURCE")/../haddock-test/src/"
+MAIN_PATH="$(dirname "$BASH_SOURCE")/Main.hs"
+runhaskell -i:"$LIB_PATH" $MAIN_PATH $@
diff --git a/utils/haddock/hoogle-test/src/Bug722/Bug722.hs b/utils/haddock/hoogle-test/src/Bug722/Bug722.hs
new file mode 100644
index 0000000000000000000000000000000000000000..0a1acbd4f6d945408122976f699ed22f6d58de31
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/Bug722/Bug722.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeOperators, TypeFamilies #-}
+module Bug722 where
+
+import Data.Kind (Type)
+
+class Foo a where
+  (!@#) :: a -> a -> a
+infixl 4 !@#
+
+type family (&*) :: Type -> Type -> Type
+infixr 3 &*
+
+data a :-& b = a :^& b
+infixl 6 :-&, :^&
+
diff --git a/utils/haddock/hoogle-test/src/Bug806/Bug806.hs b/utils/haddock/hoogle-test/src/Bug806/Bug806.hs
new file mode 100644
index 0000000000000000000000000000000000000000..2af59e025857a1a27809fa35585e51ce47c83a98
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/Bug806/Bug806.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE UndecidableInstances #-}
+module Bug806 where
+
+import Data.Kind (Type)
+import Data.Proxy
+
+-- | 'F1' docs
+type family F1 a b :: Type -> Type
+-- | 'F2' docs
+type family F2 a b :: Type -> Type where
+  F2 Int b = Maybe
+  F2 a   b = []
+-- | 'D' docs
+data family D a :: Type -> Type
+
+v :: Int
+v = 42
+
+-- | 'C' docs
+class C a where
+  -- | 'AT' docs
+  type AT a
+  type AT a = Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy)))))))))
diff --git a/utils/haddock/hoogle-test/src/Bug825/Bug825.hs b/utils/haddock/hoogle-test/src/Bug825/Bug825.hs
new file mode 100644
index 0000000000000000000000000000000000000000..48c0930540390d2c0e7de53946d784494fd2825a
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/Bug825/Bug825.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeOperators #-}
+module Bug825 where
+
+data a :~: b
+data (:~~:) a b
diff --git a/utils/haddock/hoogle-test/src/Bug946/Bug946.hs b/utils/haddock/hoogle-test/src/Bug946/Bug946.hs
new file mode 100644
index 0000000000000000000000000000000000000000..ec567d6df10a29692695b2e2bb8c88a7b3056079
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/Bug946/Bug946.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE PatternSynonyms #-}
+module Bug946 (
+  AnInt(AnInt, Zero),
+  pattern TwoPointFive,
+) where
+
+-- | A wrapper around 'Int'
+data AnInt = AnInt Int -- ^ some 'Int'
+
+-- | The 'Int' 0
+pattern Zero :: AnInt
+pattern Zero = AnInt 0
+
+-- | The double 2.5
+pattern TwoPointFive :: Double
+pattern TwoPointFive = 2.5
diff --git a/utils/haddock/hoogle-test/src/Bug992/Bug992.hs b/utils/haddock/hoogle-test/src/Bug992/Bug992.hs
new file mode 100644
index 0000000000000000000000000000000000000000..83454c98c302102819b72dffcc0c176278833340
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/Bug992/Bug992.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE KindSignatures #-}
+
+module Bug992 where
+
+import Data.Kind (Type)
+
+data K (m :: Type -> Type) = K
diff --git a/utils/haddock/hoogle-test/src/assoc-types/AssocTypes.hs b/utils/haddock/hoogle-test/src/assoc-types/AssocTypes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..3fa5f034711ce194d70fc2e2e7e94beacfbd384f
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/assoc-types/AssocTypes.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE AllowAmbiguousTypes #-}
+
+
+module AssocTypes where
+
+
+class Foo a where
+
+    type Bar a b
+    type Baz a
+
+    type Baz a = [(a, a)]
+
+    bar :: Bar a a
+    bar = undefined
+
+
+instance Foo [a] where
+
+    type Bar [a] Int = [(a, Bool)]
+    type Bar [a] Bool = [(Int, a)]
+
+    type Baz [a] = (a, a, a)
diff --git a/utils/haddock/hoogle-test/src/classes/Classes.hs b/utils/haddock/hoogle-test/src/classes/Classes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..2bd726a286cbbd8661a3b788e1cb3fd5af2112a8
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/classes/Classes.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE Haskell2010 #-}
+module Classes where
+
+
+class Foo f where
+
+    bar :: f a -> f b -> f (a, b)
+    baz :: f ()
+
+    baz = undefined
+
+
+class Quux q where
+
+    (+++), (///) :: q -> q -> q
+    (***), logBase :: q -> q -> q
+    foo, quux :: q -> q -> q
diff --git a/utils/haddock/hoogle-test/src/fixity/Fixity.hs b/utils/haddock/hoogle-test/src/fixity/Fixity.hs
new file mode 100644
index 0000000000000000000000000000000000000000..122bd4f8b42e2811ab4866274ab0f30a1388491c
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/fixity/Fixity.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE Haskell2010 #-}
+module Fixity where
+
+
+(+++), (***), (///) :: a -> a -> a
+(+++) = undefined
+(***) = undefined
+(///) = undefined
+
+
+infix 6 +++
+infixl 7 ***
+infixr 8 ///
diff --git a/utils/haddock/hoogle-test/src/modules/Bar.hs b/utils/haddock/hoogle-test/src/modules/Bar.hs
new file mode 100644
index 0000000000000000000000000000000000000000..86e2648be021b0d8debbff244a6f895cc6d57817
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/modules/Bar.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bar where
+
+
+import Foo
+
+
+bar :: Int -> Int
+bar x = foo' x x
+
+
+bar' :: Int -> Int -> Int
+bar' x y = foo' (bar (foo x)) (bar (foo y))
diff --git a/utils/haddock/hoogle-test/src/modules/Foo.hs b/utils/haddock/hoogle-test/src/modules/Foo.hs
new file mode 100644
index 0000000000000000000000000000000000000000..947da4cef0c4759813d2b5ae0c04a209356f64cc
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/modules/Foo.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+module Foo where
+
+
+foo :: Int -> Int
+foo = (* 2)
+
+
+foo' :: Int -> Int -> Int
+foo' x y = foo x + foo y
diff --git a/utils/haddock/hoogle-test/src/type-sigs/ReaderT.hs b/utils/haddock/hoogle-test/src/type-sigs/ReaderT.hs
new file mode 100644
index 0000000000000000000000000000000000000000..fb09bac028bff640e8c1ae19f448ed06d6c568a5
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/type-sigs/ReaderT.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module ReaderT where
+
+newtype ReaderT r m a = ReaderT { runReaderT :: r -> m a }
diff --git a/utils/haddock/hoogle-test/src/type-sigs/ReaderTReexport.hs b/utils/haddock/hoogle-test/src/type-sigs/ReaderTReexport.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b995bba8bb9d6ab058f55954196899c46907f1db
--- /dev/null
+++ b/utils/haddock/hoogle-test/src/type-sigs/ReaderTReexport.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module ReaderTReexport (ReaderT(..), runReaderT) where
+
+import ReaderT
diff --git a/utils/haddock/html-test/Main.hs b/utils/haddock/html-test/Main.hs
new file mode 100755
index 0000000000000000000000000000000000000000..36e56d9a9071327ecfbf0d38d05ee94233c1d85c
--- /dev/null
+++ b/utils/haddock/html-test/Main.hs
@@ -0,0 +1,62 @@
+{-# LANGUAGE CPP #-}
+
+
+import Data.Char
+import Data.Function (on)
+
+import System.Environment
+import System.FilePath
+
+import Test.Haddock
+import Test.Haddock.Xhtml
+
+
+checkConfig :: CheckConfig Xml
+checkConfig = CheckConfig
+    { ccfgRead = parseXml
+    , ccfgClean = stripIfRequired
+    , ccfgDump = dumpXml
+    , ccfgEqual = (==) `on` dumpXml
+    }
+
+
+dirConfig :: DirConfig
+dirConfig = (defaultDirConfig $ takeDirectory __FILE__)
+    { dcfgCheckIgnore = checkIgnore
+    }
+
+
+main :: IO ()
+main = do
+    cfg <- parseArgs checkConfig dirConfig =<< getArgs
+    runAndCheck $ cfg
+        { cfgHaddockArgs = cfgHaddockArgs cfg ++ ["--pretty-html", "--html"]
+        }
+
+
+stripIfRequired :: String -> Xml -> Xml
+stripIfRequired mdl =
+    stripLinks' . stripFooter
+  where
+    stripLinks'
+        | mdl `elem` preserveLinksModules = id
+        | otherwise = stripLinks
+
+
+-- | List of modules in which we don't 'stripLinks'
+preserveLinksModules :: [String]
+preserveLinksModules = ["Bug253.html", "NamespacedIdentifiers.html"]
+
+ingoredTests :: [FilePath]
+ingoredTests =
+  [
+    -- Currently some declarations are exported twice
+    -- we need a reliable way to deduplicate here.
+    -- Happens since PR #688.
+    "B"
+  ]
+
+checkIgnore :: FilePath -> Bool
+checkIgnore file | takeBaseName file `elem` ingoredTests = True
+checkIgnore file@(c:_) | takeExtension file == ".html" && isUpper c = False
+checkIgnore _ = True
diff --git a/utils/haddock/html-test/ref/A.html b/utils/haddock/html-test/ref/A.html
new file mode 100644
index 0000000000000000000000000000000000000000..d3dc54ff3a82dcfe4f2b8156d4e60c134fa1bd10
--- /dev/null
+++ b/utils/haddock/html-test/ref/A.html
@@ -0,0 +1,192 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >A</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>A</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >A</a
+	      > = <a href="#"
+	      >A</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >other</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >test2</a
+	      > :: <a href="#" title="Data.Bool"
+	      >Bool</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >X</a
+	      > = <a href="#"
+	      >X</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >reExport</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:A" class="def"
+	    >A</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:A" class="def"
+		  >A</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:other" class="def"
+	    >other</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:test2" class="def"
+	    >test2</a
+	    > :: <a href="#" title="Data.Bool"
+	    >Bool</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for test2</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:X" class="def"
+	    >X</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Should show up on the page for both modules A and B</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:X" class="def"
+		  >X</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Doc for consructor</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:reExport" class="def"
+	    >reExport</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Should show up on the page for both modules A and B</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/B.html b/utils/haddock/html-test/ref/B.html
new file mode 100644
index 0000000000000000000000000000000000000000..4c1506a3010adc967c64f0a18d9c3acad3307ca4
--- /dev/null
+++ b/utils/haddock/html-test/ref/B.html
@@ -0,0 +1,174 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >B</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Ocean"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      ></span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>B</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    >module <a href="#"
+	      >A</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >test</a
+	      > :: <a href="#"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >reExport</a
+	      > :: <a href="#"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >X</a
+	      > = <a href="#"
+	      >X</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  >module <a href="#"
+	    >A</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:test" class="def"
+	    >test</a
+	    > :: <a href="#"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This link shouldn't work: <code
+	      >other</code
+	      >.
+   These links should work: <code
+	      ><a href="#"
+		>other</a
+		></code
+	      >, <code
+	      ><a href="#"
+		>sortBy</a
+		></code
+	      >, <code
+	      ><a href="#"
+		>test2</a
+		></code
+	      >, <code
+	      ><a href="#"
+		>test2</a
+		></code
+	      >, <code
+	      ><a href="#"
+		>fromMaybe</a
+		></code
+	      >.
+   Module link: <a href="#"
+	      >Prelude</a
+	      >.</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:reExport" class="def"
+	    >reExport</a
+	    > :: <a href="#"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Should show up on the page for both modules A and B</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:X" class="def"
+	    >X</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Should show up on the page for both modules A and B</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:X" class="def"
+		  >X</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Doc for consructor</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ><div id="footer"
+    ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bold.html b/utils/haddock/html-test/ref/Bold.html
new file mode 100644
index 0000000000000000000000000000000000000000..00f9301a5787163220a9ae6ab67223984091905b
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bold.html
@@ -0,0 +1,104 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bold</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bold</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Some <strong
+	      >bold text</strong
+	      >.</p
+	    ><ul
+	    ><li
+	      ><strong
+		>Bold</strong
+		> in a list</li
+	      ></ul
+	    ><dl
+	    ><dt
+	      ><strong
+		>bold in a definition</strong
+		></dt
+	      ><dd
+	      >list</dd
+	      ></dl
+	    ><pre
+	    > bold <strong
+	      >in</strong
+	      > a <strong
+	      >code</strong
+	      > block</pre
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1.html b/utils/haddock/html-test/ref/Bug1.html
new file mode 100644
index 0000000000000000000000000000000000000000..c3e350d8f10740850e1fc066c3790254e77b644b
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1.html
@@ -0,0 +1,107 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >T</a
+	      > = <a href="#"
+	      >T</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:T" class="def"
+	    >T</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >We should have different anchors for constructors and types/classes.  This
+ hyperlink should point to the type constructor by default: <code
+	      ><a href="#" title="Bug1"
+		>T</a
+		></code
+	      >.</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:T" class="def"
+		  >T</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1004.html b/utils/haddock/html-test/ref/Bug1004.html
new file mode 100644
index 0000000000000000000000000000000000000000..5527d8c147a5cb7fe9ae1766938ff0a05b0bf3c1
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1004.html
@@ -0,0 +1,2615 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1004</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1004</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Product</a
+	      > (f :: k -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      >) (g :: k -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      >) (a :: k) = <a href="#"
+	      >Pair</a
+	      > (f a) (g a)</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Product" class="def"
+	    >Product</a
+	    > (f :: k -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) (g :: k -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) (a :: k) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Lifted product of functors.</p
+	    ><h4 class="subheading details-toggle-control details-toggle" data-details-id="ch:Product0"
+	    >Examples</h4
+	    ><details id="ch:Product0"
+	    ><summary class="hide-when-js-enabled"
+	      >Expand</summary
+	      ><pre class="screen"
+	      ><code class="prompt"
+		>&gt;&gt;&gt; </code
+		><strong class="userinput"
+		><code
+		  >fmap (+1) (Pair [1, 2, 3] (Just 0))
+</code
+		  ></strong
+		>Pair [2,3,4] (Just 1)
+</pre
+	      ><pre class="screen"
+	      ><code class="prompt"
+		>&gt;&gt;&gt; </code
+		><strong class="userinput"
+		><code
+		  >Pair &quot;Hello, &quot; (Left 'x') &lt;&gt; Pair &quot;World&quot; (Right 'y')
+</code
+		  ></strong
+		>Pair &quot;Hello, World&quot; (Right 'y')
+</pre
+	      ></details
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Pair" class="def"
+		  >Pair</a
+		  > (f a) (g a)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Product"
+	    >Instances</h4
+	    ><details id="i:Product" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Generic1:1"
+		      ></span
+		      > <a href="#" title="GHC.Generics"
+		      >Generic1</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g :: k -&gt; <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Generic1:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Rep1_Product:Rep1:1"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="GHC.Generics"
+				>Rep1</a
+				> (<a href="#" title="Bug1004"
+				>Product</a
+				> f g :: k -&gt; <a href="#" title="Data.Kind"
+				>Type</a
+				>)</span
+			      ></td
+			    ><td class="doc"
+			    ><p
+			      ><em
+				>Since: base-4.9.0.0</em
+				></p
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:Rep1_Product:Rep1:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Data.Functor.Product</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="GHC.Generics"
+				  >Rep1</a
+				  > (<a href="#" title="Bug1004"
+				  >Product</a
+				  > f g :: k -&gt; <a href="#" title="Data.Kind"
+				  >Type</a
+				  >) = <a href="#" title="GHC.Generics"
+				  >D1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaData</a
+				  > &quot;Product&quot; &quot;Data.Functor.Product&quot; &quot;base&quot; '<a href="#" title="Data.Bool"
+				  >False</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >C1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaCons</a
+				  > &quot;Pair&quot; '<a href="#" title="GHC.Generics"
+				  >PrefixI</a
+				  > '<a href="#" title="Data.Bool"
+				  >False</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >S1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaSel</a
+				  > ('<a href="#" title="Data.Maybe"
+				  >Nothing</a
+				  > :: <a href="#" title="Data.Maybe"
+				  >Maybe</a
+				  > <a href="#" title="GHC.Exts"
+				  >Symbol</a
+				  >) '<a href="#" title="GHC.Generics"
+				  >NoSourceUnpackedness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >NoSourceStrictness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >DecidedLazy</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >Rec1</a
+				  > f) <a href="#" title="GHC.Generics"
+				  >:*:</a
+				  > <a href="#" title="GHC.Generics"
+				  >S1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaSel</a
+				  > ('<a href="#" title="Data.Maybe"
+				  >Nothing</a
+				  > :: <a href="#" title="Data.Maybe"
+				  >Maybe</a
+				  > <a href="#" title="GHC.Exts"
+				  >Symbol</a
+				  >) '<a href="#" title="GHC.Generics"
+				  >NoSourceUnpackedness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >NoSourceStrictness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >DecidedLazy</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >Rec1</a
+				  > g)))</div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >from1</a
+			  > :: <span class="keyword"
+			  >forall</span
+			  > (a :: k). <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="GHC.Generics"
+			  >Rep1</a
+			  > (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g) a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >to1</a
+			  > :: <span class="keyword"
+			  >forall</span
+			  > (a :: k). <a href="#" title="GHC.Generics"
+			  >Rep1</a
+			  > (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g) a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:MonadZip:2"
+		      ></span
+		      > (<a href="#" title="Control.Monad.Zip"
+		      >MonadZip</a
+		      > f, <a href="#" title="Control.Monad.Zip"
+		      >MonadZip</a
+		      > g) =&gt; <a href="#" title="Control.Monad.Zip"
+		      >MonadZip</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:MonadZip:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >mzip</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g (a, b) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >mzipWith</a
+			  > :: (a -&gt; b -&gt; c) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g c <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >munzip</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g (a, b) -&gt; (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a, <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Foldable1:3"
+		      ></span
+		      > (<a href="#" title="Data.Foldable1"
+		      >Foldable1</a
+		      > f, <a href="#" title="Data.Foldable1"
+		      >Foldable1</a
+		      > g) =&gt; <a href="#" title="Data.Foldable1"
+		      >Foldable1</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >It would be enough for either half of a product to be <code
+		      ><a href="#" title="Data.Foldable1"
+			>Foldable1</a
+			></code
+		      >.
+ Other could be <code
+		      ><a href="#" title="Data.Foldable"
+			>Foldable</a
+			></code
+		      >.</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Foldable1:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Foldable1</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >fold1</a
+			  > :: <a href="#" title="Prelude"
+			  >Semigroup</a
+			  > m =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g m -&gt; m <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldMap1</a
+			  > :: <a href="#" title="Prelude"
+			  >Semigroup</a
+			  > m =&gt; (a -&gt; m) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; m <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldMap1'</a
+			  > :: <a href="#" title="Prelude"
+			  >Semigroup</a
+			  > m =&gt; (a -&gt; m) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; m <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >toNonEmpty</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.List.NonEmpty"
+			  >NonEmpty</a
+			  > a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >maximum</a
+			  > :: <a href="#" title="Data.Ord"
+			  >Ord</a
+			  > a =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >minimum</a
+			  > :: <a href="#" title="Data.Ord"
+			  >Ord</a
+			  > a =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >head</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >last</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldrMap1</a
+			  > :: (a -&gt; b) -&gt; (a -&gt; b -&gt; b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldlMap1'</a
+			  > :: (a -&gt; b) -&gt; (b -&gt; a -&gt; b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldlMap1</a
+			  > :: (a -&gt; b) -&gt; (b -&gt; a -&gt; b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldrMap1'</a
+			  > :: (a -&gt; b) -&gt; (a -&gt; b -&gt; b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Eq1:4"
+		      ></span
+		      > (<a href="#" title="Data.Functor.Classes"
+		      >Eq1</a
+		      > f, <a href="#" title="Data.Functor.Classes"
+		      >Eq1</a
+		      > g) =&gt; <a href="#" title="Data.Functor.Classes"
+		      >Eq1</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Eq1:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >liftEq</a
+			  > :: (a -&gt; b -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  >) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Ord1:5"
+		      ></span
+		      > (<a href="#" title="Data.Functor.Classes"
+		      >Ord1</a
+		      > f, <a href="#" title="Data.Functor.Classes"
+		      >Ord1</a
+		      > g) =&gt; <a href="#" title="Data.Functor.Classes"
+		      >Ord1</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Ord1:5"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >liftCompare</a
+			  > :: (a -&gt; b -&gt; <a href="#" title="Data.Ord"
+			  >Ordering</a
+			  >) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Data.Ord"
+			  >Ordering</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Read1:6"
+		      ></span
+		      > (<a href="#" title="Data.Functor.Classes"
+		      >Read1</a
+		      > f, <a href="#" title="Data.Functor.Classes"
+		      >Read1</a
+		      > g) =&gt; <a href="#" title="Data.Functor.Classes"
+		      >Read1</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Read1:6"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >liftReadsPrec</a
+			  > :: (<a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Prelude"
+			  >ReadS</a
+			  > a) -&gt; <a href="#" title="Prelude"
+			  >ReadS</a
+			  > [a] -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Prelude"
+			  >ReadS</a
+			  > (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >liftReadList</a
+			  > :: (<a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Prelude"
+			  >ReadS</a
+			  > a) -&gt; <a href="#" title="Prelude"
+			  >ReadS</a
+			  > [a] -&gt; <a href="#" title="Prelude"
+			  >ReadS</a
+			  > [<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >liftReadPrec</a
+			  > :: <a href="#" title="Text.ParserCombinators.ReadPrec"
+			  >ReadPrec</a
+			  > a -&gt; <a href="#" title="Text.ParserCombinators.ReadPrec"
+			  >ReadPrec</a
+			  > [a] -&gt; <a href="#" title="Text.ParserCombinators.ReadPrec"
+			  >ReadPrec</a
+			  > (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >liftReadListPrec</a
+			  > :: <a href="#" title="Text.ParserCombinators.ReadPrec"
+			  >ReadPrec</a
+			  > a -&gt; <a href="#" title="Text.ParserCombinators.ReadPrec"
+			  >ReadPrec</a
+			  > [a] -&gt; <a href="#" title="Text.ParserCombinators.ReadPrec"
+			  >ReadPrec</a
+			  > [<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Show1:7"
+		      ></span
+		      > (<a href="#" title="Data.Functor.Classes"
+		      >Show1</a
+		      > f, <a href="#" title="Data.Functor.Classes"
+		      >Show1</a
+		      > g) =&gt; <a href="#" title="Data.Functor.Classes"
+		      >Show1</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Show1:7"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >liftShowsPrec</a
+			  > :: (<a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; a -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  >) -&gt; ([a] -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  >) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >liftShowList</a
+			  > :: (<a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; a -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  >) -&gt; ([a] -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  >) -&gt; [<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a] -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Contravariant:8"
+		      ></span
+		      > (<a href="#" title="Data.Functor.Contravariant"
+		      >Contravariant</a
+		      > f, <a href="#" title="Data.Functor.Contravariant"
+		      >Contravariant</a
+		      > g) =&gt; <a href="#" title="Data.Functor.Contravariant"
+		      >Contravariant</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Contravariant:8"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Contravariant</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >contramap</a
+			  > :: (a' -&gt; a) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a' <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&gt;$)</a
+			  > :: b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Alternative:9"
+		      ></span
+		      > (<a href="#" title="Control.Applicative"
+		      >Alternative</a
+		      > f, <a href="#" title="Control.Applicative"
+		      >Alternative</a
+		      > g) =&gt; <a href="#" title="Control.Applicative"
+		      >Alternative</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Alternative:9"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >empty</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;|&gt;)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >some</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g [a] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >many</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g [a] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Applicative:10"
+		      ></span
+		      > (<a href="#" title="Control.Applicative"
+		      >Applicative</a
+		      > f, <a href="#" title="Control.Applicative"
+		      >Applicative</a
+		      > g) =&gt; <a href="#" title="Control.Applicative"
+		      >Applicative</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Applicative:10"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >pure</a
+			  > :: a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;*&gt;)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g (a -&gt; b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >liftA2</a
+			  > :: (a -&gt; b -&gt; c) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g c <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(*&gt;)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;*)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Functor:11"
+		      ></span
+		      > (<a href="#" title="Control.Monad"
+		      >Functor</a
+		      > f, <a href="#" title="Control.Monad"
+		      >Functor</a
+		      > g) =&gt; <a href="#" title="Control.Monad"
+		      >Functor</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Functor:11"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >fmap</a
+			  > :: (a -&gt; b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;$)</a
+			  > :: a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Monad:12"
+		      ></span
+		      > (<a href="#" title="Control.Monad"
+		      >Monad</a
+		      > f, <a href="#" title="Control.Monad"
+		      >Monad</a
+		      > g) =&gt; <a href="#" title="Control.Monad"
+		      >Monad</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Monad:12"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >(&gt;&gt;=)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; (a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&gt;&gt;)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >return</a
+			  > :: a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:MonadPlus:13"
+		      ></span
+		      > (<a href="#" title="Control.Monad"
+		      >MonadPlus</a
+		      > f, <a href="#" title="Control.Monad"
+		      >MonadPlus</a
+		      > g) =&gt; <a href="#" title="Control.Monad"
+		      >MonadPlus</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:MonadPlus:13"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >mzero</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >mplus</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:MonadFix:14"
+		      ></span
+		      > (<a href="#" title="Control.Monad.Fix"
+		      >MonadFix</a
+		      > f, <a href="#" title="Control.Monad.Fix"
+		      >MonadFix</a
+		      > g) =&gt; <a href="#" title="Control.Monad.Fix"
+		      >MonadFix</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:MonadFix:14"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >mfix</a
+			  > :: (a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Foldable:15"
+		      ></span
+		      > (<a href="#" title="Data.Foldable"
+		      >Foldable</a
+		      > f, <a href="#" title="Data.Foldable"
+		      >Foldable</a
+		      > g) =&gt; <a href="#" title="Data.Foldable"
+		      >Foldable</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Foldable:15"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >fold</a
+			  > :: <a href="#" title="Data.Monoid"
+			  >Monoid</a
+			  > m =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g m -&gt; m <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldMap</a
+			  > :: <a href="#" title="Data.Monoid"
+			  >Monoid</a
+			  > m =&gt; (a -&gt; m) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; m <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldMap'</a
+			  > :: <a href="#" title="Data.Monoid"
+			  >Monoid</a
+			  > m =&gt; (a -&gt; m) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; m <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldr</a
+			  > :: (a -&gt; b -&gt; b) -&gt; b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldr'</a
+			  > :: (a -&gt; b -&gt; b) -&gt; b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldl</a
+			  > :: (b -&gt; a -&gt; b) -&gt; b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldl'</a
+			  > :: (b -&gt; a -&gt; b) -&gt; b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldr1</a
+			  > :: (a -&gt; a -&gt; a) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foldl1</a
+			  > :: (a -&gt; a -&gt; a) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >toList</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; [a] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >null</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >length</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >elem</a
+			  > :: <a href="#" title="Data.Eq"
+			  >Eq</a
+			  > a =&gt; a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >maximum</a
+			  > :: <a href="#" title="Data.Ord"
+			  >Ord</a
+			  > a =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >minimum</a
+			  > :: <a href="#" title="Data.Ord"
+			  >Ord</a
+			  > a =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >sum</a
+			  > :: <a href="#" title="Prelude"
+			  >Num</a
+			  > a =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >product</a
+			  > :: <a href="#" title="Prelude"
+			  >Num</a
+			  > a =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Traversable:16"
+		      ></span
+		      > (<a href="#" title="Data.Traversable"
+		      >Traversable</a
+		      > f, <a href="#" title="Data.Traversable"
+		      >Traversable</a
+		      > g) =&gt; <a href="#" title="Data.Traversable"
+		      >Traversable</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Traversable:16"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >traverse</a
+			  > :: <a href="#" title="Control.Applicative"
+			  >Applicative</a
+			  > f0 =&gt; (a -&gt; f0 b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; f0 (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >sequenceA</a
+			  > :: <a href="#" title="Control.Applicative"
+			  >Applicative</a
+			  > f0 =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g (f0 a) -&gt; f0 (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >mapM</a
+			  > :: <a href="#" title="Control.Monad"
+			  >Monad</a
+			  > m =&gt; (a -&gt; m b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; m (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g b) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >sequence</a
+			  > :: <a href="#" title="Control.Monad"
+			  >Monad</a
+			  > m =&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g (m a) -&gt; m (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Monoid:17"
+		      ></span
+		      > (<a href="#" title="Data.Monoid"
+		      >Monoid</a
+		      > (f a), <a href="#" title="Data.Monoid"
+		      >Monoid</a
+		      > (g a)) =&gt; <a href="#" title="Data.Monoid"
+		      >Monoid</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g a)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.16.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Monoid:17"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >mempty</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >mappend</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >mconcat</a
+			  > :: [<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a] -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Semigroup:18"
+		      ></span
+		      > (<a href="#" title="Prelude"
+		      >Semigroup</a
+		      > (f a), <a href="#" title="Prelude"
+		      >Semigroup</a
+		      > (g a)) =&gt; <a href="#" title="Prelude"
+		      >Semigroup</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g a)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.16.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Semigroup:18"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >(&lt;&gt;)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >sconcat</a
+			  > :: <a href="#" title="Data.List.NonEmpty"
+			  >NonEmpty</a
+			  > (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >stimes</a
+			  > :: <a href="#" title="Prelude"
+			  >Integral</a
+			  > b =&gt; b -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Data:19"
+		      ></span
+		      > (<a href="#" title="Data.Dynamic"
+		      >Typeable</a
+		      > a, <a href="#" title="Data.Dynamic"
+		      >Typeable</a
+		      > f, <a href="#" title="Data.Dynamic"
+		      >Typeable</a
+		      > g, <a href="#" title="Data.Dynamic"
+		      >Typeable</a
+		      > k, <a href="#" title="Data.Data"
+		      >Data</a
+		      > (f a), <a href="#" title="Data.Data"
+		      >Data</a
+		      > (g a)) =&gt; <a href="#" title="Data.Data"
+		      >Data</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g a)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Data:19"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >gfoldl</a
+			  > :: (<span class="keyword"
+			  >forall</span
+			  > d b. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; c (d -&gt; b) -&gt; d -&gt; c b) -&gt; (<span class="keyword"
+			  >forall</span
+			  > g0. g0 -&gt; c g0) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; c (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gunfold</a
+			  > :: (<span class="keyword"
+			  >forall</span
+			  > b r. <a href="#" title="Data.Data"
+			  >Data</a
+			  > b =&gt; c (b -&gt; r) -&gt; c r) -&gt; (<span class="keyword"
+			  >forall</span
+			  > r. r -&gt; c r) -&gt; <a href="#" title="Data.Data"
+			  >Constr</a
+			  > -&gt; c (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >toConstr</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Data"
+			  >Constr</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >dataTypeOf</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Data"
+			  >DataType</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >dataCast1</a
+			  > :: <a href="#" title="Data.Dynamic"
+			  >Typeable</a
+			  > t =&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; c (t d)) -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (c (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >dataCast2</a
+			  > :: <a href="#" title="Data.Dynamic"
+			  >Typeable</a
+			  > t =&gt; (<span class="keyword"
+			  >forall</span
+			  > d e. (<a href="#" title="Data.Data"
+			  >Data</a
+			  > d, <a href="#" title="Data.Data"
+			  >Data</a
+			  > e) =&gt; c (t d e)) -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (c (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapT</a
+			  > :: (<span class="keyword"
+			  >forall</span
+			  > b. <a href="#" title="Data.Data"
+			  >Data</a
+			  > b =&gt; b -&gt; b) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapQl</a
+			  > :: (r -&gt; r' -&gt; r) -&gt; r -&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; r') -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; r <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapQr</a
+			  > :: <span class="keyword"
+			  >forall</span
+			  > r r'. (r' -&gt; r -&gt; r) -&gt; r -&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; r') -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; r <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapQ</a
+			  > :: (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; u) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; [u] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapQi</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; u) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; u <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapM</a
+			  > :: <a href="#" title="Control.Monad"
+			  >Monad</a
+			  > m =&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; m d) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; m (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapMp</a
+			  > :: <a href="#" title="Control.Monad"
+			  >MonadPlus</a
+			  > m =&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; m d) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; m (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapMo</a
+			  > :: <a href="#" title="Control.Monad"
+			  >MonadPlus</a
+			  > m =&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; m d) -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; m (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Generic:20"
+		      ></span
+		      > <a href="#" title="GHC.Generics"
+		      >Generic</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g a)</span
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Generic:20"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Rep_Product:Rep:1"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="GHC.Generics"
+				>Rep</a
+				> (<a href="#" title="Bug1004"
+				>Product</a
+				> f g a)</span
+			      ></td
+			    ><td class="doc"
+			    ><p
+			      ><em
+				>Since: base-4.9.0.0</em
+				></p
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:Rep_Product:Rep:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Data.Functor.Product</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="GHC.Generics"
+				  >Rep</a
+				  > (<a href="#" title="Bug1004"
+				  >Product</a
+				  > f g a) = <a href="#" title="GHC.Generics"
+				  >D1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaData</a
+				  > &quot;Product&quot; &quot;Data.Functor.Product&quot; &quot;base&quot; '<a href="#" title="Data.Bool"
+				  >False</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >C1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaCons</a
+				  > &quot;Pair&quot; '<a href="#" title="GHC.Generics"
+				  >PrefixI</a
+				  > '<a href="#" title="Data.Bool"
+				  >False</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >S1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaSel</a
+				  > ('<a href="#" title="Data.Maybe"
+				  >Nothing</a
+				  > :: <a href="#" title="Data.Maybe"
+				  >Maybe</a
+				  > <a href="#" title="GHC.Exts"
+				  >Symbol</a
+				  >) '<a href="#" title="GHC.Generics"
+				  >NoSourceUnpackedness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >NoSourceStrictness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >DecidedLazy</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >Rec0</a
+				  > (f a)) <a href="#" title="GHC.Generics"
+				  >:*:</a
+				  > <a href="#" title="GHC.Generics"
+				  >S1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaSel</a
+				  > ('<a href="#" title="Data.Maybe"
+				  >Nothing</a
+				  > :: <a href="#" title="Data.Maybe"
+				  >Maybe</a
+				  > <a href="#" title="GHC.Exts"
+				  >Symbol</a
+				  >) '<a href="#" title="GHC.Generics"
+				  >NoSourceUnpackedness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >NoSourceStrictness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >DecidedLazy</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >Rec0</a
+				  > (g a))))</div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >from</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="GHC.Generics"
+			  >Rep</a
+			  > (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) x <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >to</a
+			  > :: <a href="#" title="GHC.Generics"
+			  >Rep</a
+			  > (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) x -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Read:21"
+		      ></span
+		      > (<a href="#" title="Prelude"
+		      >Read</a
+		      > (f a), <a href="#" title="Prelude"
+		      >Read</a
+		      > (g a)) =&gt; <a href="#" title="Prelude"
+		      >Read</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g a)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.18.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Read:21"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >readsPrec</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Prelude"
+			  >ReadS</a
+			  > (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >readList</a
+			  > :: <a href="#" title="Prelude"
+			  >ReadS</a
+			  > [<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >readPrec</a
+			  > :: <a href="#" title="Text.ParserCombinators.ReadPrec"
+			  >ReadPrec</a
+			  > (<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >readListPrec</a
+			  > :: <a href="#" title="Text.ParserCombinators.ReadPrec"
+			  >ReadPrec</a
+			  > [<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Show:22"
+		      ></span
+		      > (<a href="#" title="Prelude"
+		      >Show</a
+		      > (f a), <a href="#" title="Prelude"
+		      >Show</a
+		      > (g a)) =&gt; <a href="#" title="Prelude"
+		      >Show</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g a)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.18.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Show:22"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >showsPrec</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >show</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.String"
+			  >String</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >showList</a
+			  > :: [<a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a] -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Eq:23"
+		      ></span
+		      > (<a href="#" title="Data.Eq"
+		      >Eq</a
+		      > (f a), <a href="#" title="Data.Eq"
+		      >Eq</a
+		      > (g a)) =&gt; <a href="#" title="Data.Eq"
+		      >Eq</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g a)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.18.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Eq:23"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >(==)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(/=)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Ord:24"
+		      ></span
+		      > (<a href="#" title="Data.Ord"
+		      >Ord</a
+		      > (f a), <a href="#" title="Data.Ord"
+		      >Ord</a
+		      > (g a)) =&gt; <a href="#" title="Data.Ord"
+		      >Ord</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g a)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.18.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Ord:24"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >compare</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Ord"
+			  >Ordering</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;=)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&gt;)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&gt;=)</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >max</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >min</a
+			  > :: <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a -&gt; <a href="#" title="Bug1004"
+			  >Product</a
+			  > f g a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Rep1:25"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="GHC.Generics"
+		      >Rep1</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g :: k -&gt; <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Rep1:25"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="GHC.Generics"
+			>Rep1</a
+			> (<a href="#" title="Bug1004"
+			>Product</a
+			> f g :: k -&gt; <a href="#" title="Data.Kind"
+			>Type</a
+			>) = <a href="#" title="GHC.Generics"
+			>D1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaData</a
+			> &quot;Product&quot; &quot;Data.Functor.Product&quot; &quot;base&quot; '<a href="#" title="Data.Bool"
+			>False</a
+			>) (<a href="#" title="GHC.Generics"
+			>C1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaCons</a
+			> &quot;Pair&quot; '<a href="#" title="GHC.Generics"
+			>PrefixI</a
+			> '<a href="#" title="Data.Bool"
+			>False</a
+			>) (<a href="#" title="GHC.Generics"
+			>S1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaSel</a
+			> ('<a href="#" title="Data.Maybe"
+			>Nothing</a
+			> :: <a href="#" title="Data.Maybe"
+			>Maybe</a
+			> <a href="#" title="GHC.Exts"
+			>Symbol</a
+			>) '<a href="#" title="GHC.Generics"
+			>NoSourceUnpackedness</a
+			> '<a href="#" title="GHC.Generics"
+			>NoSourceStrictness</a
+			> '<a href="#" title="GHC.Generics"
+			>DecidedLazy</a
+			>) (<a href="#" title="GHC.Generics"
+			>Rec1</a
+			> f) <a href="#" title="GHC.Generics"
+			>:*:</a
+			> <a href="#" title="GHC.Generics"
+			>S1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaSel</a
+			> ('<a href="#" title="Data.Maybe"
+			>Nothing</a
+			> :: <a href="#" title="Data.Maybe"
+			>Maybe</a
+			> <a href="#" title="GHC.Exts"
+			>Symbol</a
+			>) '<a href="#" title="GHC.Generics"
+			>NoSourceUnpackedness</a
+			> '<a href="#" title="GHC.Generics"
+			>NoSourceStrictness</a
+			> '<a href="#" title="GHC.Generics"
+			>DecidedLazy</a
+			>) (<a href="#" title="GHC.Generics"
+			>Rec1</a
+			> g)))</div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Rep:26"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="GHC.Generics"
+		      >Rep</a
+		      > (<a href="#" title="Bug1004"
+		      >Product</a
+		      > f g a)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.9.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Product:Rep:26"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Data.Functor.Product</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="GHC.Generics"
+			>Rep</a
+			> (<a href="#" title="Bug1004"
+			>Product</a
+			> f g a) = <a href="#" title="GHC.Generics"
+			>D1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaData</a
+			> &quot;Product&quot; &quot;Data.Functor.Product&quot; &quot;base&quot; '<a href="#" title="Data.Bool"
+			>False</a
+			>) (<a href="#" title="GHC.Generics"
+			>C1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaCons</a
+			> &quot;Pair&quot; '<a href="#" title="GHC.Generics"
+			>PrefixI</a
+			> '<a href="#" title="Data.Bool"
+			>False</a
+			>) (<a href="#" title="GHC.Generics"
+			>S1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaSel</a
+			> ('<a href="#" title="Data.Maybe"
+			>Nothing</a
+			> :: <a href="#" title="Data.Maybe"
+			>Maybe</a
+			> <a href="#" title="GHC.Exts"
+			>Symbol</a
+			>) '<a href="#" title="GHC.Generics"
+			>NoSourceUnpackedness</a
+			> '<a href="#" title="GHC.Generics"
+			>NoSourceStrictness</a
+			> '<a href="#" title="GHC.Generics"
+			>DecidedLazy</a
+			>) (<a href="#" title="GHC.Generics"
+			>Rec0</a
+			> (f a)) <a href="#" title="GHC.Generics"
+			>:*:</a
+			> <a href="#" title="GHC.Generics"
+			>S1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaSel</a
+			> ('<a href="#" title="Data.Maybe"
+			>Nothing</a
+			> :: <a href="#" title="Data.Maybe"
+			>Maybe</a
+			> <a href="#" title="GHC.Exts"
+			>Symbol</a
+			>) '<a href="#" title="GHC.Generics"
+			>NoSourceUnpackedness</a
+			> '<a href="#" title="GHC.Generics"
+			>NoSourceStrictness</a
+			> '<a href="#" title="GHC.Generics"
+			>DecidedLazy</a
+			>) (<a href="#" title="GHC.Generics"
+			>Rec0</a
+			> (g a))))</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1033.html b/utils/haddock/html-test/ref/Bug1033.html
new file mode 100644
index 0000000000000000000000000000000000000000..ee63caae987aa1e83875ec590e02dc117cb17e31
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1033.html
@@ -0,0 +1,272 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1033</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1033</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Foo" class="def"
+		  >Foo</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo"
+	    >Instances</h4
+	    ><details id="i:Foo" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Foo:Generic:1"
+		      ></span
+		      > <a href="#" title="GHC.Generics"
+		      >Generic</a
+		      > <a href="#" title="Bug1033"
+		      >Foo</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Foo:Generic:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1033</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Rep_Foo:Rep:1"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="GHC.Generics"
+				>Rep</a
+				> <a href="#" title="Bug1033"
+				>Foo</a
+				></span
+			      ></td
+			    ><td class="doc"
+			    ><p
+			      >This does some generic foos.</p
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:Rep_Foo:Rep:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Bug1033</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="GHC.Generics"
+				  >Rep</a
+				  > <a href="#" title="Bug1033"
+				  >Foo</a
+				  > = <a href="#" title="GHC.Generics"
+				  >D1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaData</a
+				  > &quot;Foo&quot; &quot;Bug1033&quot; &quot;main&quot; '<a href="#" title="Data.Bool"
+				  >False</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >C1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaCons</a
+				  > &quot;Foo&quot; '<a href="#" title="GHC.Generics"
+				  >PrefixI</a
+				  > '<a href="#" title="Data.Bool"
+				  >False</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >U1</a
+				  > :: <a href="#" title="Data.Kind"
+				  >Type</a
+				  > -&gt; <a href="#" title="Data.Kind"
+				  >Type</a
+				  >))</div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >from</a
+			  > :: <a href="#" title="Bug1033"
+			  >Foo</a
+			  > -&gt; <a href="#" title="GHC.Generics"
+			  >Rep</a
+			  > <a href="#" title="Bug1033"
+			  >Foo</a
+			  > x <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >to</a
+			  > :: <a href="#" title="GHC.Generics"
+			  >Rep</a
+			  > <a href="#" title="Bug1033"
+			  >Foo</a
+			  > x -&gt; <a href="#" title="Bug1033"
+			  >Foo</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Foo:Rep:2"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="GHC.Generics"
+		      >Rep</a
+		      > <a href="#" title="Bug1033"
+		      >Foo</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >This does some generic foos.</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Foo:Rep:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1033</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="GHC.Generics"
+			>Rep</a
+			> <a href="#" title="Bug1033"
+			>Foo</a
+			> = <a href="#" title="GHC.Generics"
+			>D1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaData</a
+			> &quot;Foo&quot; &quot;Bug1033&quot; &quot;main&quot; '<a href="#" title="Data.Bool"
+			>False</a
+			>) (<a href="#" title="GHC.Generics"
+			>C1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaCons</a
+			> &quot;Foo&quot; '<a href="#" title="GHC.Generics"
+			>PrefixI</a
+			> '<a href="#" title="Data.Bool"
+			>False</a
+			>) (<a href="#" title="GHC.Generics"
+			>U1</a
+			> :: <a href="#" title="Data.Kind"
+			>Type</a
+			> -&gt; <a href="#" title="Data.Kind"
+			>Type</a
+			>))</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1035.html b/utils/haddock/html-test/ref/Bug1035.html
new file mode 100644
index 0000000000000000000000000000000000000000..891e230d2cc683e668d0cee52daf17d5d1e7c528
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1035.html
@@ -0,0 +1,150 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1035</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1035</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Foo</a
+	      > = <a href="#"
+	      >Bar</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Bar</a
+	      > = <a href="#"
+	      >Foo</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Bar" class="def"
+		  >Bar</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Bar" class="def"
+	    >Bar</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Foo" class="def"
+		  >Foo</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A link to <code
+	      ><a href="#" title="Bug1035"
+		>Bar</a
+		></code
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1050.html b/utils/haddock/html-test/ref/Bug1050.html
new file mode 100644
index 0000000000000000000000000000000000000000..71ec19191702ee053b19acfd644fe6db918a3d75
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1050.html
@@ -0,0 +1,112 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1050</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1050</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:T" class="def"
+	    >T</a
+	    > (a :: <span class="keyword"
+	    >forall</span
+	    > k. k -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) (b :: k) <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:MkT" class="def"
+		  >MkT</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > (a :: <span class="keyword"
+		  >forall</span
+		  > k. k -&gt; <a href="#" title="Data.Kind"
+		  >Type</a
+		  >) k (b :: k). a b -&gt; <a href="#" title="Bug1050"
+		  >T</a
+		  > a b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:mkT" class="def"
+	    >mkT</a
+	    > :: <span class="keyword"
+	    >forall</span
+	    > {k} {f :: <span class="keyword"
+	    >forall</span
+	    > k1. k1 -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >} {a :: k}. f a -&gt; <a href="#" title="Bug1050"
+	    >T</a
+	    > f a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1054.html b/utils/haddock/html-test/ref/Bug1054.html
new file mode 100644
index 0000000000000000000000000000000000000000..8d31c62e0f9cba8d28b515ff11eb32b7a6d2b95a
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1054.html
@@ -0,0 +1,96 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1054</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1054</p
+	></div
+      ><div id="table-of-contents"
+      ><div id="contents-list"
+	><p class="caption" onclick="window.scrollTo(0,0)"
+	  >Contents</p
+	  ><ul
+	  ><li
+	    ><a href="#"
+	      >Header with <code
+		>foo</code
+		> link</a
+	      ></li
+	    ></ul
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><a href="#" id="g:1"
+	><h1
+	  >Header with <code
+	    >foo</code
+	    > link</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1063.html b/utils/haddock/html-test/ref/Bug1063.html
new file mode 100644
index 0000000000000000000000000000000000000000..7f2b46cf368aaeba0cf29e5f0358c3d07e84c327
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1063.html
@@ -0,0 +1,104 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1063</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1063</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > (c =&gt; d) =&gt; <a id="t:Implies" class="def"
+	    >Implies</a
+	    > c d <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Implies"
+	    >Instances</h4
+	    ><details id="i:Implies" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Implies:Implies:1"
+		      ></span
+		      > (c =&gt; d) =&gt; <a href="#" title="Bug1063"
+		      >Implies</a
+		      > c d</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Implies:Implies:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1063</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1067A.html b/utils/haddock/html-test/ref/Bug1067A.html
new file mode 100644
index 0000000000000000000000000000000000000000..0ccff963730220930c81325bca525a3669b56c85
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1067A.html
@@ -0,0 +1,120 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1067A</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1067A</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Foo</a
+	      > <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >P</a
+		  > :: <a href="#" title="Bug1067A"
+		  >Foo</a
+		  ></li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A foo</p
+	    ></div
+	  ><div class="subs bundled-patterns"
+	  ><p class="caption"
+	    >Bundled Patterns</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v:P" class="def"
+		  >P</a
+		  > :: <a href="#" title="Bug1067A"
+		  >Foo</a
+		  ></td
+		><td class="doc"
+		><p
+		  >A pattern</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1067B.html b/utils/haddock/html-test/ref/Bug1067B.html
new file mode 100644
index 0000000000000000000000000000000000000000..ab48c202418350fc20dbd1c7a2ddac38a33fa96a
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1067B.html
@@ -0,0 +1,90 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1067B</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1067B</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >P</a
+	      > :: <a href="#" title="Bug1067A"
+	      >Foo</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:P" class="def"
+	    >P</a
+	    > :: <a href="#" title="Bug1067A"
+	    >Foo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A pattern</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug1103.html b/utils/haddock/html-test/ref/Bug1103.html
new file mode 100644
index 0000000000000000000000000000000000000000..60af9b86e5ac93b45933bc82d839fd047fb6e6bf
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug1103.html
@@ -0,0 +1,560 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug1103</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug1103</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:Foo1" class="def"
+	    >Foo1</a
+	    > :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo1"
+	    >Instances</h4
+	    ><details id="i:Foo1" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo1:Foo1:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo1</a
+		      > <a href="#" title="Data.Bool"
+		      >Bool</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo1:Foo1:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo1</a
+			> <a href="#" title="Data.Bool"
+			>Bool</a
+			> = <a id="v:Foo1Bool" class="def"
+			>Foo1Bool</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo1:Foo1:2"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo1</a
+		      > (<a href="#" title="Data.Maybe"
+		      >Maybe</a
+		      > a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo1:Foo1:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo1</a
+			> (<a href="#" title="Data.Maybe"
+			>Maybe</a
+			> a)</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:Foo2" class="def"
+	    >Foo2</a
+	    > :: k -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo2"
+	    >Instances</h4
+	    ><details id="i:Foo2" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo2:Foo2:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo2</a
+		      > (a :: <a href="#" title="Data.Char"
+		      >Char</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo2:Foo2:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo2</a
+			> (a :: <a href="#" title="Data.Char"
+			>Char</a
+			>)</div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo2:Foo2:2"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo2</a
+		      > <a href="#" title="Data.Bool"
+		      >Bool</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo2:Foo2:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo2</a
+			> <a href="#" title="Data.Bool"
+			>Bool</a
+			> = <a id="v:Foo2Bool" class="def"
+			>Foo2Bool</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo2:Foo2:3"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo2</a
+		      > (<a href="#" title="Data.Maybe"
+		      >Maybe</a
+		      > a :: <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo2:Foo2:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo2</a
+			> (<a href="#" title="Data.Maybe"
+			>Maybe</a
+			> a :: <a href="#" title="Data.Kind"
+			>Type</a
+			>)</div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo2:Foo2:4"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo2</a
+		      > (a :: <a href="#" title="Data.Char"
+		      >Char</a
+		      > -&gt; <a href="#" title="Data.Char"
+		      >Char</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo2:Foo2:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo2</a
+			> (a :: <a href="#" title="Data.Char"
+			>Char</a
+			> -&gt; <a href="#" title="Data.Char"
+			>Char</a
+			>)</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:Foo3" class="def"
+	    >Foo3</a
+	    > :: k <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo3"
+	    >Instances</h4
+	    ><details id="i:Foo3" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo3:Foo3:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo3</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo3:Foo3:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo3</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo3:Foo3:2"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo3</a
+		      > (a :: <a href="#" title="Data.Char"
+		      >Char</a
+		      > -&gt; <a href="#" title="Data.Char"
+		      >Char</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo3:Foo3:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo3</a
+			> (a :: <a href="#" title="Data.Char"
+			>Char</a
+			> -&gt; <a href="#" title="Data.Char"
+			>Char</a
+			>)</div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo3:Foo3:3"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo3</a
+		      > (a :: <a href="#" title="Data.Char"
+		      >Char</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo3:Foo3:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo3</a
+			> (a :: <a href="#" title="Data.Char"
+			>Char</a
+			>)</div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo3:Foo3:4"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo3</a
+		      > <a href="#" title="Data.Bool"
+		      >Bool</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo3:Foo3:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo3</a
+			> <a href="#" title="Data.Bool"
+			>Bool</a
+			> = <a id="v:Foo3Bool" class="def"
+			>Foo3Bool</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo3:Foo3:5"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug1103"
+		      >Foo3</a
+		      > (<a href="#" title="Data.Maybe"
+		      >Maybe</a
+		      > a :: <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo3:Foo3:5"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug1103</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug1103"
+			>Foo3</a
+			> (<a href="#" title="Data.Maybe"
+			>Maybe</a
+			> a :: <a href="#" title="Data.Kind"
+			>Type</a
+			>)</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug195.html b/utils/haddock/html-test/ref/Bug195.html
new file mode 100644
index 0000000000000000000000000000000000000000..3428b31dce3cc6da6ebc0584312c723d21241811
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug195.html
@@ -0,0 +1,188 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug195</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug195</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:T" class="def"
+	    >T</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:A" class="def"
+		  >A</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:someField" class="def"
+			  >someField</a
+			  > :: ()</dfn
+			><div class="doc"
+			><p
+			  >Doc for someField of A</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:someOtherField" class="def"
+			  >someOtherField</a
+			  > :: ()</dfn
+			><div class="doc"
+			><p
+			  >Doc for someOtherField of A</p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:B" class="def"
+		  >B</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:someField" class="def"
+			  >someField</a
+			  > :: ()</dfn
+			><div class="doc"
+			><p
+			  >Doc for someField of A</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:someOtherField" class="def"
+			  >someOtherField</a
+			  > :: ()</dfn
+			><div class="doc"
+			><p
+			  >Doc for someOtherField of A</p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:C" class="def"
+		  >C</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:someField" class="def"
+			  >someField</a
+			  > :: ()</dfn
+			><div class="doc"
+			><p
+			  >Doc for someField of A</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:someOtherField" class="def"
+			  >someOtherField</a
+			  > :: ()</dfn
+			><div class="doc"
+			><p
+			  >Doc for someOtherField of A</p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug2.html b/utils/haddock/html-test/ref/Bug2.html
new file mode 100644
index 0000000000000000000000000000000000000000..f8da696da01ae8cac18f39f177e9183ae599e8bb
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug2.html
@@ -0,0 +1,68 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug2</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug2</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:x" class="def"
+	    >x</a
+	    > :: <a href="#" title="A"
+	    >A</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug201.html b/utils/haddock/html-test/ref/Bug201.html
new file mode 100644
index 0000000000000000000000000000000000000000..0f2b3878cde0d95512b4435bc9cdf9dfd45db6bd
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug201.html
@@ -0,0 +1,109 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug201</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug201</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: ()</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >g</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><pre
+	    >This leading whitespace
+should be dropped
+</pre
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:g" class="def"
+	    >g</a
+	    > :: () <a href="#" class="selflink"
+	    >#</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
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug253.html b/utils/haddock/html-test/ref/Bug253.html
new file mode 100644
index 0000000000000000000000000000000000000000..60d5ef66166970ff7c1029db301bb0035669db19
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug253.html
@@ -0,0 +1,104 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug253</title
+    ><link href="linuwial.css" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="quick-jump.css"
+     /><link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans:400,400i,700"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="index.html"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="doc-index.html"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug253</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >This module tests that if we're trying to link to a <em
+	    >qualified</em
+	    >
+ identifier that's not in scope, we get an anchor as if it was a
+ variable. Previous behaviour was to treat it as a type constructor
+ so issue like #253 arose. Also see <code
+	    >rename</code
+	    > function comments in
+ source.</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#v:foo"
+	      >foo</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: () <a href="#v:foo" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This link should generate <code
+	      >#v</code
+	      > anchor: <code
+	      ><a href="DoesNotExist.html#v:fakeFakeFake" title="DoesNotExist"
+		>fakeFakeFake</a
+		></code
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug26.html b/utils/haddock/html-test/ref/Bug26.html
new file mode 100644
index 0000000000000000000000000000000000000000..73b33e89a3bdf7e4a0a4332df0de111db55889dc
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug26.html
@@ -0,0 +1,216 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug26</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug26</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >This module tests the &#8216;@since &#8230;&#8217; annotation.</p
+	  ><p
+	  ><em
+	    >Since: 1.2.3</em
+	    ></p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: ()</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >g</a
+	      > :: ()</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >C</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >c_f</a
+		  > :: a</li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Foo</p
+	    ><p
+	    ><em
+	      >Since: 2.10.8</em
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:g" class="def"
+	    >g</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Bar</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:C" class="def"
+	    >C</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Class</p
+	    ><p
+	    ><em
+	      >Since: 1.0</em
+	      ></p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:c_f" class="def"
+	      >c_f</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      ><em
+		>Since: 1.2.3</em
+		></p
+	      ></div
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:C"
+	    >Instances</h4
+	    ><details id="i:C" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:C:C:1"
+		      ></span
+		      > <a href="#" title="Bug26"
+		      >C</a
+		      > ()</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >instance for ()</p
+		    ><p
+		    ><em
+		      >Since: 0.7.8</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:C:C:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug26</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >c_f</a
+			  > :: () <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug280.html b/utils/haddock/html-test/ref/Bug280.html
new file mode 100644
index 0000000000000000000000000000000000000000..e821b091b066a4e71b63d0f6a8bfa00f2b830429
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug280.html
@@ -0,0 +1,84 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug280</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th valign="top"
+	    >Copyright</th
+	    ><td
+	    >Foo<br
+	       />Bar<br
+	       />Baz</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug280</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >The module description</p
+	  ></div
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:x" class="def"
+	    >x</a
+	    > :: <a href="#" title="Data.String"
+	    >String</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug294.html b/utils/haddock/html-test/ref/Bug294.html
new file mode 100644
index 0000000000000000000000000000000000000000..ff27890727ddb3702444556e0c44031ec22d668f
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug294.html
@@ -0,0 +1,378 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug294</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</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 id="t:A" class="def"
+	    >A</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:A"
+	    >Instances</h4
+	    ><details id="i:A" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:A:DP:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug294"
+		      >DP</a
+		      > <a href="#" title="Bug294"
+		      >A</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:A:DP:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug294</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug294"
+			>DP</a
+			> <a href="#" title="Bug294"
+			>A</a
+			> = <a id="v:ProblemCtor-39-" class="def"
+			>ProblemCtor'</a
+			> <a href="#" title="Bug294"
+			>A</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:A:TP:2"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug294"
+		      >TP</a
+		      > <a href="#" title="Bug294"
+		      >A</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:A:TP:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug294</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug294"
+			>TP</a
+			> <a href="#" title="Bug294"
+			>A</a
+			> = <a id="v:ProblemCtor" class="def"
+			>ProblemCtor</a
+			> <a href="#" title="Bug294"
+			>A</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:problemField" class="def"
+	    >problemField</a
+	    > :: TO <a href="#" title="Bug294"
+	    >A</a
+	    > -&gt; <a href="#" title="Bug294"
+	    >A</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:problemField-39-" class="def"
+	    >problemField'</a
+	    > :: DO <a href="#" title="Bug294"
+	    >A</a
+	    > -&gt; <a href="#" title="Bug294"
+	    >A</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:gadtField" class="def"
+	    >gadtField</a
+	    > :: GADT <a href="#" title="Bug294"
+	    >A</a
+	    > -&gt; <a href="#" title="Bug294"
+	    >A</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:TP" class="def"
+	    >TP</a
+	    > t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:TP"
+	    >Instances</h4
+	    ><details id="i:TP" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:TP:TP:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug294"
+		      >TP</a
+		      > <a href="#" title="Bug294"
+		      >A</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:TP:TP:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug294</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug294"
+			>TP</a
+			> <a href="#" title="Bug294"
+			>A</a
+			> = <a id="v:ProblemCtor" class="def"
+			>ProblemCtor</a
+			> <a href="#" title="Bug294"
+			>A</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:DP" class="def"
+	    >DP</a
+	    > t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:DP"
+	    >Instances</h4
+	    ><details id="i:DP" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:DP:DP:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug294"
+		      >DP</a
+		      > <a href="#" title="Bug294"
+		      >A</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:DP:DP:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug294</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug294"
+			>DP</a
+			> <a href="#" title="Bug294"
+			>A</a
+			> = <a id="v:ProblemCtor-39-" class="def"
+			>ProblemCtor'</a
+			> <a href="#" title="Bug294"
+			>A</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:TO-39-" class="def"
+	    >TO'</a
+	    > t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:TO-39-"
+	    >Instances</h4
+	    ><details id="i:TO-39-" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:TO-39-:TO-39-:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Bug294"
+		      >TO'</a
+		      > a</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:TO-39-:TO-39-:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug294</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Bug294"
+			>TO'</a
+			> a = <a id="v:PolyCtor" class="def"
+			>PolyCtor</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug298.html b/utils/haddock/html-test/ref/Bug298.html
new file mode 100644
index 0000000000000000000000000000000000000000..8983195b739e26527070159a15eb513ec5f8f890
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug298.html
@@ -0,0 +1,146 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug298</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug298</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >(&lt;^&gt;)</a
+	      > :: (a -&gt; a) -&gt; a -&gt; a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >(&lt;^)</a
+	      > :: a -&gt; a -&gt; a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >(^&gt;)</a
+	      > :: a -&gt; a -&gt; a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >(&#8902;^)</a
+	      > :: a -&gt; a -&gt; a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-60--94--62-" class="def"
+	    >(&lt;^&gt;)</a
+	    > :: (a -&gt; a) -&gt; a -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-60--94-" class="def"
+	    >(&lt;^)</a
+	    > :: a -&gt; a -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-94--62-" class="def"
+	    >(^&gt;)</a
+	    > :: a -&gt; a -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-8902--94-" class="def"
+	    >(&#8902;^)</a
+	    > :: a -&gt; a -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Links to <code
+	      ><a href="#" title="Bug298"
+		>&lt;^&gt;</a
+		></code
+	      > and <code
+	      ><a href="#" title="Bug298"
+		>^&gt;</a
+		></code
+	      >, <code
+	      ><a href="#" title="Bug298"
+		>&lt;^</a
+		></code
+	      > and <code
+	      ><a href="#" title="Bug298"
+		>&#8902;^</a
+		></code
+	      >.</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug3.html b/utils/haddock/html-test/ref/Bug3.html
new file mode 100644
index 0000000000000000000000000000000000000000..da390bc7966c5b1e97f27197d00f4cc6495c459e
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug3.html
@@ -0,0 +1,87 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug3</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug3</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >/multi-line
+ emphasis/</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug308.html b/utils/haddock/html-test/ref/Bug308.html
new file mode 100644
index 0000000000000000000000000000000000000000..66fedba859a850af39319c24c313e05e67e95359
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug308.html
@@ -0,0 +1,118 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug308</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug308</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: ()</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >g</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >start<a id="startAnchor"
+	      ></a
+	      > followed by middle<a id="middleAnchor"
+	      ></a
+	      > and end<a id="endAnchor"
+	      ></a
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:g" class="def"
+	    >g</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >start <a href="#"
+	      >Bug308</a
+	      ></p
+	    ><p
+	    >startOldStyle <a href="#"
+	      >Bug308</a
+	      ></p
+	    ><p
+	    >middle <a href="#"
+	      >Bug308</a
+	      ></p
+	    ><p
+	    >end <a href="#"
+	      >Bug308</a
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug308CrossModule.html b/utils/haddock/html-test/ref/Bug308CrossModule.html
new file mode 100644
index 0000000000000000000000000000000000000000..1b9a280988caefab92ca1d0da1da5b51445cc8be
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug308CrossModule.html
@@ -0,0 +1,96 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug308CrossModule</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug308CrossModule</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >h</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:h" class="def"
+	    >h</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >start <a href="#"
+	      >Bug308</a
+	      ></p
+	    ><p
+	    >startOldStyle <a href="#"
+	      >Bug308</a
+	      ></p
+	    ><p
+	    >middle <a href="#"
+	      >Bug308</a
+	      ></p
+	    ><p
+	    >end <a href="#"
+	      >Bug308</a
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug310.html b/utils/haddock/html-test/ref/Bug310.html
new file mode 100644
index 0000000000000000000000000000000000000000..8e5205af23a74936ae64743d18a1841f300719c0
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug310.html
@@ -0,0 +1,76 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug310</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug310</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type family</span
+	    > (a :: <a href="#" title="GHC.TypeLits"
+	    >Natural</a
+	    >) <a id="t:-43-" class="def"
+	    >+</a
+	    > (b :: <a href="#" title="GHC.TypeLits"
+	    >Natural</a
+	    >) :: <a href="#" title="GHC.TypeLits"
+	    >Natural</a
+	    > <span class="keyword"
+	    >where ...</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug313.html b/utils/haddock/html-test/ref/Bug313.html
new file mode 100644
index 0000000000000000000000000000000000000000..44a970b781c841f4d53eb518d8f0c6c289adf13b
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug313.html
@@ -0,0 +1,139 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug313</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug313</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >The first list is incorrectly numbered as 1. 2. 1.; the second example
+ renders fine (1. 2. 3.).</p
+	  ><p
+	  >See <a href="#"
+	    >https://github.com/haskell/haddock/issues/313</a
+	    ></p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >a</a
+	      > :: a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >b</a
+	      > :: a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:a" class="def"
+	    >a</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Some text.</p
+	    ><ol
+	    ><li value="1"
+	      >Item 1</li
+	      ><li value="2"
+	      ><p
+		>Item 2</p
+		><pre
+		>Some code</pre
+		></li
+	      ><li value="3"
+	      >Item 3</li
+	      ></ol
+	    ><p
+	    >Some more text.</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:b" class="def"
+	    >b</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Some text.</p
+	    ><ol
+	    ><li value="1"
+	      >Item 1</li
+	      ><li value="2"
+	      ><p
+		>Item 2</p
+		><pre
+		>Some code</pre
+		></li
+	      ><li value="3"
+	      >Item 3</li
+	      ></ol
+	    ><p
+	    >Some more text.</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug335.html b/utils/haddock/html-test/ref/Bug335.html
new file mode 100644
index 0000000000000000000000000000000000000000..a5049088d46eee78df908ef86d84a7c2523014a1
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug335.html
@@ -0,0 +1,136 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug335</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug335</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: ()</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >g</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><h3 class="subheading details-toggle-control details-toggle" data-details-id="ch:f0"
+	    >ExF:</h3
+	    ><details id="ch:f0"
+	    ><summary class="hide-when-js-enabled"
+	      >Expand</summary
+	      ><p
+	      >abc</p
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:g" class="def"
+	    >g</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><h3 class="subheading details-toggle-control details-toggle" data-details-id="ch:g0"
+	    >ExG:</h3
+	    ><details id="ch:g0"
+	    ><summary class="hide-when-js-enabled"
+	      >Expand</summary
+	      ><pre class="screen"
+	      ><code class="prompt"
+		>&gt;&gt;&gt; </code
+		><strong class="userinput"
+		><code
+		  >a
+</code
+		  ></strong
+		>b
+</pre
+	      ><pre class="screen"
+	      ><code class="prompt"
+		>&gt;&gt;&gt; </code
+		><strong class="userinput"
+		><code
+		  >c
+</code
+		  ></strong
+		>d
+</pre
+	      ><h4
+	      >Under ex</h4
+	      ><p
+	      >foo</p
+	      ></details
+	    ><h2
+	    >Out of Ex</h2
+	    ><p
+	    >foo</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug4.html b/utils/haddock/html-test/ref/Bug4.html
new file mode 100644
index 0000000000000000000000000000000000000000..a8861c4ef93969685f6f88d68acb8aa3d312718f
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug4.html
@@ -0,0 +1,86 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug4</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug4</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >don't use apostrophe's in the wrong place's</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug458.html b/utils/haddock/html-test/ref/Bug458.html
new file mode 100644
index 0000000000000000000000000000000000000000..ad07b3faa4a73086c1b0287c40ed18fc7ed86250
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug458.html
@@ -0,0 +1,88 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug458</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug458</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >(&#8838;)</a
+	      > :: () -&gt; () -&gt; ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-8838-" class="def"
+	    >(&#8838;)</a
+	    > :: () -&gt; () -&gt; () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >See the defn of <code
+	      ><code
+		><a href="#" title="Bug458"
+		  >&#8838;</a
+		  ></code
+		></code
+	      >.</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug466.html b/utils/haddock/html-test/ref/Bug466.html
new file mode 100644
index 0000000000000000000000000000000000000000..40fa85e277d3d7bbec627b1401d918a67cc52fff
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug466.html
@@ -0,0 +1,310 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug466</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug466</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Cl" class="def"
+	    >Cl</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs associated-types"
+	  ><p class="caption"
+	    >Associated Types</p
+	    ><p class="src"
+	    ><span class="keyword"
+	      >type</span
+	      > <a id="t:Fam" class="def"
+	      >Fam</a
+	      > a :: [<a href="#" title="Data.Kind"
+	      >Type</a
+	      >] <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Cl"
+	    >Instances</h4
+	    ><details id="i:Cl" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Cl:Cl:1"
+		      ></span
+		      > <a href="#" title="Bug466"
+		      >Cl</a
+		      > <a href="#" title="Bug466"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Cl:Cl:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug466</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:FamX:Fam:1"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="Bug466"
+				>Fam</a
+				> <a href="#" title="Bug466"
+				>X</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:FamX:Fam:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Bug466</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="Bug466"
+				  >Fam</a
+				  > <a href="#" title="Bug466"
+				  >X</a
+				  > = '[<a href="#" title="Data.Char"
+				  >Char</a
+				  >]</div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:X" class="def"
+	    >X</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:X" class="def"
+		  >X</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:X"
+	    >Instances</h4
+	    ><details id="i:X" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:Cl:1"
+		      ></span
+		      > <a href="#" title="Bug466"
+		      >Cl</a
+		      > <a href="#" title="Bug466"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:Cl:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug466</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:FamX:Fam:1"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="Bug466"
+				>Fam</a
+				> <a href="#" title="Bug466"
+				>X</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:FamX:Fam:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Bug466</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="Bug466"
+				  >Fam</a
+				  > <a href="#" title="Bug466"
+				  >X</a
+				  > = '[<a href="#" title="Data.Char"
+				  >Char</a
+				  >]</div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:Fam:2"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="Bug466"
+		      >Fam</a
+		      > <a href="#" title="Bug466"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:Fam:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug466</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="Bug466"
+			>Fam</a
+			> <a href="#" title="Bug466"
+			>X</a
+			> = '[<a href="#" title="Data.Char"
+			>Char</a
+			>]</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug546.html b/utils/haddock/html-test/ref/Bug546.html
new file mode 100644
index 0000000000000000000000000000000000000000..3b478723821b64b5984457343f7967e40fb44846
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug546.html
@@ -0,0 +1,281 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug546</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug546</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >x</a
+	      > :: <a href="#" title="Prelude"
+	      >Integer</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >compile</a
+	      > :: <a href="#" title="Data.String"
+	      >String</a
+	      > -&gt; <a href="#" title="Data.String"
+	      >String</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:x" class="def"
+	    >x</a
+	    > :: <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Test:</p
+	    ><dl
+	    ><dt
+	      ><code
+		>[code with square \ brackets]</code
+		></dt
+	      ><dd
+	      >lorem ipsum</dd
+	      ></dl
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:compile" class="def"
+	    >compile</a
+	    > :: <a href="#" title="Data.String"
+	    >String</a
+	    > -&gt; <a href="#" title="Data.String"
+	    >String</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><dl
+	    ><dt
+	      ><code
+		>[..]</code
+		></dt
+	      ><dd
+	      >Matches any of the enclosed characters. Ranges of characters can
+            be specified by separating the endpoints with a <code
+		>'-'</code
+		>. <code
+		>'-'</code
+		> or
+            <code
+		>']'</code
+		> can be matched by including them as the first character(s)
+            in the list. Never matches path separators: <code
+		>[/]</code
+		> matches
+            nothing at all. Named character classes can also be matched:
+            <code
+		>[:x:]</code
+		> within <code
+		>[]</code
+		> specifies the class named <code
+		>x</code
+		>, which matches
+            certain predefined characters. See below for a full list.</dd
+	      ><dt
+	      ><code
+		>[^..]</code
+		> or <code
+		>[!..]</code
+		></dt
+	      ><dd
+	      >Like <code
+		>[..]</code
+		>, but matches any character <em
+		>not</em
+		> listed.
+                        Note that <code
+		>[^-x]</code
+		> is not the inverse of <code
+		>[-x]</code
+		>, but
+                        the range <code
+		>[^-x]</code
+		>.</dd
+	      ><dt
+	      ><code
+		>&lt;m-n&gt;</code
+		></dt
+	      ><dd
+	      >Matches any integer in the range m to n, inclusive. The range may
+            be open-ended by leaving out either number: <code
+		>&quot;&lt;-&gt;&quot;</code
+		>, for
+            instance, matches any integer.</dd
+	      ><dt
+	      ><code
+		>**/</code
+		></dt
+	      ><dd
+	      >Matches any number of characters, including path separators,
+            excluding the empty string.</dd
+	      ></dl
+	    ><p
+	    >Supported character classes:</p
+	    ><dl
+	    ><dt
+	      ><code
+		>[:alnum:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;0-9A-Za-z&quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:alpha:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;A-Za-z&quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:blank:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;\t &quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:cntrl:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;\0-\x1f\x7f&quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:digit:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;0-9&quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:graph:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;!-~&quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:lower:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;a-z&quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:print:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot; -~&quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:punct:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;!-/:-@[-`{-~&quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:space:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;\t-\r &quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:upper:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;A-Z&quot;</code
+		>.</dd
+	      ><dt
+	      ><code
+		>[:xdigit:]</code
+		></dt
+	      ><dd
+	      >Equivalent to <code
+		>&quot;0-9A-Fa-f&quot;</code
+		>.</dd
+	      ></dl
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug548.html b/utils/haddock/html-test/ref/Bug548.html
new file mode 100644
index 0000000000000000000000000000000000000000..126615a290411bcaae2643f8054b159e71d6127e
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug548.html
@@ -0,0 +1,996 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug548</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug548</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:WrappedArrow" class="def"
+	    >WrappedArrow</a
+	    > (a :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) b c <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:WrapArrow" class="def"
+		  >WrapArrow</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:unwrapArrow" class="def"
+			  >unwrapArrow</a
+			  > :: a b c</dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:WrappedArrow"
+	    >Instances</h4
+	    ><details id="i:WrappedArrow" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:WrappedArrow:Generic1:1"
+		      ></span
+		      > <a href="#" title="GHC.Generics"
+		      >Generic1</a
+		      > (<a href="#" title="Bug548"
+		      >WrappedArrow</a
+		      > a b :: <a href="#" title="Data.Kind"
+		      >Type</a
+		      > -&gt; <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:WrappedArrow:Generic1:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Control.Applicative</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Rep1_WrappedArrow:Rep1:1"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="GHC.Generics"
+				>Rep1</a
+				> (<a href="#" title="Bug548"
+				>WrappedArrow</a
+				> a b :: <a href="#" title="Data.Kind"
+				>Type</a
+				> -&gt; <a href="#" title="Data.Kind"
+				>Type</a
+				>)</span
+			      ></td
+			    ><td class="doc"
+			    ><p
+			      ><em
+				>Since: base-4.7.0.0</em
+				></p
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:Rep1_WrappedArrow:Rep1:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Control.Applicative</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="GHC.Generics"
+				  >Rep1</a
+				  > (<a href="#" title="Bug548"
+				  >WrappedArrow</a
+				  > a b :: <a href="#" title="Data.Kind"
+				  >Type</a
+				  > -&gt; <a href="#" title="Data.Kind"
+				  >Type</a
+				  >) = <a href="#" title="GHC.Generics"
+				  >D1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaData</a
+				  > &quot;WrappedArrow&quot; &quot;Control.Applicative&quot; &quot;base&quot; '<a href="#" title="Data.Bool"
+				  >True</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >C1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaCons</a
+				  > &quot;WrapArrow&quot; '<a href="#" title="GHC.Generics"
+				  >PrefixI</a
+				  > '<a href="#" title="Data.Bool"
+				  >True</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >S1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaSel</a
+				  > ('<a href="#" title="Data.Maybe"
+				  >Just</a
+				  > &quot;unwrapArrow&quot;) '<a href="#" title="GHC.Generics"
+				  >NoSourceUnpackedness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >NoSourceStrictness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >DecidedLazy</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >Rec1</a
+				  > (a b))))</div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >from1</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="GHC.Generics"
+			  >Rep1</a
+			  > (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b) a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >to1</a
+			  > :: <a href="#" title="GHC.Generics"
+			  >Rep1</a
+			  > (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b) a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:WrappedArrow:Alternative:2"
+		      ></span
+		      > (<a href="#" title="Control.Arrow"
+		      >ArrowZero</a
+		      > a, <a href="#" title="Control.Arrow"
+		      >ArrowPlus</a
+		      > a) =&gt; <a href="#" title="Control.Applicative"
+		      >Alternative</a
+		      > (<a href="#" title="Bug548"
+		      >WrappedArrow</a
+		      > a b)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-2.1</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:WrappedArrow:Alternative:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Control.Applicative</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >empty</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;|&gt;)</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >some</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b [a0] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >many</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b [a0] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:WrappedArrow:Applicative:3"
+		      ></span
+		      > <a href="#" title="Control.Arrow"
+		      >Arrow</a
+		      > a =&gt; <a href="#" title="Control.Applicative"
+		      >Applicative</a
+		      > (<a href="#" title="Bug548"
+		      >WrappedArrow</a
+		      > a b)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-2.1</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:WrappedArrow:Applicative:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Control.Applicative</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >pure</a
+			  > :: a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;*&gt;)</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b (a0 -&gt; b0) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b b0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >liftA2</a
+			  > :: (a0 -&gt; b0 -&gt; c) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b b0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(*&gt;)</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b b0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b b0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;*)</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b b0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:WrappedArrow:Functor:4"
+		      ></span
+		      > <a href="#" title="Control.Arrow"
+		      >Arrow</a
+		      > a =&gt; <a href="#" title="Control.Monad"
+		      >Functor</a
+		      > (<a href="#" title="Bug548"
+		      >WrappedArrow</a
+		      > a b)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-2.1</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:WrappedArrow:Functor:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Control.Applicative</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >fmap</a
+			  > :: (a0 -&gt; b0) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b b0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;$)</a
+			  > :: a0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b b0 -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:WrappedArrow:Data:5"
+		      ></span
+		      > (<a href="#" title="Data.Dynamic"
+		      >Typeable</a
+		      > a, <a href="#" title="Data.Dynamic"
+		      >Typeable</a
+		      > b, <a href="#" title="Data.Dynamic"
+		      >Typeable</a
+		      > c, <a href="#" title="Data.Data"
+		      >Data</a
+		      > (a b c)) =&gt; <a href="#" title="Data.Data"
+		      >Data</a
+		      > (<a href="#" title="Bug548"
+		      >WrappedArrow</a
+		      > a b c)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.14.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:WrappedArrow:Data:5"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Control.Applicative</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >gfoldl</a
+			  > :: (<span class="keyword"
+			  >forall</span
+			  > d b0. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; c0 (d -&gt; b0) -&gt; d -&gt; c0 b0) -&gt; (<span class="keyword"
+			  >forall</span
+			  > g. g -&gt; c0 g) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; c0 (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gunfold</a
+			  > :: (<span class="keyword"
+			  >forall</span
+			  > b0 r. <a href="#" title="Data.Data"
+			  >Data</a
+			  > b0 =&gt; c0 (b0 -&gt; r) -&gt; c0 r) -&gt; (<span class="keyword"
+			  >forall</span
+			  > r. r -&gt; c0 r) -&gt; <a href="#" title="Data.Data"
+			  >Constr</a
+			  > -&gt; c0 (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >toConstr</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; <a href="#" title="Data.Data"
+			  >Constr</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >dataTypeOf</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; <a href="#" title="Data.Data"
+			  >DataType</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >dataCast1</a
+			  > :: <a href="#" title="Data.Dynamic"
+			  >Typeable</a
+			  > t =&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; c0 (t d)) -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (c0 (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >dataCast2</a
+			  > :: <a href="#" title="Data.Dynamic"
+			  >Typeable</a
+			  > t =&gt; (<span class="keyword"
+			  >forall</span
+			  > d e. (<a href="#" title="Data.Data"
+			  >Data</a
+			  > d, <a href="#" title="Data.Data"
+			  >Data</a
+			  > e) =&gt; c0 (t d e)) -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (c0 (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapT</a
+			  > :: (<span class="keyword"
+			  >forall</span
+			  > b0. <a href="#" title="Data.Data"
+			  >Data</a
+			  > b0 =&gt; b0 -&gt; b0) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapQl</a
+			  > :: (r -&gt; r' -&gt; r) -&gt; r -&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; r') -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; r <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapQr</a
+			  > :: <span class="keyword"
+			  >forall</span
+			  > r r'. (r' -&gt; r -&gt; r) -&gt; r -&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; r') -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; r <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapQ</a
+			  > :: (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; u) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; [u] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapQi</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; u) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; u <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapM</a
+			  > :: <a href="#" title="Control.Monad"
+			  >Monad</a
+			  > m =&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; m d) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; m (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapMp</a
+			  > :: <a href="#" title="Control.Monad"
+			  >MonadPlus</a
+			  > m =&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; m d) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; m (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >gmapMo</a
+			  > :: <a href="#" title="Control.Monad"
+			  >MonadPlus</a
+			  > m =&gt; (<span class="keyword"
+			  >forall</span
+			  > d. <a href="#" title="Data.Data"
+			  >Data</a
+			  > d =&gt; d -&gt; m d) -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; m (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:WrappedArrow:Generic:6"
+		      ></span
+		      > <a href="#" title="GHC.Generics"
+		      >Generic</a
+		      > (<a href="#" title="Bug548"
+		      >WrappedArrow</a
+		      > a b c)</span
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:WrappedArrow:Generic:6"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Control.Applicative</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Rep_WrappedArrow:Rep:1"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="GHC.Generics"
+				>Rep</a
+				> (<a href="#" title="Bug548"
+				>WrappedArrow</a
+				> a b c)</span
+			      ></td
+			    ><td class="doc"
+			    ><p
+			      ><em
+				>Since: base-4.7.0.0</em
+				></p
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:Rep_WrappedArrow:Rep:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Control.Applicative</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="GHC.Generics"
+				  >Rep</a
+				  > (<a href="#" title="Bug548"
+				  >WrappedArrow</a
+				  > a b c) = <a href="#" title="GHC.Generics"
+				  >D1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaData</a
+				  > &quot;WrappedArrow&quot; &quot;Control.Applicative&quot; &quot;base&quot; '<a href="#" title="Data.Bool"
+				  >True</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >C1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaCons</a
+				  > &quot;WrapArrow&quot; '<a href="#" title="GHC.Generics"
+				  >PrefixI</a
+				  > '<a href="#" title="Data.Bool"
+				  >True</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >S1</a
+				  > ('<a href="#" title="GHC.Generics"
+				  >MetaSel</a
+				  > ('<a href="#" title="Data.Maybe"
+				  >Just</a
+				  > &quot;unwrapArrow&quot;) '<a href="#" title="GHC.Generics"
+				  >NoSourceUnpackedness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >NoSourceStrictness</a
+				  > '<a href="#" title="GHC.Generics"
+				  >DecidedLazy</a
+				  >) (<a href="#" title="GHC.Generics"
+				  >Rec0</a
+				  > (a b c))))</div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >from</a
+			  > :: <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c -&gt; <a href="#" title="GHC.Generics"
+			  >Rep</a
+			  > (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c) x <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >to</a
+			  > :: <a href="#" title="GHC.Generics"
+			  >Rep</a
+			  > (<a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c) x -&gt; <a href="#" title="Bug548"
+			  >WrappedArrow</a
+			  > a b c <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:WrappedArrow:Rep1:7"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="GHC.Generics"
+		      >Rep1</a
+		      > (<a href="#" title="Bug548"
+		      >WrappedArrow</a
+		      > a b :: <a href="#" title="Data.Kind"
+		      >Type</a
+		      > -&gt; <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.7.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:WrappedArrow:Rep1:7"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Control.Applicative</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="GHC.Generics"
+			>Rep1</a
+			> (<a href="#" title="Bug548"
+			>WrappedArrow</a
+			> a b :: <a href="#" title="Data.Kind"
+			>Type</a
+			> -&gt; <a href="#" title="Data.Kind"
+			>Type</a
+			>) = <a href="#" title="GHC.Generics"
+			>D1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaData</a
+			> &quot;WrappedArrow&quot; &quot;Control.Applicative&quot; &quot;base&quot; '<a href="#" title="Data.Bool"
+			>True</a
+			>) (<a href="#" title="GHC.Generics"
+			>C1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaCons</a
+			> &quot;WrapArrow&quot; '<a href="#" title="GHC.Generics"
+			>PrefixI</a
+			> '<a href="#" title="Data.Bool"
+			>True</a
+			>) (<a href="#" title="GHC.Generics"
+			>S1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaSel</a
+			> ('<a href="#" title="Data.Maybe"
+			>Just</a
+			> &quot;unwrapArrow&quot;) '<a href="#" title="GHC.Generics"
+			>NoSourceUnpackedness</a
+			> '<a href="#" title="GHC.Generics"
+			>NoSourceStrictness</a
+			> '<a href="#" title="GHC.Generics"
+			>DecidedLazy</a
+			>) (<a href="#" title="GHC.Generics"
+			>Rec1</a
+			> (a b))))</div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:WrappedArrow:Rep:8"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="GHC.Generics"
+		      >Rep</a
+		      > (<a href="#" title="Bug548"
+		      >WrappedArrow</a
+		      > a b c)</span
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    ><em
+		      >Since: base-4.7.0.0</em
+		      ></p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:WrappedArrow:Rep:8"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Control.Applicative</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="GHC.Generics"
+			>Rep</a
+			> (<a href="#" title="Bug548"
+			>WrappedArrow</a
+			> a b c) = <a href="#" title="GHC.Generics"
+			>D1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaData</a
+			> &quot;WrappedArrow&quot; &quot;Control.Applicative&quot; &quot;base&quot; '<a href="#" title="Data.Bool"
+			>True</a
+			>) (<a href="#" title="GHC.Generics"
+			>C1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaCons</a
+			> &quot;WrapArrow&quot; '<a href="#" title="GHC.Generics"
+			>PrefixI</a
+			> '<a href="#" title="Data.Bool"
+			>True</a
+			>) (<a href="#" title="GHC.Generics"
+			>S1</a
+			> ('<a href="#" title="GHC.Generics"
+			>MetaSel</a
+			> ('<a href="#" title="Data.Maybe"
+			>Just</a
+			> &quot;unwrapArrow&quot;) '<a href="#" title="GHC.Generics"
+			>NoSourceUnpackedness</a
+			> '<a href="#" title="GHC.Generics"
+			>NoSourceStrictness</a
+			> '<a href="#" title="GHC.Generics"
+			>DecidedLazy</a
+			>) (<a href="#" title="GHC.Generics"
+			>Rec0</a
+			> (a b c))))</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug574.html b/utils/haddock/html-test/ref/Bug574.html
new file mode 100644
index 0000000000000000000000000000000000000000..ae6fea1bc0cbc0f248be15a8484f2cdbd55e759f
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug574.html
@@ -0,0 +1,94 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug574</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug574</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Something with a spliced type</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug6.html b/utils/haddock/html-test/ref/Bug6.html
new file mode 100644
index 0000000000000000000000000000000000000000..129542e2351b45124abd50a5f0844ec7e2fa8aea
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug6.html
@@ -0,0 +1,340 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug6</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug6</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >Exporting records.</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >A</a
+	      > = <a href="#"
+	      >A</a
+	      > <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >B</a
+	      > = <a href="#"
+	      >B</a
+	      > <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >b</a
+	      > :: <a href="#" title="Bug6"
+	      >B</a
+	      > -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >C</a
+	      > = <a href="#"
+	      >C</a
+	      > {<ul class="subs"
+	      ><li
+		><a href="#"
+		  >c1</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  ></li
+		><li
+		><a href="#"
+		  >c2</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  ></li
+		></ul
+	      >}</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >D</a
+	      > = <a href="#"
+	      >D</a
+	      > <a href="#" title="Data.Int"
+	      >Int</a
+	      > <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >newtype</span
+	      > <a href="#"
+	      >E</a
+	      > = <a href="#"
+	      >E</a
+	      > <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:A" class="def"
+	    >A</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This record is exported without its field</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:A" class="def"
+		  >A</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:B" class="def"
+	    >B</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >.. with its field, but the field is named separately in the export list
+ (the field isn't documented separately since it is already documented here)</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:B" class="def"
+		  >B</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:b" class="def"
+	    >b</a
+	    > :: <a href="#" title="Bug6"
+	    >B</a
+	    > -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:C" class="def"
+	    >C</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >.. with fields names as subordinate names in the export</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:C" class="def"
+		  >C</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:c1" class="def"
+			  >c1</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:c2" class="def"
+			  >c2</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:D" class="def"
+	    >D</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >.. with only some of the fields exported (we can't handle this one -
+ how do we render the declaration?)</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:D" class="def"
+		  >D</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:E" class="def"
+	    >E</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >a newtype with a field</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:E" class="def"
+		  >E</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug613.html b/utils/haddock/html-test/ref/Bug613.html
new file mode 100644
index 0000000000000000000000000000000000000000..16cd5b932a82660fbffc67e6bd2ed8a421a6f058
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug613.html
@@ -0,0 +1,292 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug613</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug613</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >Functor</a
+	      > (f :: <a href="#" title="Data.Kind"
+	      >Type</a
+	      > -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      >) <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >fmap</a
+		  > :: (a -&gt; b) -&gt; f a -&gt; f b</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >ThreeVars</a
+	      > a0 a b = <a href="#"
+	      >ThreeVars</a
+	      > a b</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Functor" class="def"
+	    >Functor</a
+	    > (f :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:fmap" class="def"
+	      >fmap</a
+	      > :: (a -&gt; b) -&gt; f a -&gt; f b <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Functor"
+	    >Instances</h4
+	    ><details id="i:Functor" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Functor:Functor:1"
+		      ></span
+		      > <a href="#" title="Bug613"
+		      >Functor</a
+		      > (<a href="#" title="Data.Either"
+		      >Either</a
+		      > a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Functor:Functor:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug613</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >fmap</a
+			  > :: (a0 -&gt; b) -&gt; <a href="#" title="Data.Either"
+			  >Either</a
+			  > a a0 -&gt; <a href="#" title="Data.Either"
+			  >Either</a
+			  > a b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Functor:Functor:2"
+		      ></span
+		      > <a href="#" title="Bug613"
+		      >Functor</a
+		      > (<a href="#" title="Bug613"
+		      >ThreeVars</a
+		      > a0 a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Functor:Functor:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug613</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >fmap</a
+			  > :: (a1 -&gt; b) -&gt; <a href="#" title="Bug613"
+			  >ThreeVars</a
+			  > a0 a a1 -&gt; <a href="#" title="Bug613"
+			  >ThreeVars</a
+			  > a0 a b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:ThreeVars" class="def"
+	    >ThreeVars</a
+	    > a0 a b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Phantom type a0 is added to block the first renaming from a to a0. This ensures that the renamer doesn't create a new conflict</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:ThreeVars" class="def"
+		  >ThreeVars</a
+		  > a b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:ThreeVars"
+	    >Instances</h4
+	    ><details id="i:ThreeVars" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:ThreeVars:Functor:1"
+		      ></span
+		      > <a href="#" title="Bug613"
+		      >Functor</a
+		      > (<a href="#" title="Bug613"
+		      >ThreeVars</a
+		      > a0 a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:ThreeVars:Functor:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug613</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >fmap</a
+			  > :: (a1 -&gt; b) -&gt; <a href="#" title="Bug613"
+			  >ThreeVars</a
+			  > a0 a a1 -&gt; <a href="#" title="Bug613"
+			  >ThreeVars</a
+			  > a0 a b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug647.html b/utils/haddock/html-test/ref/Bug647.html
new file mode 100644
index 0000000000000000000000000000000000000000..07b3b11bd1dbb155644de1d4b6ee4f6a9500c9e2
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug647.html
@@ -0,0 +1,110 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug647</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug647</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Bug647" class="def"
+	    >Bug647</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:f" class="def"
+	      >f</a
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="subs arguments"
+	    ><p class="caption"
+	      >Arguments</p
+	      ><table
+	      ><tr
+		><td class="src"
+		  >:: a</td
+		  ><td class="doc"
+		  ><p
+		    >doc for arg1</p
+		    ></td
+		  ></tr
+		><tr
+		><td class="src"
+		  >-&gt; a</td
+		  ><td class="doc"
+		  ><p
+		    >doc for arg2</p
+		    ></td
+		  ></tr
+		><tr
+		><td class="src"
+		  >-&gt; a</td
+		  ><td class="doc"
+		  ><p
+		    >doc for arg3</p
+		    ></td
+		  ></tr
+		></table
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug679.html b/utils/haddock/html-test/ref/Bug679.html
new file mode 100644
index 0000000000000000000000000000000000000000..1bf2ccfdbdfc98c7c4b9c33a27d5076cedc4a26f
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug679.html
@@ -0,0 +1,208 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug679</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug679</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Bar" class="def"
+	    >Bar</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Bar" class="def"
+		  >Bar</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Bar"
+	    >Instances</h4
+	    ><details id="i:Bar" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Bar:Foo:1"
+		      ></span
+		      > <a href="#" title="Bug679"
+		      >Foo</a
+		      > (<a href="#" title="Bug679"
+		      >Bar</a
+		      > a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Bar:Foo:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug679</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: <a href="#" title="Bug679"
+			  >Bar</a
+			  > a -&gt; <a href="#" title="Bug679"
+			  >Bar</a
+			  > a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:foo" class="def"
+	      >foo</a
+	      > :: a -&gt; a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo"
+	    >Instances</h4
+	    ><details id="i:Foo" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:1"
+		      ></span
+		      > <a href="#" title="Bug679"
+		      >Foo</a
+		      > (<a href="#" title="Bug679"
+		      >Bar</a
+		      > a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug679</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: <a href="#" title="Bug679"
+			  >Bar</a
+			  > a -&gt; <a href="#" title="Bug679"
+			  >Bar</a
+			  > a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug7.html b/utils/haddock/html-test/ref/Bug7.html
new file mode 100644
index 0000000000000000000000000000000000000000..df5cebe342e20d8444bb68ad02fe0a4d784b2848
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug7.html
@@ -0,0 +1,215 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug7</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug7</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >This module caused a duplicate instance in the documentation for the Foo
+ type.</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Foo</a
+	      > = <a href="#"
+	      >Foo</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >Bar</a
+	      > x y</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >The Foo datatype</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Foo" class="def"
+		  >Foo</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo"
+	    >Instances</h4
+	    ><details id="i:Foo" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Foo:Bar:1"
+		      ></span
+		      > <a href="#" title="Bug7"
+		      >Bar</a
+		      > <a href="#" title="Bug7"
+		      >Foo</a
+		      > <a href="#" title="Bug7"
+		      >Foo</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Just one instance</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Foo:Bar:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug7</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Bar" class="def"
+	    >Bar</a
+	    > x y <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >The Bar class</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Bar"
+	    >Instances</h4
+	    ><details id="i:Bar" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Bar:Bar:1"
+		      ></span
+		      > <a href="#" title="Bug7"
+		      >Bar</a
+		      > <a href="#" title="Bug7"
+		      >Foo</a
+		      > <a href="#" title="Bug7"
+		      >Foo</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Just one instance</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Bar:Bar:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug7</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug8.html b/utils/haddock/html-test/ref/Bug8.html
new file mode 100644
index 0000000000000000000000000000000000000000..fda107707f5818fe69fb0ee11f706f8e236b27e4
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug8.html
@@ -0,0 +1,154 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug8</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug8</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Typ" class="def"
+	    >Typ</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Type" class="def"
+		  >Type</a
+		  > (<a href="#" title="Bug8"
+		  >Typ</a
+		  >, [<a href="#" title="Bug8"
+		  >Typ</a
+		  >])</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:TFree" class="def"
+		  >TFree</a
+		  > (<a href="#" title="Bug8"
+		  >Typ</a
+		  >, [<a href="#" title="Bug8"
+		  >Typ</a
+		  >])</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-45--45--62-" class="def"
+	    >(--&gt;)</a
+	    > :: p1 -&gt; p2 -&gt; <a href="#" title="Bug8"
+	    >Typ</a
+	    > <span class="fixity"
+	    >infix 9</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-45--45--45--62-" class="def"
+	    >(---&gt;)</a
+	    > :: <a href="#" title="Data.Foldable"
+	    >Foldable</a
+	    > t0 =&gt; t0 t -&gt; <a href="#" title="Bug8"
+	    >Typ</a
+	    > -&gt; <a href="#" title="Bug8"
+	    >Typ</a
+	    > <span class="fixity"
+	    >infix 9</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:s" class="def"
+	    >s</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:t" class="def"
+	    >t</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:main" class="def"
+	    >main</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug85.html b/utils/haddock/html-test/ref/Bug85.html
new file mode 100644
index 0000000000000000000000000000000000000000..714635da82f3771c07b7b11c688736b2fc61861a
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug85.html
@@ -0,0 +1,152 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug85</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</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 id="t:Foo" class="def"
+	    >Foo</a
+	    > (a :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) b <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Bar" class="def"
+		  >Bar</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > (a :: <a href="#" title="Data.Kind"
+		  >Type</a
+		  > -&gt; <a href="#" title="Data.Kind"
+		  >Type</a
+		  >) x. a x -&gt; <a href="#" title="Bug85"
+		  >Foo</a
+		  > a (a x)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Baz" class="def"
+	    >Baz</a
+	    > <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Baz-39-" class="def"
+		  >Baz'</a
+		  > :: <a href="#" title="Bug85"
+		  >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 id="t:Qux" class="def"
+	    >Qux</a
+	    > <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Quux" class="def"
+		  >Quux</a
+		  > :: <a href="#" title="Bug85"
+		  >Qux</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug865.html b/utils/haddock/html-test/ref/Bug865.html
new file mode 100644
index 0000000000000000000000000000000000000000..7cc142b33fff0382e971ec3d9e1fd9ccd17dbc3c
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug865.html
@@ -0,0 +1,92 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug865</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug865</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >link</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:link" class="def"
+	    >link</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >An emphasized link <a href="#"
+	      >yes <em
+		>this</em
+		> is emphasized while this is
+ <code
+		>monospaced</code
+		></a
+	      >. And here is an image:</p
+	    ><p
+	    ><img src="https://www.haskell.org/static/img/haskell-logo.svg" title="emphasis stripped"
+	       /></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug923.html b/utils/haddock/html-test/ref/Bug923.html
new file mode 100644
index 0000000000000000000000000000000000000000..3992c17fe9cc813d5e8a7dab7d7fe67606f5aa36
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug923.html
@@ -0,0 +1,256 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug923</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug923</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >T</a
+	      > (a :: <a href="#" title="Data.Kind"
+	      >Type</a
+	      > -&gt; (<a href="#" title="Data.Kind"
+	      >Type</a
+	      >, <a href="#" title="Data.Kind"
+	      >Type</a
+	      >)) <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >T</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > a1. a1 -&gt; <a href="#" title="Bug923"
+		  >T</a
+		  > ('<a href="#" title="GHC.Tuple"
+		  >(,)</a
+		  > a1 :: <a href="#" title="Data.Kind"
+		  >Type</a
+		  > -&gt; (<a href="#" title="Data.Kind"
+		  >Type</a
+		  >, <a href="#" title="Data.Kind"
+		  >Type</a
+		  >))</li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:T" class="def"
+	    >T</a
+	    > (a :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; (<a href="#" title="Data.Kind"
+	    >Type</a
+	    >, <a href="#" title="Data.Kind"
+	    >Type</a
+	    >)) <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A promoted tuple type</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:T" class="def"
+		  >T</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > a1. a1 -&gt; <a href="#" title="Bug923"
+		  >T</a
+		  > ('<a href="#" title="GHC.Tuple"
+		  >(,)</a
+		  > a1 :: <a href="#" title="Data.Kind"
+		  >Type</a
+		  > -&gt; (<a href="#" title="Data.Kind"
+		  >Type</a
+		  >, <a href="#" title="Data.Kind"
+		  >Type</a
+		  >))</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:T"
+	    >Instances</h4
+	    ><details id="i:T" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:T:Eq:1"
+		      ></span
+		      > <a href="#" title="Data.Eq"
+		      >Eq</a
+		      > a =&gt; <a href="#" title="Data.Eq"
+		      >Eq</a
+		      > (<a href="#" title="Bug923"
+		      >T</a
+		      > ('<a href="#" title="GHC.Tuple"
+		      >(,)</a
+		      > a :: <a href="#" title="Data.Kind"
+		      >Type</a
+		      > -&gt; (<a href="#" title="Data.Kind"
+		      >Type</a
+		      >, <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)))</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >A promoted tuple type in an instance</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:T:Eq:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Bug923</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >(==)</a
+			  > :: <a href="#" title="Bug923"
+			  >T</a
+			  > ('<a href="#" title="GHC.Tuple"
+			  >(,)</a
+			  > a :: <a href="#" title="Data.Kind"
+			  >Type</a
+			  > -&gt; (<a href="#" title="Data.Kind"
+			  >Type</a
+			  >, <a href="#" title="Data.Kind"
+			  >Type</a
+			  >)) -&gt; <a href="#" title="Bug923"
+			  >T</a
+			  > ('<a href="#" title="GHC.Tuple"
+			  >(,)</a
+			  > a :: <a href="#" title="Data.Kind"
+			  >Type</a
+			  > -&gt; (<a href="#" title="Data.Kind"
+			  >Type</a
+			  >, <a href="#" title="Data.Kind"
+			  >Type</a
+			  >)) -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(/=)</a
+			  > :: <a href="#" title="Bug923"
+			  >T</a
+			  > ('<a href="#" title="GHC.Tuple"
+			  >(,)</a
+			  > a :: <a href="#" title="Data.Kind"
+			  >Type</a
+			  > -&gt; (<a href="#" title="Data.Kind"
+			  >Type</a
+			  >, <a href="#" title="Data.Kind"
+			  >Type</a
+			  >)) -&gt; <a href="#" title="Bug923"
+			  >T</a
+			  > ('<a href="#" title="GHC.Tuple"
+			  >(,)</a
+			  > a :: <a href="#" title="Data.Kind"
+			  >Type</a
+			  > -&gt; (<a href="#" title="Data.Kind"
+			  >Type</a
+			  >, <a href="#" title="Data.Kind"
+			  >Type</a
+			  >)) -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug952.html b/utils/haddock/html-test/ref/Bug952.html
new file mode 100644
index 0000000000000000000000000000000000000000..0105b82fe73b91dec2436c041b838d3509d12b98
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug952.html
@@ -0,0 +1,82 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug952</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug952</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >See 'case', 'of', '--' compared to 'Q.case', 'Q.of', 'Q.--'</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug953.html b/utils/haddock/html-test/ref/Bug953.html
new file mode 100644
index 0000000000000000000000000000000000000000..b19179d093cdacb7227b22ec56cefdc1a19c83aa
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug953.html
@@ -0,0 +1,154 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug953</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug953</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Foo</a
+	      > = <a href="#"
+	      >Foo'</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Bar</a
+	      > = <a href="#"
+	      >Bar'</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A foo</p
+	    ><h4 class="subheading details-toggle-control details-toggle" data-details-id="ch:Foo0"
+	    >Examples</h4
+	    ><details id="ch:Foo0"
+	    ><summary class="hide-when-js-enabled"
+	      >Expand</summary
+	      ><p
+	      >Foo example body</p
+	      ></details
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Foo-39-" class="def"
+		  >Foo'</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Bar" class="def"
+	    >Bar</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A bar</p
+	    ><h4 class="subheading details-toggle-control details-toggle" data-details-id="ch:Bar0"
+	    >Examples</h4
+	    ><details id="ch:Bar0"
+	    ><summary class="hide-when-js-enabled"
+	      >Expand</summary
+	      ><p
+	      >Bar example body</p
+	      ></details
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Bar-39-" class="def"
+		  >Bar'</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bug973.html b/utils/haddock/html-test/ref/Bug973.html
new file mode 100644
index 0000000000000000000000000000000000000000..25fb6408322c03fbeb48ac6ed13d8eb765ae7fa2
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bug973.html
@@ -0,0 +1,174 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bug973</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug973</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >showRead</a
+	      > :: (<a href="#" title="Prelude"
+	      >Show</a
+	      > a, <a href="#" title="Prelude"
+	      >Read</a
+	      > b) =&gt; a -&gt; b</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >showRead'</a
+	      > :: <span class="keyword"
+	      >forall</span
+	      > b a. (<a href="#" title="Prelude"
+	      >Show</a
+	      > a, <a href="#" title="Prelude"
+	      >Read</a
+	      > b) =&gt; a -&gt; b</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:showRead" class="def"
+	    >showRead</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: (<a href="#" title="Prelude"
+		  >Show</a
+		  > a, <a href="#" title="Prelude"
+		  >Read</a
+		  > b)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>=&gt; a</td
+		><td class="doc"
+		><p
+		  >this gets turned into a string...</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; b</td
+		><td class="doc"
+		><p
+		  >...from which this is read</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:showRead-39-" class="def"
+	    >showRead'</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: <span class="keyword"
+		  >forall</span
+		  > b a. (<a href="#" title="Prelude"
+		  >Show</a
+		  > a, <a href="#" title="Prelude"
+		  >Read</a
+		  > b)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>=&gt; a</td
+		><td class="doc"
+		><p
+		  >this gets turned into a string...</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; b</td
+		><td class="doc"
+		><p
+		  >...from which this is read</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="doc"
+	  ><p
+	    >Same as <code
+	      ><a href="#" title="Bug973"
+		>showRead</a
+		></code
+	      >, but with type variable order flipped</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/BugDeprecated.html b/utils/haddock/html-test/ref/BugDeprecated.html
new file mode 100644
index 0000000000000000000000000000000000000000..e4017f17f7d0016841fa513ead21dd784f46fe07
--- /dev/null
+++ b/utils/haddock/html-test/ref/BugDeprecated.html
@@ -0,0 +1,200 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >BugDeprecated</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>BugDeprecated</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >bar</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >baz</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >one</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >two</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >three</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: for foo</p
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:bar" class="def"
+	    >bar</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: for bar</p
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:baz" class="def"
+	    >baz</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: for baz</p
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:one" class="def"
+	    >one</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: for one</p
+	      ></div
+	    ><p
+	    >some documentation for one</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:two" class="def"
+	    >two</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: for two</p
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:three" class="def"
+	    >three</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: for three</p
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/BugExportHeadings.html b/utils/haddock/html-test/ref/BugExportHeadings.html
new file mode 100644
index 0000000000000000000000000000000000000000..2ba3a8585ffed13334ddced7ad9d156aeb130836
--- /dev/null
+++ b/utils/haddock/html-test/ref/BugExportHeadings.html
@@ -0,0 +1,234 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >BugExportHeadings</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>BugExportHeadings</p
+	></div
+      ><div id="table-of-contents"
+      ><div id="contents-list"
+	><p class="caption" onclick="window.scrollTo(0,0)"
+	  >Contents</p
+	  ><ul
+	  ><li
+	    ><a href="#"
+	      >Foo</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Bar</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Baz</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >One</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Two</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Three</a
+	      ></li
+	    ></ul
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >bar</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >baz</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >one</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >two</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >three</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><a href="#" id="g:1"
+	><h1
+	  >Foo</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><a href="#" id="g:2"
+	><h1
+	  >Bar</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:bar" class="def"
+	    >bar</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><a href="#" id="g:3"
+	><h1
+	  >Baz</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:baz" class="def"
+	    >baz</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><a href="#" id="g:4"
+	><h1
+	  >One</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:one" class="def"
+	    >one</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: for one</p
+	      ></div
+	    ></div
+	  ></div
+	><a href="#" id="g:5"
+	><h1
+	  >Two</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:two" class="def"
+	    >two</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: for two</p
+	      ></div
+	    ></div
+	  ></div
+	><a href="#" id="g:6"
+	><h1
+	  >Three</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:three" class="def"
+	    >three</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: for three</p
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Bugs.html b/utils/haddock/html-test/ref/Bugs.html
new file mode 100644
index 0000000000000000000000000000000000000000..59c79d24053b818e001b58d6f8cf94c84d2862fb
--- /dev/null
+++ b/utils/haddock/html-test/ref/Bugs.html
@@ -0,0 +1,84 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Bugs</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bugs</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:A" class="def"
+	    >A</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:A" class="def"
+		  >A</a
+		  > a (a -&gt; <a href="#" title="Data.Int"
+		  >Int</a
+		  >)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/BundledPatterns.html b/utils/haddock/html-test/ref/BundledPatterns.html
new file mode 100644
index 0000000000000000000000000000000000000000..8672a3b3c6b07e9d1363483a0f48d152693460e2
--- /dev/null
+++ b/utils/haddock/html-test/ref/BundledPatterns.html
@@ -0,0 +1,468 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >BundledPatterns</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>BundledPatterns</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Vec</a
+	      > (a :: <a href="#" title="GHC.TypeLits"
+	      >Nat</a
+	      >) b <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >Nil</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > b. <a href="#" title="BundledPatterns"
+		  >Vec</a
+		  > 0 b</li
+		><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >(:&gt;)</a
+		  > :: a -&gt; <a href="#" title="BundledPatterns"
+		  >Vec</a
+		  > n a -&gt; <a href="#" title="BundledPatterns"
+		  >Vec</a
+		  > (n <a href="#" title="Bug310"
+		  >+</a
+		  > 1) a</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >RTree</a
+	      > (a :: <a href="#" title="GHC.TypeLits"
+	      >Nat</a
+	      >) b <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >LR</a
+		  > :: a -&gt; <a href="#" title="BundledPatterns"
+		  >RTree</a
+		  > 0 a</li
+		><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >BR</a
+		  > :: <a href="#" title="BundledPatterns"
+		  >RTree</a
+		  > d a -&gt; <a href="#" title="BundledPatterns"
+		  >RTree</a
+		  > d a -&gt; <a href="#" title="BundledPatterns"
+		  >RTree</a
+		  > (d <a href="#" title="Bug310"
+		  >+</a
+		  > 1) a</li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Vec" class="def"
+	    >Vec</a
+	    > (a :: <a href="#" title="GHC.TypeLits"
+	    >Nat</a
+	    >) b <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Fixed size vectors.</p
+	    ><ul
+	    ><li
+	      >Lists with their length encoded in their type</li
+	      ><li
+	      ><code
+		><a href="#" title="BundledPatterns"
+		  >Vec</a
+		  ></code
+		>tor elements have an <strong
+		>ASCENDING</strong
+		> subscript starting from 0 and
+   ending at <code
+		><code
+		  ><a href="#" title="Data.Foldable"
+		    >length</a
+		    ></code
+		  > - 1</code
+		>.</li
+	      ></ul
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Nil" class="def"
+		  >Nil</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > b. <a href="#" title="BundledPatterns"
+		  >Vec</a
+		  > 0 b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs bundled-patterns"
+	  ><p class="caption"
+	    >Bundled Patterns</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v::-62-" class="def"
+		  >(:&gt;)</a
+		  > :: a -&gt; <a href="#" title="BundledPatterns"
+		  >Vec</a
+		  > n a -&gt; <a href="#" title="BundledPatterns"
+		  >Vec</a
+		  > (n <a href="#" title="Bug310"
+		  >+</a
+		  > 1) a <span class="fixity"
+		  >infixr 5</span
+		  ><span class="rightedge"
+		  ></span
+		  ></td
+		><td class="doc"
+		><p
+		  >Add an element to the head of a vector.</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >3:&gt;4:&gt;5:&gt;Nil
+</code
+		      ></strong
+		    >&lt;3,4,5&gt;
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let x = 3:&gt;4:&gt;5:&gt;Nil
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t x
+</code
+		      ></strong
+		    >x :: Num a =&gt; Vec 3 a
+</pre
+		  ><p
+		  >Can be used as a pattern:</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let f (x :&gt; y :&gt; _) = x + y
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t f
+</code
+		      ></strong
+		    >f :: Num a =&gt; Vec ((n + 1) + 1) a -&gt; a
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >f (3:&gt;4:&gt;5:&gt;6:&gt;7:&gt;Nil)
+</code
+		      ></strong
+		    >7
+</pre
+		  ><p
+		  >Also in conjunctions with (<code
+		    >:&lt;</code
+		    >):</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let g (a :&gt; b :&gt; (_ :&lt; y :&lt; x)) = a + b +  x + y
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t g
+</code
+		      ></strong
+		    >g :: Num a =&gt; Vec ((((n + 1) + 1) + 1) + 1) a -&gt; a
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >g (1:&gt;2:&gt;3:&gt;4:&gt;5:&gt;Nil)
+</code
+		      ></strong
+		    >12
+</pre
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:RTree" class="def"
+	    >RTree</a
+	    > (a :: <a href="#" title="GHC.TypeLits"
+	    >Nat</a
+	    >) b <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Perfect depth binary tree.</p
+	    ><ul
+	    ><li
+	      >Only has elements at the leaf of the tree</li
+	      ><li
+	      >A tree of depth <em
+		>d</em
+		> has <em
+		>2^d</em
+		> elements.</li
+	      ></ul
+	    ></div
+	  ><div class="subs bundled-patterns"
+	  ><p class="caption"
+	    >Bundled Patterns</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v:LR" class="def"
+		  >LR</a
+		  > :: a -&gt; <a href="#" title="BundledPatterns"
+		  >RTree</a
+		  > 0 a</td
+		><td class="doc"
+		><p
+		  >Leaf of a perfect depth tree</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >LR 1
+</code
+		      ></strong
+		    >1
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let x = LR 1
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t x
+</code
+		      ></strong
+		    >x :: Num a =&gt; RTree 0 a
+</pre
+		  ><p
+		  >Can be used as a pattern:</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let f (LR a) (LR b) = a + b
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t f
+</code
+		      ></strong
+		    >f :: Num a =&gt; RTree 0 a -&gt; RTree 0 a -&gt; a
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >f (LR 1) (LR 2)
+</code
+		      ></strong
+		    >3
+</pre
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v:BR" class="def"
+		  >BR</a
+		  > :: <a href="#" title="BundledPatterns"
+		  >RTree</a
+		  > d a -&gt; <a href="#" title="BundledPatterns"
+		  >RTree</a
+		  > d a -&gt; <a href="#" title="BundledPatterns"
+		  >RTree</a
+		  > (d <a href="#" title="Bug310"
+		  >+</a
+		  > 1) a</td
+		><td class="doc"
+		><p
+		  >Branch of a perfect depth tree</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >BR (LR 1) (LR 2)
+</code
+		      ></strong
+		    >&lt;1,2&gt;
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let x = BR (LR 1) (LR 2)
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t x
+</code
+		      ></strong
+		    >x :: Num a =&gt; RTree 1 a
+</pre
+		  ><p
+		  >Case be used a pattern:</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let f (BR (LR a) (LR b)) = LR (a + b)
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t f
+</code
+		      ></strong
+		    >f :: Num a =&gt; RTree 1 a -&gt; RTree 0 a
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >f (BR (LR 1) (LR 2))
+</code
+		      ></strong
+		    >3
+</pre
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/BundledPatterns2.html b/utils/haddock/html-test/ref/BundledPatterns2.html
new file mode 100644
index 0000000000000000000000000000000000000000..d3c4a60f25f372566206d7a757e233e4f2ad9704
--- /dev/null
+++ b/utils/haddock/html-test/ref/BundledPatterns2.html
@@ -0,0 +1,462 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >BundledPatterns2</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>BundledPatterns2</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Vec</a
+	      > (a :: <a href="#" title="GHC.TypeLits"
+	      >Nat</a
+	      >) b <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >(:&gt;)</a
+		  > :: a -&gt; <a href="#" title="BundledPatterns2"
+		  >Vec</a
+		  > n a -&gt; <a href="#" title="BundledPatterns2"
+		  >Vec</a
+		  > (n <a href="#" title="Bug310"
+		  >+</a
+		  > 1) a</li
+		><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >Empty</a
+		  > :: <a href="#" title="BundledPatterns2"
+		  >Vec</a
+		  > 0 a</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >RTree</a
+	      > (a :: <a href="#" title="GHC.TypeLits"
+	      >Nat</a
+	      >) b <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >LR</a
+		  > :: a -&gt; <a href="#" title="BundledPatterns2"
+		  >RTree</a
+		  > 0 a</li
+		><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >BR</a
+		  > :: <a href="#" title="BundledPatterns2"
+		  >RTree</a
+		  > d a -&gt; <a href="#" title="BundledPatterns2"
+		  >RTree</a
+		  > d a -&gt; <a href="#" title="BundledPatterns2"
+		  >RTree</a
+		  > (d <a href="#" title="Bug310"
+		  >+</a
+		  > 1) a</li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Vec" class="def"
+	    >Vec</a
+	    > (a :: <a href="#" title="GHC.TypeLits"
+	    >Nat</a
+	    >) b <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Fixed size vectors.</p
+	    ><ul
+	    ><li
+	      >Lists with their length encoded in their type</li
+	      ><li
+	      ><code
+		><a href="#" title="BundledPatterns2"
+		  >Vec</a
+		  ></code
+		>tor elements have an <strong
+		>ASCENDING</strong
+		> subscript starting from 0 and
+   ending at <code
+		><code
+		  ><a href="#" title="Data.Foldable"
+		    >length</a
+		    ></code
+		  > - 1</code
+		>.</li
+	      ></ul
+	    ></div
+	  ><div class="subs bundled-patterns"
+	  ><p class="caption"
+	    >Bundled Patterns</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v::-62-" class="def"
+		  >(:&gt;)</a
+		  > :: a -&gt; <a href="#" title="BundledPatterns2"
+		  >Vec</a
+		  > n a -&gt; <a href="#" title="BundledPatterns2"
+		  >Vec</a
+		  > (n <a href="#" title="Bug310"
+		  >+</a
+		  > 1) a <span class="fixity"
+		  >infixr 5</span
+		  ><span class="rightedge"
+		  ></span
+		  ></td
+		><td class="doc"
+		><p
+		  >Add an element to the head of a vector.</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >3:&gt;4:&gt;5:&gt;Nil
+</code
+		      ></strong
+		    >&lt;3,4,5&gt;
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let x = 3:&gt;4:&gt;5:&gt;Nil
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t x
+</code
+		      ></strong
+		    >x :: Num a =&gt; Vec 3 a
+</pre
+		  ><p
+		  >Can be used as a pattern:</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let f (x :&gt; y :&gt; _) = x + y
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t f
+</code
+		      ></strong
+		    >f :: Num a =&gt; Vec ((n + 1) + 1) a -&gt; a
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >f (3:&gt;4:&gt;5:&gt;6:&gt;7:&gt;Nil)
+</code
+		      ></strong
+		    >7
+</pre
+		  ><p
+		  >Also in conjunctions with (<code
+		    >:&lt;</code
+		    >):</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let g (a :&gt; b :&gt; (_ :&lt; y :&lt; x)) = a + b +  x + y
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t g
+</code
+		      ></strong
+		    >g :: Num a =&gt; Vec ((((n + 1) + 1) + 1) + 1) a -&gt; a
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >g (1:&gt;2:&gt;3:&gt;4:&gt;5:&gt;Nil)
+</code
+		      ></strong
+		    >12
+</pre
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v:Empty" class="def"
+		  >Empty</a
+		  > :: <a href="#" title="BundledPatterns2"
+		  >Vec</a
+		  > 0 a</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:RTree" class="def"
+	    >RTree</a
+	    > (a :: <a href="#" title="GHC.TypeLits"
+	    >Nat</a
+	    >) b <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Perfect depth binary tree.</p
+	    ><ul
+	    ><li
+	      >Only has elements at the leaf of the tree</li
+	      ><li
+	      >A tree of depth <em
+		>d</em
+		> has <em
+		>2^d</em
+		> elements.</li
+	      ></ul
+	    ></div
+	  ><div class="subs bundled-patterns"
+	  ><p class="caption"
+	    >Bundled Patterns</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v:LR" class="def"
+		  >LR</a
+		  > :: a -&gt; <a href="#" title="BundledPatterns2"
+		  >RTree</a
+		  > 0 a</td
+		><td class="doc"
+		><p
+		  >Leaf of a perfect depth tree</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >LR 1
+</code
+		      ></strong
+		    >1
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let x = LR 1
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t x
+</code
+		      ></strong
+		    >x :: Num a =&gt; RTree 0 a
+</pre
+		  ><p
+		  >Can be used as a pattern:</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let f (LR a) (LR b) = a + b
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t f
+</code
+		      ></strong
+		    >f :: Num a =&gt; RTree 0 a -&gt; RTree 0 a -&gt; a
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >f (LR 1) (LR 2)
+</code
+		      ></strong
+		    >3
+</pre
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v:BR" class="def"
+		  >BR</a
+		  > :: <a href="#" title="BundledPatterns2"
+		  >RTree</a
+		  > d a -&gt; <a href="#" title="BundledPatterns2"
+		  >RTree</a
+		  > d a -&gt; <a href="#" title="BundledPatterns2"
+		  >RTree</a
+		  > (d <a href="#" title="Bug310"
+		  >+</a
+		  > 1) a</td
+		><td class="doc"
+		><p
+		  >Branch of a perfect depth tree</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >BR (LR 1) (LR 2)
+</code
+		      ></strong
+		    >&lt;1,2&gt;
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let x = BR (LR 1) (LR 2)
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t x
+</code
+		      ></strong
+		    >x :: Num a =&gt; RTree 1 a
+</pre
+		  ><p
+		  >Case be used a pattern:</p
+		  ><pre class="screen"
+		  ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >let f (BR (LR a) (LR b)) = LR (a + b)
+</code
+		      ></strong
+		    ><code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >:t f
+</code
+		      ></strong
+		    >f :: Num a =&gt; RTree 1 a -&gt; RTree 0 a
+<code class="prompt"
+		    >&gt;&gt;&gt; </code
+		    ><strong class="userinput"
+		    ><code
+		      >f (BR (LR 1) (LR 2))
+</code
+		      ></strong
+		    >3
+</pre
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/ConstructorArgs.html b/utils/haddock/html-test/ref/ConstructorArgs.html
new file mode 100644
index 0000000000000000000000000000000000000000..ca9bfb8dccfe23fb9fb439d55af35a2971eb7118
--- /dev/null
+++ b/utils/haddock/html-test/ref/ConstructorArgs.html
@@ -0,0 +1,728 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >ConstructorArgs</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>ConstructorArgs</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Foo</a
+	      ><ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >Rec</a
+		  > { <ul class="subs"
+		  ><li
+		    ><a href="#"
+		      >x</a
+		      > :: <a href="#" title="Data.String"
+		      >String</a
+		      ></li
+		    ><li
+		    ><a href="#"
+		      >y</a
+		      > :: <a href="#" title="Data.String"
+		      >String</a
+		      ></li
+		    ></ul
+		  > }</li
+		><li
+		>| <a href="#"
+		  >Baz</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		><li
+		>| <a href="#"
+		  >Boa</a
+		  > !<a href="#" title="Data.Int"
+		  >Int</a
+		  > !<a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		><li
+		>| <a href="#" title="Data.Int"
+		  >Int</a
+		  > <a href="#"
+		  >:|</a
+		  > <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		><li
+		>| <a href="#" title="Data.Int"
+		  >Int</a
+		  > <a href="#"
+		  >:*</a
+		  > <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Boo</a
+	      > <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >Foo</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  > -&gt; <a href="#" title="Data.String"
+		  >String</a
+		  > -&gt; <a href="#" title="ConstructorArgs"
+		  >Boo</a
+		  ></li
+		><li
+		><a href="#"
+		  >Foa</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  > -&gt; <a href="#" title="ConstructorArgs"
+		  >Boo</a
+		  ></li
+		><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >Fo</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  > -&gt; <a href="#" title="Data.String"
+		  >String</a
+		  > -&gt; <a href="#" title="ConstructorArgs"
+		  >Boo</a
+		  ></li
+		><li
+		><span class="keyword"
+		  >pattern</span
+		  > <a href="#"
+		  >Fo'</a
+		  > :: <a href="#" title="ConstructorArgs"
+		  >Boo</a
+		  ></li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >Bo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; <a href="#" title="Data.String"
+	      >String</a
+	      > -&gt; <a href="#" title="ConstructorArgs"
+	      >Boo</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >Bo'</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; <a href="#" title="Data.String"
+	      >String</a
+	      > -&gt; <a href="#" title="ConstructorArgs"
+	      >Boo</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <span class="fixity"
+	    >infixr 1</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Rec" class="def"
+		  >Rec</a
+		  ></td
+		><td class="doc"
+		><p
+		  >doc on a record</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:x" class="def"
+			  >x</a
+			  > :: <a href="#" title="Data.String"
+			  >String</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >doc on the <code
+			    ><a href="#" title="Data.String"
+			      >String</a
+			      ></code
+			    > field of <code
+			    ><a href="#" title="ConstructorArgs"
+			      >Rec</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:y" class="def"
+			  >y</a
+			  > :: <a href="#" title="Data.String"
+			  >String</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >doc on the <code
+			    ><a href="#" title="Data.String"
+			      >String</a
+			      ></code
+			    > field of <code
+			    ><a href="#" title="ConstructorArgs"
+			      >Rec</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Baz" class="def"
+		  >Baz</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > <a href="#" title="Data.String"
+		  >String</a
+		  ></td
+		><td class="doc"
+		><p
+		  >old prefix doc style</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Boa" class="def"
+		  >Boa</a
+		  > <span class="fixity"
+		  >infixr 2</span
+		  ><span class="rightedge"
+		  ></span
+		  ></td
+		><td class="doc"
+		><p
+		  >doc on the <code
+		    ><a href="#" title="ConstructorArgs"
+		      >Boa</a
+		      ></code
+		    > constrictor</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			>!<a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >doc on the <code
+			    ><a href="#" title="Data.Int"
+			      >Int</a
+			      ></code
+			    > field of <code
+			    ><a href="#" title="ConstructorArgs"
+			      >Boa</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>!<a href="#" title="Data.String"
+			  >String</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >doc on the <code
+			    ><a href="#" title="Data.String"
+			      >String</a
+			      ></code
+			    > field of <code
+			    ><a href="#" title="ConstructorArgs"
+			      >Boa</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a href="#" title="Data.Int"
+		  >Int</a
+		  > <a id="v::-124-" class="def"
+		  >:|</a
+		  > <a href="#" title="Data.String"
+		  >String</a
+		  ></td
+		><td class="doc"
+		><p
+		  >old infix doc style</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v::-42-" class="def"
+		  >(:*)</a
+		  > <span class="fixity"
+		  >infixr 3</span
+		  ><span class="rightedge"
+		  ></span
+		  ></td
+		><td class="doc"
+		><p
+		  >doc on the <code
+		    ><a href="#" title="ConstructorArgs"
+		      >:*</a
+		      ></code
+		    > constructor</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >doc on the <code
+			    ><a href="#" title="Data.Int"
+			      >Int</a
+			      ></code
+			    > field of the <code
+			    ><a href="#" title="ConstructorArgs"
+			      >:*</a
+			      ></code
+			    > constructor</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a href="#" title="Data.String"
+			  >String</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >doc on the <code
+			    ><a href="#" title="Data.String"
+			      >String</a
+			      ></code
+			    > field of the <code
+			    ><a href="#" title="ConstructorArgs"
+			      >:*</a
+			      ></code
+			    > constructor</p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Boo" class="def"
+	    >Boo</a
+	    > <span class="keyword"
+	    >where</span
+	    > <span class="fixity"
+	    >infixr 4</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Foo" class="def"
+		  >Foo</a
+		  > <span class="fixity"
+		  >infixr 1</span
+		  ><span class="rightedge"
+		  ></span
+		  ></td
+		><td class="doc"
+		><p
+		  >Info about a <code
+		    ><a href="#" title="ConstructorArgs"
+		      >Foo</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			>:: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  ><code
+			    ><a href="#" title="Data.Int"
+			      >Int</a
+			      ></code
+			    > field of <code
+			    ><a href="#" title="ConstructorArgs"
+			      >Foo</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>-&gt; <a href="#" title="Data.String"
+			  >String</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  ><code
+			    ><a href="#" title="Data.String"
+			      >String</a
+			      ></code
+			    > field of <code
+			    ><a href="#" title="ConstructorArgs"
+			      >Foo</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>-&gt; <a href="#" title="ConstructorArgs"
+			  >Boo</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >Make a <code
+			    ><a href="#" title="ConstructorArgs"
+			      >Boo</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Foa" class="def"
+		  >Foa</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  > -&gt; <a href="#" title="ConstructorArgs"
+		  >Boo</a
+		  ></td
+		><td class="doc"
+		><p
+		  >no argument docs GADT</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs bundled-patterns"
+	  ><p class="caption"
+	    >Bundled Patterns</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v:Fo" class="def"
+		  >Fo</a
+		  > <span class="fixity"
+		  >infixr 5</span
+		  ><span class="rightedge"
+		  ></span
+		  ></td
+		><td class="doc"
+		><p
+		  >Info about bundled <code
+		    ><a href="#" title="ConstructorArgs"
+		      >Fo</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			>:: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >an <code
+			    ><a href="#" title="Data.Int"
+			      >Int</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>-&gt; <a href="#" title="Data.String"
+			  >String</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >a <code
+			    ><a href="#" title="Data.String"
+			      >String</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>-&gt; <a href="#" title="ConstructorArgs"
+			  >Boo</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >a <code
+			    ><a href="#" title="ConstructorArgs"
+			      >Boo</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><span class="keyword"
+		  >pattern</span
+		  > <a id="v:Fo-39-" class="def"
+		  >Fo'</a
+		  > :: <a href="#" title="ConstructorArgs"
+		  >Boo</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Bundled and no argument docs</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:Bo" class="def"
+	    >Bo</a
+	    > <span class="fixity"
+	    >infixr 6</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc"
+		><p
+		  >an <code
+		    ><a href="#" title="Data.Int"
+		      >Int</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="Data.String"
+		  >String</a
+		  ></td
+		><td class="doc"
+		><p
+		  >a <code
+		    ><a href="#" title="Data.String"
+		      >String</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="ConstructorArgs"
+		  >Boo</a
+		  ></td
+		><td class="doc"
+		><p
+		  >a <code
+		    ><a href="#" title="ConstructorArgs"
+		      >Boo</a
+		      ></code
+		    > pattern</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="doc"
+	  ><p
+	    >Info about not-bundled <code
+	      ><a href="#" title="ConstructorArgs"
+		>Bo</a
+		></code
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:Bo-39-" class="def"
+	    >Bo'</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > -&gt; <a href="#" title="Data.String"
+	    >String</a
+	    > -&gt; <a href="#" title="ConstructorArgs"
+	    >Boo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Not bundled and no argument docs</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/ConstructorPatternExport.html b/utils/haddock/html-test/ref/ConstructorPatternExport.html
new file mode 100644
index 0000000000000000000000000000000000000000..218bf206f3239f4f590569385d7873e89b6c2365
--- /dev/null
+++ b/utils/haddock/html-test/ref/ConstructorPatternExport.html
@@ -0,0 +1,124 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >ConstructorPatternExport</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>ConstructorPatternExport</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:FooCons" class="def"
+	    >FooCons</a
+	    > :: <a href="#" title="Data.String"
+	    >String</a
+	    > -&gt; a -&gt; Foo a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:MyRecCons" class="def"
+	    >MyRecCons</a
+	    > :: <a href="#" title="Data.Bool"
+	    >Bool</a
+	    > -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > -&gt; MyRec <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v::-43-" class="def"
+	    >(:+)</a
+	    > :: <a href="#" title="Data.String"
+	    >String</a
+	    > -&gt; a -&gt; MyInfix a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:BlubCons" class="def"
+	    >BlubCons</a
+	    > :: () =&gt; <a href="#" title="Prelude"
+	    >Show</a
+	    > b =&gt; b -&gt; Blub <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:MyGADTCons" class="def"
+	    >MyGADTCons</a
+	    > :: a1 -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > -&gt; MyGADT (<a href="#" title="Data.Maybe"
+	    >Maybe</a
+	    > <a href="#" title="Data.String"
+	    >String</a
+	    >) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/CrossPackageDocs.html b/utils/haddock/html-test/ref/CrossPackageDocs.html
new file mode 100644
index 0000000000000000000000000000000000000000..5dd20c5213cbe373a26780fbdbe0273171a45938
--- /dev/null
+++ b/utils/haddock/html-test/ref/CrossPackageDocs.html
@@ -0,0 +1,287 @@
+<!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
+    >CrossPackageDocs</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_CrossPackageDocs.html");};
+//]]>
+</script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+    >&nbsp;</span
+    ><ul class="links" id="page-menu"
+      ><li
+	><a href=""
+	  >Contents</a
+	  ></li
+	><li
+	><a href=""
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>CrossPackageDocs</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=""
+	    >map</a
+	    > ::  (a -&gt; b) -&gt; [a] -&gt; [b]</li
+	  ><li class="src short"
+	  ><span class="keyword"
+	    >class</span
+	    > <a href=""
+	    >IsString</a
+	    > a <span class="keyword"
+	    >where</span
+	    ><ul class="subs"
+	    ><li
+	      ><a href=""
+		>fromString</a
+		> :: <a href=""
+		>String</a
+		> -&gt; a</li
+	      ></ul
+	    ></li
+	  ><li class="src short"
+	  ><a href=""
+	    >runInteractiveProcess</a
+	    > :: <a href=""
+	    >FilePath</a
+	    > -&gt; [<a href=""
+	    >String</a
+	    >] -&gt; <a href=""
+	    >Maybe</a
+	    > <a href=""
+	    >FilePath</a
+	    > -&gt; <a href=""
+	    >Maybe</a
+	    > [(<a href=""
+	    >String</a
+	    >, <a href=""
+	    >String</a
+	    >)] -&gt; <a href=""
+	    >IO</a
+	    > (<a href=""
+	    >Handle</a
+	    >, <a href=""
+	    >Handle</a
+	    >, <a href=""
+	    >Handle</a
+	    >, <a href=""
+	    >ProcessHandle</a
+	    >)</li
+	  ></ul
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a name="v:map" class="def"
+	    >map</a
+	    > ::  (a -&gt; b) -&gt; [a] -&gt; [b]</p
+	  ><div class="doc"
+	  ><p
+	    ><code
+	      ><a href=""
+		>map</a
+		></code
+	      > <code
+	      >f xs</code
+	      > is the list obtained by applying <code
+	      >f</code
+	      > to each element
+ of <code
+	      >xs</code
+	      >, i.e.,</p
+	    ><pre
+	    > map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
+ map f [x1, x2, ...] == [f x1, f x2, ...]</pre
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a name="t:IsString" class="def"
+	    >IsString</a
+	    > a <span class="keyword"
+	    >where</span
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Class for string-like datastructures; used by the overloaded string
+   extension (-XOverloadedStrings in GHC).</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a name="v:fromString" class="def"
+	      >fromString</a
+	      > :: <a href=""
+	      >String</a
+	      > -&gt; a</p
+	    ></div
+	  ><div class="subs instances"
+	  ><p id="control.i:IsString" class="caption collapser" onclick="toggleSection('i:IsString')"
+	    >Instances</p
+	    ><div id="section.i:IsString" class="show"
+	    ><table
+	      ><tr
+		><td class="src"
+		  ><a href=""
+		    >IsString</a
+		    > [<a href=""
+		    >Char</a
+		    >]</td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		></table
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a name="v:runInteractiveProcess" class="def"
+	    >runInteractiveProcess</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: <a href=""
+		  >FilePath</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Filename of the executable (see <code
+		    ><a href=""
+		      >proc</a
+		      ></code
+		    > for details)</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; [<a href=""
+		  >String</a
+		  >]</td
+		><td class="doc"
+		><p
+		  >Arguments to pass to the executable</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href=""
+		  >Maybe</a
+		  > <a href=""
+		  >FilePath</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Optional path to the working directory</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href=""
+		  >Maybe</a
+		  > [(<a href=""
+		  >String</a
+		  >, <a href=""
+		  >String</a
+		  >)]</td
+		><td class="doc"
+		><p
+		  >Optional environment (otherwise inherit)</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href=""
+		  >IO</a
+		  > (<a href=""
+		  >Handle</a
+		  >, <a href=""
+		  >Handle</a
+		  >, <a href=""
+		  >Handle</a
+		  >, <a href=""
+		  >ProcessHandle</a
+		  >)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="doc"
+	  ><p
+	    >Runs a raw command, and returns <code
+	      ><a href=""
+		>Handle</a
+		></code
+	      >s that may be used to communicate
+     with the process via its <code
+	      >stdin</code
+	      >, <code
+	      >stdout</code
+	      > and <code
+	      >stderr</code
+	      > respectively.</p
+	    ><p
+	    >For example, to start a process and feed a string to its stdin:</p
+	    ><pre
+	    >   (inp,out,err,pid) &lt;- runInteractiveProcess &quot;...&quot;
+   forkIO (hPutStr inp str)</pre
+	    ><p
+	    >The <code
+	      ><a href=""
+		>Handle</a
+		></code
+	      >s are initially in binary mode; if you need them to be
+    in text mode then use <code
+	      ><a href=""
+		>hSetBinaryMode</a
+		></code
+	      >.</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ><div id="footer"
+    ><p
+      >Produced by <a href=""
+	>Haddock</a
+	> version 2.15.0</p
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DefaultAssociatedTypes.html b/utils/haddock/html-test/ref/DefaultAssociatedTypes.html
new file mode 100644
index 0000000000000000000000000000000000000000..470f719ec71bb5f5683b1aa519e53eb6329ca129
--- /dev/null
+++ b/utils/haddock/html-test/ref/DefaultAssociatedTypes.html
@@ -0,0 +1,164 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DefaultAssociatedTypes</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DefaultAssociatedTypes</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >Foo</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><span class="keyword"
+		  >type</span
+		  > <a href="#"
+		  >Qux</a
+		  > a</li
+		><li
+		><a href="#"
+		  >bar</a
+		  > :: a -&gt; <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		><li
+		><a href="#"
+		  >baz</a
+		  > :: a -&gt; <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Documentation for Foo.</p
+	    ></div
+	  ><div class="subs associated-types"
+	  ><p class="caption"
+	    >Associated Types</p
+	    ><p class="src"
+	    ><span class="keyword"
+	      >type</span
+	      > <a id="t:Qux" class="def"
+	      >Qux</a
+	      > a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Doc for Qux</p
+	      ></div
+	    > <div class="subs default"
+	    ><p class="caption"
+	      ></p
+	      ><p class="src"
+	      ><span class="keyword"
+		>type</span
+		> <a href="#" title="DefaultAssociatedTypes"
+		>Qux</a
+		> a = [a]</p
+	      ></div
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:bar" class="def"
+	      >bar</a
+	      > :: a -&gt; <a href="#" title="Data.String"
+	      >String</a
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Documentation for bar and baz.</p
+	      ></div
+	    ><p class="src"
+	    ><a id="v:baz" class="def"
+	      >baz</a
+	      > :: a -&gt; <a href="#" title="Data.String"
+	      >String</a
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Documentation for bar and baz.</p
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DefaultSignatures.html b/utils/haddock/html-test/ref/DefaultSignatures.html
new file mode 100644
index 0000000000000000000000000000000000000000..6c46355076b60449e2a9b0af7d30977314a4ed6f
--- /dev/null
+++ b/utils/haddock/html-test/ref/DefaultSignatures.html
@@ -0,0 +1,198 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DefaultSignatures</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DefaultSignatures</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >Foo</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >bar</a
+		  > :: a -&gt; <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		><li
+		><a href="#"
+		  >baz</a
+		  > :: a -&gt; <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		><li
+		><a href="#"
+		  >baz'</a
+		  > :: <a href="#" title="Data.String"
+		  >String</a
+		  > -&gt; a</li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Documentation for Foo.</p
+	    ></div
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    ><a href="#" title="DefaultSignatures"
+	      >baz</a
+	      ></p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:bar" class="def"
+	      >bar</a
+	      > :: a -&gt; <a href="#" title="Data.String"
+	      >String</a
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Documentation for bar and baz.</p
+	      ></div
+	    > <div class="subs default"
+	    ><p class="caption"
+	      ></p
+	      ><p class="src"
+	      ><span class="keyword"
+		>default</span
+		> <a id="v:bar" class="def"
+		>bar</a
+		> :: <a href="#" title="Prelude"
+		>Show</a
+		> a =&gt; a -&gt; <a href="#" title="Data.String"
+		>String</a
+		> <a href="#" class="selflink"
+		>#</a
+		></p
+	      ><div class="doc"
+	      ><p
+		>Documentation for the default signature of bar.</p
+		></div
+	      ></div
+	    ><p class="src"
+	    ><a id="v:baz" class="def"
+	      >baz</a
+	      > :: a -&gt; <a href="#" title="Data.String"
+	      >String</a
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Documentation for bar and baz.</p
+	      ></div
+	    ><p class="src"
+	    ><a id="v:baz-39-" class="def"
+	      >baz'</a
+	      > :: <a href="#" title="Data.String"
+	      >String</a
+	      > -&gt; a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Documentation for baz'.</p
+	      ></div
+	    > <div class="subs default"
+	    ><p class="caption"
+	      ></p
+	      ><p class="src"
+	      ><span class="keyword"
+		>default</span
+		> <a id="v:baz-39-" class="def"
+		>baz'</a
+		> :: <a href="#" title="Prelude"
+		>Read</a
+		> a =&gt; <a href="#" title="Data.String"
+		>String</a
+		> -&gt; a <a href="#" class="selflink"
+		>#</a
+		></p
+	      ><div class="doc"
+	      ><p
+		>Documentation for the default signature of baz'.</p
+		></div
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedClass.html b/utils/haddock/html-test/ref/DeprecatedClass.html
new file mode 100644
index 0000000000000000000000000000000000000000..ff3be26d90f7217f62023ab03af0da3b22e79875
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedClass.html
@@ -0,0 +1,166 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedClass</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedClass</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >SomeClass</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >foo</a
+		  > :: a -&gt; a</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >SomeOtherClass</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >bar</a
+		  > :: a -&gt; a</li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:SomeClass" class="def"
+	    >SomeClass</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: SomeClass</p
+	      ></div
+	    ><p
+	    >some class</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:foo" class="def"
+	      >foo</a
+	      > :: a -&gt; a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><div class="warning"
+	      ><p
+		>Deprecated: foo</p
+		></div
+	      ><p
+	      >documentation for foo</p
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:SomeOtherClass" class="def"
+	    >SomeOtherClass</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: SomeOtherClass</p
+	      ></div
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:bar" class="def"
+	      >bar</a
+	      > :: a -&gt; a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><div class="warning"
+	      ><p
+		>Deprecated: bar</p
+		></div
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedData.html b/utils/haddock/html-test/ref/DeprecatedData.html
new file mode 100644
index 0000000000000000000000000000000000000000..3ca9982078525378236142bbad73291029e30b7a
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedData.html
@@ -0,0 +1,196 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedData</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedData</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Foo</a
+	      ><ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >Foo</a
+		  ></li
+		><li
+		>| <a href="#"
+		  >Bar</a
+		  ></li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >One</a
+	      ><ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >One</a
+		  ></li
+		><li
+		>| <a href="#"
+		  >Two</a
+		  ></li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: Foo</p
+	      ></div
+	    ><p
+	    >type Foo</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Foo" class="def"
+		  >Foo</a
+		  ></td
+		><td class="doc"
+		><div class="warning"
+		  ><p
+		    >Deprecated: Foo</p
+		    ></div
+		  ><p
+		  >constructor Foo</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Bar" class="def"
+		  >Bar</a
+		  ></td
+		><td class="doc"
+		><div class="warning"
+		  ><p
+		    >Deprecated: Bar</p
+		    ></div
+		  ><p
+		  >constructor Bar</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:One" class="def"
+	    >One</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: One</p
+	      ></div
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:One" class="def"
+		  >One</a
+		  ></td
+		><td class="doc"
+		><div class="warning"
+		  ><p
+		    >Deprecated: One</p
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Two" class="def"
+		  >Two</a
+		  ></td
+		><td class="doc"
+		><div class="warning"
+		  ><p
+		    >Deprecated: Two</p
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedFunction.html b/utils/haddock/html-test/ref/DeprecatedFunction.html
new file mode 100644
index 0000000000000000000000000000000000000000..104a67f1b574ad5ac043fd1f75e853f97c0b216f
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedFunction.html
@@ -0,0 +1,114 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedFunction</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedFunction</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >bar</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: use <code
+		><a href="#" title="DeprecatedFunction"
+		  >bar</a
+		  ></code
+		> instead</p
+	      ></div
+	    ><p
+	    >some documentation for foo</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:bar" class="def"
+	    >bar</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >some documentation for bar</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedFunction2.html b/utils/haddock/html-test/ref/DeprecatedFunction2.html
new file mode 100644
index 0000000000000000000000000000000000000000..023e470114f33d6906ecbd7258de049d3fd85390
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedFunction2.html
@@ -0,0 +1,88 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedFunction2</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedFunction2</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: use bar instead</p
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedFunction3.html b/utils/haddock/html-test/ref/DeprecatedFunction3.html
new file mode 100644
index 0000000000000000000000000000000000000000..3666bcbc5af2a592e473794d3b4a32f1784da081
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedFunction3.html
@@ -0,0 +1,88 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedFunction3</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedFunction3</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Prelude"
+	      >Integer</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: use bar instead</p
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedModule.html b/utils/haddock/html-test/ref/DeprecatedModule.html
new file mode 100644
index 0000000000000000000000000000000000000000..9a0a058b22636e6d53d1ddf703ae7d9431048472
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedModule.html
@@ -0,0 +1,84 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedModule</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedModule</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><div class="warning"
+	  ><p
+	    >Deprecated: Use <a href="#"
+	      >Foo</a
+	      > instead</p
+	    ></div
+	  ><p
+	  >Documentation for <a href="#"
+	    >DeprecatedModule</a
+	    >.</p
+	  ></div
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedModule2.html b/utils/haddock/html-test/ref/DeprecatedModule2.html
new file mode 100644
index 0000000000000000000000000000000000000000..c179dfc1cd33cbc943e54526ce688c0e47cf47df
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedModule2.html
@@ -0,0 +1,78 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedModule2</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedModule2</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><div class="warning"
+	  ><p
+	    >Deprecated: Use Foo instead</p
+	    ></div
+	  ></div
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedNewtype.html b/utils/haddock/html-test/ref/DeprecatedNewtype.html
new file mode 100644
index 0000000000000000000000000000000000000000..7e423fc9b56c57a3d1cee597958efbfddcb56640
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedNewtype.html
@@ -0,0 +1,162 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedNewtype</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedNewtype</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >newtype</span
+	      > <a href="#"
+	      >SomeNewType</a
+	      > = <a href="#"
+	      >SomeNewTypeConst</a
+	      > <a href="#" title="Data.String"
+	      >String</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >newtype</span
+	      > <a href="#"
+	      >SomeOtherNewType</a
+	      > = <a href="#"
+	      >SomeOtherNewTypeConst</a
+	      > <a href="#" title="Data.String"
+	      >String</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:SomeNewType" class="def"
+	    >SomeNewType</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: SomeNewType</p
+	      ></div
+	    ><p
+	    >some documentation</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:SomeNewTypeConst" class="def"
+		  >SomeNewTypeConst</a
+		  > <a href="#" title="Data.String"
+		  >String</a
+		  ></td
+		><td class="doc"
+		><div class="warning"
+		  ><p
+		    >Deprecated: SomeNewTypeConst</p
+		    ></div
+		  ><p
+		  >constructor docu </p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:SomeOtherNewType" class="def"
+	    >SomeOtherNewType</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: SomeOtherNewType</p
+	      ></div
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:SomeOtherNewTypeConst" class="def"
+		  >SomeOtherNewTypeConst</a
+		  > <a href="#" title="Data.String"
+		  >String</a
+		  ></td
+		><td class="doc"
+		><div class="warning"
+		  ><p
+		    >Deprecated: SomeOtherNewTypeConst</p
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedReExport.html b/utils/haddock/html-test/ref/DeprecatedReExport.html
new file mode 100644
index 0000000000000000000000000000000000000000..672f28aeeda987f6d1d055e7dc01e6cc0584864e
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedReExport.html
@@ -0,0 +1,135 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedReExport</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedReExport</p
+	></div
+      ><div id="table-of-contents"
+      ><div id="contents-list"
+	><p class="caption" onclick="window.scrollTo(0,0)"
+	  >Contents</p
+	  ><ul
+	  ><li
+	    ><a href="#"
+	      >Re-exported from an other module</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Re-exported from an other package</a
+	      ></li
+	    ></ul
+	  ></div
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >What is tested here:</p
+	  ><ul
+	  ><li
+	    >Deprecation messages are shown for re-exported items.</li
+	    ></ul
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><a href="#" id="g:1"
+	><h1
+	  >Re-exported from an other module</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: use <code
+		><a href="#" title="DeprecatedFunction"
+		  >bar</a
+		  ></code
+		> instead</p
+	      ></div
+	    ><p
+	    >some documentation for foo</p
+	    ></div
+	  ></div
+	><a href="#" id="g:2"
+	><h1
+	  >Re-exported from an other package</h1
+	  ></a
+	><div class="doc"
+	><p
+	  >Not yet working, see <a href="#"
+	    >http://trac.haskell.org/haddock/ticket/223</a
+	    >
+ , isEmptyChan</p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedRecord.html b/utils/haddock/html-test/ref/DeprecatedRecord.html
new file mode 100644
index 0000000000000000000000000000000000000000..37dceddd13fd15aac6cc12c6d0c9c208cd9aa01b
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedRecord.html
@@ -0,0 +1,154 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedRecord</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedRecord</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Foo</a
+	      > = <a href="#"
+	      >Foo</a
+	      > {<ul class="subs"
+	      ><li
+		><a href="#"
+		  >fooName</a
+		  > :: <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		><li
+		><a href="#"
+		  >fooValue</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  ></li
+		></ul
+	      >}</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >type Foo</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Foo" class="def"
+		  >Foo</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:fooName" class="def"
+			  >fooName</a
+			  > :: <a href="#" title="Data.String"
+			  >String</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >some name</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:fooValue" class="def"
+			  >fooValue</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><div class="warning"
+			  ><p
+			    >Deprecated: do not use this</p
+			    ></div
+			  ><p
+			  >some value</p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedTypeFamily.html b/utils/haddock/html-test/ref/DeprecatedTypeFamily.html
new file mode 100644
index 0000000000000000000000000000000000000000..e923dbd225797a744a2989e87055a8bdc8e5f2ba
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedTypeFamily.html
@@ -0,0 +1,128 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedTypeFamily</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedTypeFamily</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data family</span
+	      > <a href="#"
+	      >SomeTypeFamily</a
+	      > k :: <a href="#" title="Data.Kind"
+	      >Type</a
+	      > -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data family</span
+	      > <a href="#"
+	      >SomeOtherTypeFamily</a
+	      > k :: <a href="#" title="Data.Kind"
+	      >Type</a
+	      > -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:SomeTypeFamily" class="def"
+	    >SomeTypeFamily</a
+	    > k :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: SomeTypeFamily</p
+	      ></div
+	    ><p
+	    >some documentation</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:SomeOtherTypeFamily" class="def"
+	    >SomeOtherTypeFamily</a
+	    > k :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: SomeOtherTypeFamily</p
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DeprecatedTypeSynonym.html b/utils/haddock/html-test/ref/DeprecatedTypeSynonym.html
new file mode 100644
index 0000000000000000000000000000000000000000..81c7d78eb0fd1501e4eb5ed64264900c1f36e69c
--- /dev/null
+++ b/utils/haddock/html-test/ref/DeprecatedTypeSynonym.html
@@ -0,0 +1,120 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DeprecatedTypeSynonym</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DeprecatedTypeSynonym</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >type</span
+	      > <a href="#"
+	      >TypeSyn</a
+	      > = <a href="#" title="Data.String"
+	      >String</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >type</span
+	      > <a href="#"
+	      >OtherTypeSyn</a
+	      > = <a href="#" title="Data.String"
+	      >String</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type</span
+	    > <a id="t:TypeSyn" class="def"
+	    >TypeSyn</a
+	    > = <a href="#" title="Data.String"
+	    >String</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: TypeSyn</p
+	      ></div
+	    ><p
+	    >some documentation</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type</span
+	    > <a id="t:OtherTypeSyn" class="def"
+	    >OtherTypeSyn</a
+	    > = <a href="#" title="Data.String"
+	    >String</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><div class="warning"
+	    ><p
+	      >Deprecated: OtherTypeSyn</p
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/DuplicateRecordFields.html b/utils/haddock/html-test/ref/DuplicateRecordFields.html
new file mode 100644
index 0000000000000000000000000000000000000000..7017df6a3583b9d512f2e298e506333d4aa64068
--- /dev/null
+++ b/utils/haddock/html-test/ref/DuplicateRecordFields.html
@@ -0,0 +1,164 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >DuplicateRecordFields</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>DuplicateRecordFields</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:RawReplay" class="def"
+	    >RawReplay</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:RawReplay" class="def"
+		  >RawReplay</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:headerSize" class="def"
+			  >headerSize</a
+			  > :: Int</dfn
+			><div class="doc"
+			><p
+			  >The byte size of the first section.</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:headerCRC" class="def"
+			  >headerCRC</a
+			  > :: Int</dfn
+			><div class="doc"
+			><p
+			  >The CRC of the first section.</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:header" class="def"
+			  >header</a
+			  > :: Int</dfn
+			><div class="doc"
+			><p
+			  >The first section.</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:contentSize" class="def"
+			  >contentSize</a
+			  > :: Int</dfn
+			><div class="doc"
+			><p
+			  >The byte size of the second section.</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:contentCRC" class="def"
+			  >contentCRC</a
+			  > :: Int</dfn
+			><div class="doc"
+			><p
+			  >The CRC of the second section.</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:content" class="def"
+			  >content</a
+			  > :: Int</dfn
+			><div class="doc"
+			><p
+			  >The second section.</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:footer" class="def"
+			  >footer</a
+			  > :: Int</dfn
+			><div class="doc"
+			><p
+			  >Arbitrary data after the second section. In replays generated by
+ Rocket League, this is always empty. However it is not technically
+ invalid to put something here.</p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Examples.html b/utils/haddock/html-test/ref/Examples.html
new file mode 100644
index 0000000000000000000000000000000000000000..b397e0796fbf1335debe1b26dcacbfb73e7c4766
--- /dev/null
+++ b/utils/haddock/html-test/ref/Examples.html
@@ -0,0 +1,179 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Examples</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Examples</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >fib</a
+	      > :: <a href="#" title="Prelude"
+	      >Integer</a
+	      > -&gt; <a href="#" title="Prelude"
+	      >Integer</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:fib" class="def"
+	    >fib</a
+	    > :: <a href="#" title="Prelude"
+	    >Integer</a
+	    > -&gt; <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Fibonacci number of given <code
+	      ><a href="#" title="Prelude"
+		>Integer</a
+		></code
+	      >.</p
+	    ><p
+	    >Examples:</p
+	    ><pre class="screen"
+	    ><code class="prompt"
+	      >&gt;&gt;&gt; </code
+	      ><strong class="userinput"
+	      ><code
+		>fib 5
+</code
+		></strong
+	      >5
+<code class="prompt"
+	      >&gt;&gt;&gt; </code
+	      ><strong class="userinput"
+	      ><code
+		>fib 10
+</code
+		></strong
+	      >55
+</pre
+	    ><pre class="screen"
+	    ><code class="prompt"
+	      >&gt;&gt;&gt; </code
+	      ><strong class="userinput"
+	      ><code
+		>fib 10
+</code
+		></strong
+	      >55
+</pre
+	    ><p
+	    >One more Example:</p
+	    ><pre class="screen"
+	    ><code class="prompt"
+	      >&gt;&gt;&gt; </code
+	      ><strong class="userinput"
+	      ><code
+		>fib 5
+</code
+		></strong
+	      >5
+</pre
+	    ><p
+	    >One more Example:</p
+	    ><pre class="screen"
+	    ><code class="prompt"
+	      >&gt;&gt;&gt; </code
+	      ><strong class="userinput"
+	      ><code
+		>fib 5
+</code
+		></strong
+	      >5
+</pre
+	    ><p
+	    >Example with an import:</p
+	    ><pre class="screen"
+	    ><code class="prompt"
+	      >&gt;&gt;&gt; </code
+	      ><strong class="userinput"
+	      ><code
+		>import Data.Char
+</code
+		></strong
+	      ><code class="prompt"
+	      >&gt;&gt;&gt; </code
+	      ><strong class="userinput"
+	      ><code
+		>isSpace 'a'
+</code
+		></strong
+	      >False
+</pre
+	    ><pre class="screen"
+	    ><code class="prompt"
+	      >&gt;&gt;&gt; </code
+	      ><strong class="userinput"
+	      ><code
+		>putStrLn &quot;foo\n\nbar&quot;
+</code
+		></strong
+	      >foo
+
+bar
+</pre
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/ExportSince1.html b/utils/haddock/html-test/ref/ExportSince1.html
new file mode 100644
index 0000000000000000000000000000000000000000..10d30d6de8e3ebf090cc934c9d45e91c82e4b08b
--- /dev/null
+++ b/utils/haddock/html-test/ref/ExportSince1.html
@@ -0,0 +1,216 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >ExportSince1</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>ExportSince1</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >hello1</a
+	      > :: <a href="#" title="Data.String"
+	      >String</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >hello2</a
+	      > :: <a href="#" title="Data.String"
+	      >String</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >HelloTy</a
+	      > = <a href="#"
+	      >HelloTy</a
+	      > {<ul class="subs"
+	      ><li
+		><a href="#"
+		  >field1</a
+		  > :: <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		></ul
+	      >}</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >HelloClass</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >method1</a
+		  > :: a -&gt; <a href="#" title="Data.String"
+		  >String</a
+		  ></li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:hello1" class="def"
+	    >hello1</a
+	    > :: <a href="#" title="Data.String"
+	    >String</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><em
+	      >Since: 1.0</em
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:hello2" class="def"
+	    >hello2</a
+	    > :: <a href="#" title="Data.String"
+	    >String</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><em
+	      >Since: 1.0</em
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:HelloTy" class="def"
+	    >HelloTy</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><em
+	      >Since: 1.0</em
+	      ></p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:HelloTy" class="def"
+		  >HelloTy</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:field1" class="def"
+			  >field1</a
+			  > :: <a href="#" title="Data.String"
+			  >String</a
+			  ></dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:HelloClass" class="def"
+	    >HelloClass</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><em
+	      >Since: 1.0</em
+	      ></p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:method1" class="def"
+	      >method1</a
+	      > :: a -&gt; <a href="#" title="Data.String"
+	      >String</a
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/ExportSince2.html b/utils/haddock/html-test/ref/ExportSince2.html
new file mode 100644
index 0000000000000000000000000000000000000000..29207f24c9d0bbf9217ea906adee2afc32980a19
--- /dev/null
+++ b/utils/haddock/html-test/ref/ExportSince2.html
@@ -0,0 +1,156 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >ExportSince2</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>ExportSince2</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >hello1</a
+	      > :: <a href="#" title="Data.String"
+	      >String</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >hello2</a
+	      > :: <a href="#" title="Data.String"
+	      >String</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >HelloTy</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >HelloClass</a
+	      > a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:hello1" class="def"
+	    >hello1</a
+	    > :: <a href="#" title="Data.String"
+	    >String</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><em
+	      >Since: 2.0</em
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:hello2" class="def"
+	    >hello2</a
+	    > :: <a href="#" title="Data.String"
+	    >String</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><em
+	      >Since: 2.0</em
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:HelloTy" class="def"
+	    >HelloTy</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><em
+	      >Since: 2.0</em
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:HelloClass" class="def"
+	    >HelloClass</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><em
+	      >Since: 2.0</em
+	      ></p
+	    ></div
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    ><a href="#" title="ExportSince1"
+	      >method1</a
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Extensions.html b/utils/haddock/html-test/ref/Extensions.html
new file mode 100644
index 0000000000000000000000000000000000000000..7be5fd80ac35099ec82dcfeb65b1f85518cb6b8b
--- /dev/null
+++ b/utils/haddock/html-test/ref/Extensions.html
@@ -0,0 +1,88 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Extensions</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Extensions</th
+	    ><td
+	    >ExplicitForAll</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Extensions</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foobar</a
+	      > :: t</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foobar" class="def"
+	    >foobar</a
+	    > :: t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Bar</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/FunArgs.html b/utils/haddock/html-test/ref/FunArgs.html
new file mode 100644
index 0000000000000000000000000000000000000000..a0481b46ed47c69c7993c129e0f04e5234404856
--- /dev/null
+++ b/utils/haddock/html-test/ref/FunArgs.html
@@ -0,0 +1,292 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >FunArgs</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>FunArgs</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: <a href="#" title="Data.Ord"
+		  >Ord</a
+		  > a</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>=&gt; <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc"
+		><p
+		  >First argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; a</td
+		><td class="doc"
+		><p
+		  >Second argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="Data.Bool"
+		  >Bool</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Third argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; (a -&gt; a)</td
+		><td class="doc"
+		><p
+		  >Fourth argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; ()</td
+		><td class="doc"
+		><p
+		  >Result</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:g" class="def"
+	    >g</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: a</td
+		><td class="doc"
+		><p
+		  >First argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; b</td
+		><td class="doc"
+		><p
+		  >Second argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; c</td
+		><td class="doc"
+		><p
+		  >Third argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; d</td
+		><td class="doc"
+		><p
+		  >Result</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:h" class="def"
+	    >h</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: a</td
+		><td class="doc"
+		><p
+		  >First argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; b</td
+		><td class="doc"
+		><p
+		  >Second argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; c</td
+		><td class="doc"
+		><p
+		  >Third argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <span class="keyword"
+		  >forall</span
+		  > d. d</td
+		><td class="doc"
+		><p
+		  >Result</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:i" class="def"
+	    >i</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: <span class="keyword"
+		  >forall</span
+		  > a (b :: ()) (d :: ()). d <a href="#" title="Data.Type.Equality"
+		  >~</a
+		  > '()</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>=&gt; <span class="keyword"
+		  >forall</span
+		  > c. a b c d</td
+		><td class="doc"
+		><p
+		  >abcd</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; ()</td
+		><td class="doc"
+		><p
+		  >Result</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:j" class="def"
+	    >j</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: <span class="keyword"
+		  >forall</span
+		  > proxy (a :: ()) b. proxy a</td
+		><td class="doc"
+		><p
+		  >First argument</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; b</td
+		><td class="doc"
+		><p
+		  >Result</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/GADTRecords.html b/utils/haddock/html-test/ref/GADTRecords.html
new file mode 100644
index 0000000000000000000000000000000000000000..7f9f80f67a2420fce4c329e7d66fb7d51eb08425
--- /dev/null
+++ b/utils/haddock/html-test/ref/GADTRecords.html
@@ -0,0 +1,244 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >GADTRecords</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>GADTRecords</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >H1</a
+	      > a b <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >C1</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > a b. <a href="#" title="GADTRecords"
+		  >H1</a
+		  > a b</li
+		><li
+		><a href="#"
+		  >C2</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > a. <a href="#" title="Data.Ord"
+		  >Ord</a
+		  > a =&gt; [a] -&gt; <a href="#" title="GADTRecords"
+		  >H1</a
+		  > a a</li
+		><li
+		><a href="#"
+		  >C3</a
+		  > :: {..} -&gt; <a href="#" title="GADTRecords"
+		  >H1</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  ></li
+		><li
+		><a href="#"
+		  >C4</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > b. {..} -&gt; <a href="#" title="GADTRecords"
+		  >H1</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > b</li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:H1" class="def"
+	    >H1</a
+	    > a b <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >h1</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:C1" class="def"
+		  >C1</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > a b. <a href="#" title="GADTRecords"
+		  >H1</a
+		  > a b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:C2" class="def"
+		  >C2</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > a. <a href="#" title="Data.Ord"
+		  >Ord</a
+		  > a =&gt; [a] -&gt; <a href="#" title="GADTRecords"
+		  >H1</a
+		  > a a</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:C3" class="def"
+		  >C3</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			>:: { <a id="v:field" class="def"
+			  >field</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >hello docs</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>&nbsp;&nbsp;&nbsp;} -&gt; <a href="#" title="GADTRecords"
+			  >H1</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:C4" class="def"
+		  >C4</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			>:: <span class="keyword"
+			  >forall</span
+			  > b. { <a id="v:field2" class="def"
+			  >field2</a
+			  > :: b</dfn
+			><div class="doc"
+			><p
+			  >hello2 docs</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>&nbsp;&nbsp;&nbsp;} -&gt; <a href="#" title="GADTRecords"
+			  >H1</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  > b</dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/GadtConstructorArgs.html b/utils/haddock/html-test/ref/GadtConstructorArgs.html
new file mode 100644
index 0000000000000000000000000000000000000000..aefe15f5cb2246fd095376e33beab16d0ef18c53
--- /dev/null
+++ b/utils/haddock/html-test/ref/GadtConstructorArgs.html
@@ -0,0 +1,200 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >GadtConstructorArgs</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>GadtConstructorArgs</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Boo" class="def"
+	    >Boo</a
+	    > <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Fot" class="def"
+		  >Fot</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			>:: { <a id="v:x" class="def"
+			  >x</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >an <code
+			    ><a href="#" title="GadtConstructorArgs"
+			      >x</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>&nbsp;&nbsp;&nbsp;, <a id="v:y" class="def"
+			  >y</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >a <code
+			    ><a href="#" title="GadtConstructorArgs"
+			      >y</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>&nbsp;&nbsp;&nbsp;} -&gt; <a href="#" title="GadtConstructorArgs"
+			  >Boo</a
+			  ></dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Fob" class="def"
+		  >Fob</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Record GADT with docs</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			>:: { <a id="v:w" class="def"
+			  >w</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >a <code
+			    ><a href="#" title="GadtConstructorArgs"
+			      >w</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>&nbsp;&nbsp;&nbsp;, <a id="v:z" class="def"
+			  >z</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >a <code
+			    ><a href="#" title="GadtConstructorArgs"
+			      >z</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			>&nbsp;&nbsp;&nbsp;} -&gt; <a href="#" title="GadtConstructorArgs"
+			  >Boo</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >a <code
+			    ><a href="#" title="GadtConstructorArgs"
+			      >Boo</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Hash.html b/utils/haddock/html-test/ref/Hash.html
new file mode 100644
index 0000000000000000000000000000000000000000..c263e98b34c2c9048d6d4300652b047fd314725e
--- /dev/null
+++ b/utils/haddock/html-test/ref/Hash.html
@@ -0,0 +1,443 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Hash</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Hash</p
+	></div
+      ><div id="table-of-contents"
+      ><div id="contents-list"
+	><p class="caption" onclick="window.scrollTo(0,0)"
+	  >Contents</p
+	  ><ul
+	  ><li
+	    ><a href="#"
+	      >The <code
+		>HashTable</code
+		> type</a
+	      ><ul
+	      ><li
+		><a href="#"
+		  >Operations on <code
+		    >HashTable</code
+		    >s</a
+		  ></li
+		></ul
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >The <code
+		>Hash</code
+		> class</a
+	      ></li
+	    ></ul
+	  ></div
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >Implementation of fixed-size hash tables, with a type
+  class for constructing hash values for structured types.</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >HashTable</a
+	      > key val</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >new</a
+	      > :: (<a href="#" title="Data.Eq"
+	      >Eq</a
+	      > key, <a href="#" title="Hash"
+	      >Hash</a
+	      > key) =&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; <a href="#" title="Prelude"
+	      >IO</a
+	      > (<a href="#" title="Hash"
+	      >HashTable</a
+	      > key val)</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >insert</a
+	      > :: (<a href="#" title="Data.Eq"
+	      >Eq</a
+	      > key, <a href="#" title="Hash"
+	      >Hash</a
+	      > key) =&gt; key -&gt; val -&gt; <a href="#" title="Prelude"
+	      >IO</a
+	      > ()</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >lookup</a
+	      > :: <a href="#" title="Hash"
+	      >Hash</a
+	      > key =&gt; key -&gt; <a href="#" title="Prelude"
+	      >IO</a
+	      > (<a href="#" title="Data.Maybe"
+	      >Maybe</a
+	      > val)</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >Hash</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >hash</a
+		  > :: a -&gt; <a href="#" title="Data.Int"
+		  >Int</a
+		  ></li
+		></ul
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><a href="#" id="g:1"
+	><h1
+	  >The <code
+	    >HashTable</code
+	    > type</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:HashTable" class="def"
+	    >HashTable</a
+	    > key val <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A hash table with keys of type <code
+	      >key</code
+	      > and values of type <code
+	      >val</code
+	      >.
+ The type <code
+	      >key</code
+	      > should be an instance of <code
+	      ><a href="#" title="Data.Eq"
+		>Eq</a
+		></code
+	      >.</p
+	    ></div
+	  ></div
+	><a href="#" id="g:2"
+	><h2
+	  >Operations on <code
+	    >HashTable</code
+	    >s</h2
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:new" class="def"
+	    >new</a
+	    > :: (<a href="#" title="Data.Eq"
+	    >Eq</a
+	    > key, <a href="#" title="Hash"
+	    >Hash</a
+	    > key) =&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > -&gt; <a href="#" title="Prelude"
+	    >IO</a
+	    > (<a href="#" title="Hash"
+	    >HashTable</a
+	    > key val) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Builds a new hash table with a given size</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:insert" class="def"
+	    >insert</a
+	    > :: (<a href="#" title="Data.Eq"
+	    >Eq</a
+	    > key, <a href="#" title="Hash"
+	    >Hash</a
+	    > key) =&gt; key -&gt; val -&gt; <a href="#" title="Prelude"
+	    >IO</a
+	    > () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Inserts a new element into the hash table</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:lookup" class="def"
+	    >lookup</a
+	    > :: <a href="#" title="Hash"
+	    >Hash</a
+	    > key =&gt; key -&gt; <a href="#" title="Prelude"
+	    >IO</a
+	    > (<a href="#" title="Data.Maybe"
+	    >Maybe</a
+	    > val) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Looks up a key in the hash table, returns <code
+	      ><code
+		><a href="#" title="Data.Maybe"
+		  >Just</a
+		  ></code
+		> val</code
+	      > if the key
+ was found, or <code
+	      ><a href="#" title="Data.Maybe"
+		>Nothing</a
+		></code
+	      > otherwise.</p
+	    ></div
+	  ></div
+	><a href="#" id="g:3"
+	><h1
+	  >The <code
+	    >Hash</code
+	    > class</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Hash" class="def"
+	    >Hash</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A class of types which can be hashed.</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:hash" class="def"
+	      >hash</a
+	      > :: a -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >hashes the value of type <code
+		>a</code
+		> into an <code
+		><a href="#" title="Data.Int"
+		  >Int</a
+		  ></code
+		></p
+	      ></div
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Hash"
+	    >Instances</h4
+	    ><details id="i:Hash" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Hash:Hash:1"
+		      ></span
+		      > <a href="#" title="Hash"
+		      >Hash</a
+		      > <a href="#" title="GHC.Exts"
+		      >Float</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Hash:Hash:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Hash</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >hash</a
+			  > :: <a href="#" title="GHC.Exts"
+			  >Float</a
+			  > -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Hash:Hash:2"
+		      ></span
+		      > <a href="#" title="Hash"
+		      >Hash</a
+		      > <a href="#" title="Data.Int"
+		      >Int</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Hash:Hash:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Hash</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >hash</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Hash:Hash:3"
+		      ></span
+		      > (<a href="#" title="Hash"
+		      >Hash</a
+		      > a, <a href="#" title="Hash"
+		      >Hash</a
+		      > b) =&gt; <a href="#" title="Hash"
+		      >Hash</a
+		      > (a, b)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Hash:Hash:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Hash</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >hash</a
+			  > :: (a, b) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/HiddenInstances.html b/utils/haddock/html-test/ref/HiddenInstances.html
new file mode 100644
index 0000000000000000000000000000000000000000..71a80862850831531df4c8b903323338fafe7d80
--- /dev/null
+++ b/utils/haddock/html-test/ref/HiddenInstances.html
@@ -0,0 +1,326 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >HiddenInstances</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>HiddenInstances</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >VisibleClass</a
+	      > a</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >VisibleData</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:VisibleClass" class="def"
+	    >VisibleClass</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Should be visible</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:VisibleClass"
+	    >Instances</h4
+	    ><details id="i:VisibleClass" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:VisibleClass:VisibleClass:1"
+		      ></span
+		      > <a href="#" title="HiddenInstances"
+		      >VisibleClass</a
+		      > <a href="#" title="HiddenInstances"
+		      >VisibleData</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Should be visible</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:VisibleClass:VisibleClass:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>HiddenInstances</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:VisibleClass:VisibleClass:2"
+		      ></span
+		      > <a href="#" title="HiddenInstances"
+		      >VisibleClass</a
+		      > <a href="#" title="Data.Int"
+		      >Int</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Should be visible</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:VisibleClass:VisibleClass:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>HiddenInstances</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:VisibleData" class="def"
+	    >VisibleData</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Should be visible</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:VisibleData"
+	    >Instances</h4
+	    ><details id="i:VisibleData" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:VisibleData:Num:1"
+		      ></span
+		      > <a href="#" title="Prelude"
+		      >Num</a
+		      > <a href="#" title="HiddenInstances"
+		      >VisibleData</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Should be visible</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:VisibleData:Num:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>HiddenInstances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >(+)</a
+			  > :: <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(-)</a
+			  > :: <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(*)</a
+			  > :: <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >negate</a
+			  > :: <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >abs</a
+			  > :: <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >signum</a
+			  > :: <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >fromInteger</a
+			  > :: <a href="#" title="Prelude"
+			  >Integer</a
+			  > -&gt; <a href="#" title="HiddenInstances"
+			  >VisibleData</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:VisibleData:VisibleClass:2"
+		      ></span
+		      > <a href="#" title="HiddenInstances"
+		      >VisibleClass</a
+		      > <a href="#" title="HiddenInstances"
+		      >VisibleData</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Should be visible</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:VisibleData:VisibleClass:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>HiddenInstances</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/HiddenInstancesB.html b/utils/haddock/html-test/ref/HiddenInstancesB.html
new file mode 100644
index 0000000000000000000000000000000000000000..89667e7325de4b62b206e45767b33482a032cbf2
--- /dev/null
+++ b/utils/haddock/html-test/ref/HiddenInstancesB.html
@@ -0,0 +1,186 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >HiddenInstancesB</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>HiddenInstancesB</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >Foo</a
+	      > a</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Bar</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Should be visible</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo"
+	    >Instances</h4
+	    ><details id="i:Foo" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:1"
+		      ></span
+		      > <a href="#" title="HiddenInstancesB"
+		      >Foo</a
+		      > <a href="#" title="HiddenInstancesB"
+		      >Bar</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Should be visible</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>HiddenInstancesA</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Bar" class="def"
+	    >Bar</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Should be visible</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Bar"
+	    >Instances</h4
+	    ><details id="i:Bar" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Bar:Foo:1"
+		      ></span
+		      > <a href="#" title="HiddenInstancesB"
+		      >Foo</a
+		      > <a href="#" title="HiddenInstancesB"
+		      >Bar</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Should be visible</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Bar:Foo:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>HiddenInstancesA</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Hyperlinks.html b/utils/haddock/html-test/ref/Hyperlinks.html
new file mode 100644
index 0000000000000000000000000000000000000000..28a38baca4c9366824338c907b1a696992a1335e
--- /dev/null
+++ b/utils/haddock/html-test/ref/Hyperlinks.html
@@ -0,0 +1,92 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Hyperlinks</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Hyperlinks</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A plain URL: <a href="#"
+	      >http://example.com/</a
+	      ></p
+	    ><p
+	    >A URL with a label: <a href="#"
+	      >some link</a
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Identifiers.html b/utils/haddock/html-test/ref/Identifiers.html
new file mode 100644
index 0000000000000000000000000000000000000000..db303fc25695f7023a909e0d34a702f5161560eb
--- /dev/null
+++ b/utils/haddock/html-test/ref/Identifiers.html
@@ -0,0 +1,290 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Identifiers</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Identifiers</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Id</a
+	      > = <a href="#"
+	      >Id</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > a <a href="#"
+	      >:*</a
+	      > b = a <a href="#"
+	      >:*</a
+	      > b</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Id" class="def"
+	    >Id</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Id" class="def"
+		  >Id</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > a <a id="t::-42-" class="def"
+	    >:*</a
+	    > b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>a <a id="v::-42-" class="def"
+		  >:*</a
+		  > b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><ul
+	    ><li
+	      ><p
+		>Unadorned:</p
+		><ul
+		><li
+		  >Unqualified: <code
+		    ><a href="#" title="Data.List"
+		      >++</a
+		      ></code
+		    >, <code
+		    ><a href="#" title="Data.Foldable"
+		      >elem</a
+		      ></code
+		    ></li
+		  ><li
+		  >Qualified: <code
+		    ><a href="#" title="Data.List"
+		      >++</a
+		      ></code
+		    >, <code
+		    ><a href="#" title="Data.Lis"
+		      >elem</a
+		      ></code
+		    ></li
+		  ><li
+		  >Namespaced: <code
+		    ><a href="#" title="Data.List"
+		      >++</a
+		      ></code
+		    >, <code
+		    >++</code
+		    >, <code
+		    ><a href="#" title="Data.Foldable"
+		      >elem</a
+		      ></code
+		    >, <code
+		    >elem</code
+		    >, <code
+		    ><a href="#" title="Identifiers"
+		      >Id</a
+		      ></code
+		    >, <code
+		    ><a href="#" title="Identifiers"
+		      >Id</a
+		      ></code
+		    >, <code
+		    ><a href="#" title="Identifiers"
+		      >:*</a
+		      ></code
+		    >, <code
+		    ><a href="#" title="Identifiers"
+		      >:*</a
+		      ></code
+		    ></li
+		  ></ul
+		></li
+	      ><li
+	      ><p
+		>Parenthesized:</p
+		><ul
+		><li
+		  >Unqualified: <code
+		    ><code
+		      ><a href="#" title="Data.List"
+			>(++)</a
+			></code
+		      > [1,2,3] [4,5,6]</code
+		    ></li
+		  ><li
+		  >Qualified: <code
+		    ><code
+		      ><a href="#" title="Data.List"
+			>(++)</a
+			></code
+		      > [1,2,3] [4,5,6]</code
+		    ></li
+		  ><li
+		  >Namespaced: <code
+		    ><a href="#" title="Data.List"
+		      >(++)</a
+		      ></code
+		    >, <code
+		    >++</code
+		    >, <code
+		    ><a href="#" title="Identifiers"
+		      >(:*)</a
+		      ></code
+		    >, <code
+		    ><a href="#" title="Identifiers"
+		      >(:*)</a
+		      ></code
+		    ></li
+		  ></ul
+		></li
+	      ><li
+	      ><p
+		>Backticked:</p
+		><ul
+		><li
+		  >Unqualified: <code
+		    >1 <code
+		      ><a href="#" title="Data.Foldable"
+			>`elem`</a
+			></code
+		      > [-3..3]</code
+		    ></li
+		  ><li
+		  >Qualified: <code
+		    >1 <code
+		      ><a href="#" title="Data.List"
+			>`elem`</a
+			></code
+		      > [-3..3]</code
+		    ></li
+		  ><li
+		  >Namespaced: <code
+		    ><a href="#" title="Data.Foldable"
+		      >`elem`</a
+		      ></code
+		    >, <code
+		    >`elem`</code
+		    >, <code
+		    ><a href="#" title="Identifiers"
+		      >`Id`</a
+		      ></code
+		    >, <code
+		    ><a href="#" title="Identifiers"
+		      >`Id`</a
+		      ></code
+		    ></li
+		  ></ul
+		></li
+	      ><li
+	      ><p
+		>Edge cases:</p
+		><ul
+		><li
+		  >Tuples: <code
+		    >()</code
+		    >, <code
+		    >(,,,)</code
+		    ></li
+		  ></ul
+		></li
+	      ></ul
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/IgnoreExports.html b/utils/haddock/html-test/ref/IgnoreExports.html
new file mode 100644
index 0000000000000000000000000000000000000000..029565b8fb787f1a9ec7205480e391aa2a442770
--- /dev/null
+++ b/utils/haddock/html-test/ref/IgnoreExports.html
@@ -0,0 +1,106 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >IgnoreExports</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>IgnoreExports</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Foo</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >documentation for Foo</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >documentation for foo</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/ImplicitParams.html b/utils/haddock/html-test/ref/ImplicitParams.html
new file mode 100644
index 0000000000000000000000000000000000000000..b027baad7b4d1041403fa984f5fe4c549ddc1006
--- /dev/null
+++ b/utils/haddock/html-test/ref/ImplicitParams.html
@@ -0,0 +1,120 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >ImplicitParams</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>ImplicitParams</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:X" class="def"
+	    >X</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:X" class="def"
+		  >X</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:c" class="def"
+	    >c</a
+	    > :: (?x :: <a href="#" title="ImplicitParams"
+	    >X</a
+	    >) =&gt; <a href="#" title="ImplicitParams"
+	    >X</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:d" class="def"
+	    >d</a
+	    > :: (?x :: <a href="#" title="ImplicitParams"
+	    >X</a
+	    >, ?y :: <a href="#" title="ImplicitParams"
+	    >X</a
+	    >) =&gt; (<a href="#" title="ImplicitParams"
+	    >X</a
+	    >, <a href="#" title="ImplicitParams"
+	    >X</a
+	    >) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: ((?x :: <a href="#" title="ImplicitParams"
+	    >X</a
+	    >) =&gt; a) -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Instances.html b/utils/haddock/html-test/ref/Instances.html
new file mode 100644
index 0000000000000000000000000000000000000000..2e1e5a6cd7dea884a65de94500360f3bacce9cbd
--- /dev/null
+++ b/utils/haddock/html-test/ref/Instances.html
@@ -0,0 +1,2294 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Instances</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Instances</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > a <a id="t:-60--126--126-" class="def"
+	    >&lt;~~</a
+	    > b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Xyzzy" class="def"
+		  >Xyzzy</a
+		  > (b -&gt; (a, a))</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:-60--126--126-"
+	    >Instances</h4
+	    ><details id="i:-60--126--126-" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:-60--126--126-:Foo:1"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > (<a href="#" title="Instances"
+		      >(&lt;~~)</a
+		      > a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:-60--126--126-:Foo:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: (a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  >) -&gt; a0 -&gt; a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: (a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > (a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > a0)) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > (a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  >) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > (f :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    >Nothing</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:foo" class="def"
+	      >foo</a
+	      > :: f <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; a -&gt; f a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:foo-39-" class="def"
+	      >foo'</a
+	      > :: f (f a) -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; f (f <a href="#" title="Data.Int"
+	      >Int</a
+	      >) <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo"
+	    >Instances</h4
+	    ><details id="i:Foo" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:1"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > <a href="#" title="Data.Maybe"
+		      >Maybe</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; a -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > a) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  >) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:2"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > <a href="#" title="Data.List"
+		      >[]</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: [<a href="#" title="Data.Int"
+			  >Int</a
+			  >] -&gt; a -&gt; [a] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: [[a]] -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; [[<a href="#" title="Data.Int"
+			  >Int</a
+			  >]] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:3"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > (<a href="#" title="Data.Either"
+		      >Either</a
+		      > a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: <a href="#" title="Data.Either"
+			  >Either</a
+			  > a <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; a0 -&gt; <a href="#" title="Data.Either"
+			  >Either</a
+			  > a a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: <a href="#" title="Data.Either"
+			  >Either</a
+			  > a (<a href="#" title="Data.Either"
+			  >Either</a
+			  > a a0) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Data.Either"
+			  >Either</a
+			  > a (<a href="#" title="Data.Either"
+			  >Either</a
+			  > a <a href="#" title="Data.Int"
+			  >Int</a
+			  >) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:4"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > (<a href="#" title="Instances"
+		      >(&lt;~~)</a
+		      > a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: (a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  >) -&gt; a0 -&gt; a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: (a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > (a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > a0)) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > (a <a href="#" title="Instances"
+			  >&lt;~~</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  >) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:5"
+		      ></span
+		      > (<a href="#" title="Data.Eq"
+		      >Eq</a
+		      > a, <a href="#" title="Instances"
+		      >Foo</a
+		      > f) =&gt; <a href="#" title="Instances"
+		      >Foo</a
+		      > (<a href="#" title="GHC.Tuple"
+		      >(,)</a
+		      > (f a))</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:5"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: (f a, <a href="#" title="Data.Int"
+			  >Int</a
+			  >) -&gt; a0 -&gt; (f a, a0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: (f a, (f a, a0)) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; (f a, (f a, <a href="#" title="Data.Int"
+			  >Int</a
+			  >)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:6"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > (<a href="#" title="Instances"
+		      >Quux</a
+		      > a b)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:6"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a b <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; a0 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a b (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b a0) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b <a href="#" title="Data.Int"
+			  >Int</a
+			  >) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:7"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > (<a href="#" title="GHC.Tuple"
+		      >(,,)</a
+		      > a a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:7"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: (a, a, <a href="#" title="Data.Int"
+			  >Int</a
+			  >) -&gt; a0 -&gt; (a, a, a0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: (a, a, (a, a, a0)) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; (a, a, (a, a, <a href="#" title="Data.Int"
+			  >Int</a
+			  >)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Foo:Foo:8"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > ((-&gt;) a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Foo:Foo:8"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: (a -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  >) -&gt; a0 -&gt; a -&gt; a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: (a -&gt; (a -&gt; a0)) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; a -&gt; (a -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  >) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a href="#" title="Instances"
+	    >Foo</a
+	    > f =&gt; <a id="t:Bar" class="def"
+	    >Bar</a
+	    > (f :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    >Nothing</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:bar" class="def"
+	      >bar</a
+	      > :: f a -&gt; f <a href="#" title="Data.Bool"
+	      >Bool</a
+	      > -&gt; a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:bar-39-" class="def"
+	      >bar'</a
+	      > :: f (f a) -&gt; f (f (f b)) <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:bar0" class="def"
+	      >bar0</a
+	      > :: (f a, f a) -&gt; (f b, f c) <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:bar1" class="def"
+	      >bar1</a
+	      > :: (f a, f a) -&gt; (f b, f c) <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Bar"
+	    >Instances</h4
+	    ><details id="i:Bar" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Bar:Bar:1"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Bar</a
+		      > <a href="#" title="Data.Maybe"
+		      >Maybe</a
+		      > <a href="#" title="Data.Bool"
+		      >Bool</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Bar:Bar:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >bar</a
+			  > :: <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar'</a
+			  > :: <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  >) -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > b)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar0</a
+			  > :: (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  >, <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  >) -&gt; (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > b, <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar1</a
+			  > :: (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  >, <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  >) -&gt; (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > b, <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Bar:Bar:2"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Bar</a
+		      > <a href="#" title="Data.Maybe"
+		      >Maybe</a
+		      > [a]</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Bar:Bar:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >bar</a
+			  > :: <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > [a] -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > -&gt; [a] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar'</a
+			  > :: <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > [a]) -&gt; <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > b)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar0</a
+			  > :: (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > [a], <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > [a]) -&gt; (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > b, <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar1</a
+			  > :: (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > [a], <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > [a]) -&gt; (<a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > b, <a href="#" title="Data.Maybe"
+			  >Maybe</a
+			  > c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Bar:Bar:3"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Bar</a
+		      > <a href="#" title="Data.List"
+		      >[]</a
+		      > (a, a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Bar:Bar:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >bar</a
+			  > :: [(a, a)] -&gt; [<a href="#" title="Data.Bool"
+			  >Bool</a
+			  >] -&gt; (a, a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar'</a
+			  > :: [[(a, a)]] -&gt; [[[b]]] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar0</a
+			  > :: ([(a, a)], [(a, a)]) -&gt; ([b], [c]) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar1</a
+			  > :: ([(a, a)], [(a, a)]) -&gt; ([b], [c]) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Bar:Bar:4"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > f =&gt; <a href="#" title="Instances"
+		      >Bar</a
+		      > (<a href="#" title="Data.Either"
+		      >Either</a
+		      > a) (f a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Bar:Bar:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >bar</a
+			  > :: <a href="#" title="Data.Either"
+			  >Either</a
+			  > a (f a) -&gt; <a href="#" title="Data.Either"
+			  >Either</a
+			  > a <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > -&gt; f a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar'</a
+			  > :: <a href="#" title="Data.Either"
+			  >Either</a
+			  > a (<a href="#" title="Data.Either"
+			  >Either</a
+			  > a (f a)) -&gt; <a href="#" title="Data.Either"
+			  >Either</a
+			  > a (<a href="#" title="Data.Either"
+			  >Either</a
+			  > a (<a href="#" title="Data.Either"
+			  >Either</a
+			  > a b)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar0</a
+			  > :: (<a href="#" title="Data.Either"
+			  >Either</a
+			  > a (f a), <a href="#" title="Data.Either"
+			  >Either</a
+			  > a (f a)) -&gt; (<a href="#" title="Data.Either"
+			  >Either</a
+			  > a b, <a href="#" title="Data.Either"
+			  >Either</a
+			  > a c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar1</a
+			  > :: (<a href="#" title="Data.Either"
+			  >Either</a
+			  > a (f a), <a href="#" title="Data.Either"
+			  >Either</a
+			  > a (f a)) -&gt; (<a href="#" title="Data.Either"
+			  >Either</a
+			  > a b, <a href="#" title="Data.Either"
+			  >Either</a
+			  > a c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Bar:Bar:5"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Bar</a
+		      > (<a href="#" title="Instances"
+		      >Quux</a
+		      > a c) (<a href="#" title="Instances"
+		      >Quux</a
+		      > a b c)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Bar:Bar:5"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >bar</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a c <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar'</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c)) -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c b0)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar0</a
+			  > :: (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c), <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c)) -&gt; (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c b0, <a href="#" title="Instances"
+			  >Quux</a
+			  > a c c0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar1</a
+			  > :: (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c), <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c)) -&gt; (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c b0, <a href="#" title="Instances"
+			  >Quux</a
+			  > a c c0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Bar:Bar:6"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > (<a href="#" title="GHC.Tuple"
+		      >(,,)</a
+		      > a b) =&gt; <a href="#" title="Instances"
+		      >Bar</a
+		      > (<a href="#" title="GHC.Tuple"
+		      >(,,)</a
+		      > a b) (a, b, a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Bar:Bar:6"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >bar</a
+			  > :: (a, b, (a, b, a)) -&gt; (a, b, <a href="#" title="Data.Bool"
+			  >Bool</a
+			  >) -&gt; (a, b, a) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar'</a
+			  > :: (a, b, (a, b, (a, b, a))) -&gt; (a, b, (a, b, (a, b, b0))) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar0</a
+			  > :: ((a, b, (a, b, a)), (a, b, (a, b, a))) -&gt; ((a, b, b0), (a, b, c)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar1</a
+			  > :: ((a, b, (a, b, a)), (a, b, (a, b, a))) -&gt; ((a, b, b0), (a, b, c)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Baz" class="def"
+	    >Baz</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    >Nothing</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:baz" class="def"
+	      >baz</a
+	      > :: a -&gt; (<span class="keyword"
+	      >forall</span
+	      > a1. a1 -&gt; a1) -&gt; (b, <span class="keyword"
+	      >forall</span
+	      > c1. c1 -&gt; a) -&gt; (b, c) <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:baz-39-" class="def"
+	      >baz'</a
+	      > :: b -&gt; (<span class="keyword"
+	      >forall</span
+	      > b1. b1 -&gt; a) -&gt; (<span class="keyword"
+	      >forall</span
+	      > b1. b1 -&gt; a) -&gt; [(b, a)] <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:baz-39--39-" class="def"
+	      >baz''</a
+	      > :: b -&gt; (<span class="keyword"
+	      >forall</span
+	      > b1. (<span class="keyword"
+	      >forall</span
+	      > b2. b2 -&gt; a) -&gt; c) -&gt; <span class="keyword"
+	      >forall</span
+	      > c1. c1 -&gt; b <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Baz"
+	    >Instances</h4
+	    ><details id="i:Baz" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Baz:Baz:1"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Baz</a
+		      > [c]</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Baz:Baz:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >baz</a
+			  > :: [c] -&gt; (<span class="keyword"
+			  >forall</span
+			  > a1. a1 -&gt; a1) -&gt; (b, <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; [c]) -&gt; (b, c0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz'</a
+			  > :: b -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; [c]) -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; [c]) -&gt; [(b, [c])] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz''</a
+			  > :: b -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. (<span class="keyword"
+			  >forall</span
+			  > b2. b2 -&gt; [c]) -&gt; c0) -&gt; <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Baz:Baz:2"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Baz</a
+		      > (a -&gt; b)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Baz:Baz:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >baz</a
+			  > :: (a -&gt; b) -&gt; (<span class="keyword"
+			  >forall</span
+			  > a1. a1 -&gt; a1) -&gt; (b0, <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; a -&gt; b) -&gt; (b0, c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz'</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; a -&gt; b) -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; a -&gt; b) -&gt; [(b0, a -&gt; b)] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz''</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. (<span class="keyword"
+			  >forall</span
+			  > b2. b2 -&gt; a -&gt; b) -&gt; c) -&gt; <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; b0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Baz:Baz:3"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Baz</a
+		      > (<a href="#" title="Instances"
+		      >Quux</a
+		      > a b c)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Baz:Baz:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >baz</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c -&gt; (<span class="keyword"
+			  >forall</span
+			  > a1. a1 -&gt; a1) -&gt; (b0, <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; (b0, c0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz'</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; [(b0, <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c)] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz''</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. (<span class="keyword"
+			  >forall</span
+			  > b2. b2 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; c0) -&gt; <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; b0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Baz:Baz:4"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Baz</a
+		      > (a, b, c)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Baz:Baz:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >baz</a
+			  > :: (a, b, c) -&gt; (<span class="keyword"
+			  >forall</span
+			  > a1. a1 -&gt; a1) -&gt; (b0, <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; (a, b, c)) -&gt; (b0, c0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz'</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; (a, b, c)) -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; (a, b, c)) -&gt; [(b0, (a, b, c))] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz''</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. (<span class="keyword"
+			  >forall</span
+			  > b2. b2 -&gt; (a, b, c)) -&gt; c0) -&gt; <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; b0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Baz:Baz:5"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Baz</a
+		      > (a, [b], b, a)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Baz:Baz:5"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >baz</a
+			  > :: (a, [b], b, a) -&gt; (<span class="keyword"
+			  >forall</span
+			  > a1. a1 -&gt; a1) -&gt; (b0, <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; (a, [b], b, a)) -&gt; (b0, c) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz'</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; (a, [b], b, a)) -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; (a, [b], b, a)) -&gt; [(b0, (a, [b], b, a))] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz''</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. (<span class="keyword"
+			  >forall</span
+			  > b2. b2 -&gt; (a, [b], b, a)) -&gt; c) -&gt; <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; b0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Quux" class="def"
+	    >Quux</a
+	    > a b c <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Qx" class="def"
+		  >Qx</a
+		  > a</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Qux" class="def"
+		  >Qux</a
+		  > a b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Quux" class="def"
+		  >Quux</a
+		  > a b c</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Quux"
+	    >Instances</h4
+	    ><details id="i:Quux" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Quux:Foo:1"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Foo</a
+		      > (<a href="#" title="Instances"
+		      >Quux</a
+		      > a b)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Quux:Foo:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >foo</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a b <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; a0 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b a0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >foo'</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a b (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b a0) -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b <a href="#" title="Data.Int"
+			  >Int</a
+			  >) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Quux:Bar:2"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Bar</a
+		      > (<a href="#" title="Instances"
+		      >Quux</a
+		      > a c) (<a href="#" title="Instances"
+		      >Quux</a
+		      > a b c)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Quux:Bar:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >bar</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a c <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar'</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c)) -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c b0)) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar0</a
+			  > :: (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c), <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c)) -&gt; (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c b0, <a href="#" title="Instances"
+			  >Quux</a
+			  > a c c0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >bar1</a
+			  > :: (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c), <a href="#" title="Instances"
+			  >Quux</a
+			  > a c (<a href="#" title="Instances"
+			  >Quux</a
+			  > a b c)) -&gt; (<a href="#" title="Instances"
+			  >Quux</a
+			  > a c b0, <a href="#" title="Instances"
+			  >Quux</a
+			  > a c c0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Quux:Baz:3"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Baz</a
+		      > (<a href="#" title="Instances"
+		      >Quux</a
+		      > a b c)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Quux:Baz:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >baz</a
+			  > :: <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c -&gt; (<span class="keyword"
+			  >forall</span
+			  > a1. a1 -&gt; a1) -&gt; (b0, <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; (b0, c0) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz'</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. b1 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; [(b0, <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c)] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >baz''</a
+			  > :: b0 -&gt; (<span class="keyword"
+			  >forall</span
+			  > b1. (<span class="keyword"
+			  >forall</span
+			  > b2. b2 -&gt; <a href="#" title="Instances"
+			  >Quux</a
+			  > a b c) -&gt; c0) -&gt; <span class="keyword"
+			  >forall</span
+			  > c1. c1 -&gt; b0 <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Quux:Thud:4"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="Instances"
+		      >Thud</a
+		      > <a href="#" title="Data.Int"
+		      >Int</a
+		      > (<a href="#" title="Instances"
+		      >Quux</a
+		      > a [a] c)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Quux:Thud:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="Instances"
+			>Thud</a
+			> <a href="#" title="Data.Int"
+			>Int</a
+			> (<a href="#" title="Instances"
+			>Quux</a
+			> a [a] c) <ul class="inst"
+			><li class="inst"
+			  >= <a id="v:Thuud" class="def"
+			    >Thuud</a
+			    > a</li
+			  ><li class="inst"
+			  >| <a id="v:Thuuud" class="def"
+			    >Thuuud</a
+			    > <a href="#" title="Data.Int"
+			    >Int</a
+			    > <a href="#" title="Data.Int"
+			    >Int</a
+			    ></li
+			  ></ul
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Norf" class="def"
+	    >Norf</a
+	    > a b <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    >Nothing</p
+	    ></div
+	  ><div class="subs associated-types"
+	  ><p class="caption"
+	    >Associated Types</p
+	    ><p class="src"
+	    ><span class="keyword"
+	      >type</span
+	      > <a id="t:Plugh" class="def"
+	      >Plugh</a
+	      > a c b <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><span class="keyword"
+	      >data</span
+	      > <a id="t:Thud" class="def"
+	      >Thud</a
+	      > a c <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:norf" class="def"
+	      >norf</a
+	      > :: <a href="#" title="Instances"
+	      >Plugh</a
+	      > a c b -&gt; a -&gt; (a -&gt; c) -&gt; b <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Norf"
+	    >Instances</h4
+	    ><details id="i:Norf" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Norf:Norf:1"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Norf</a
+		      > <a href="#" title="Data.Int"
+		      >Int</a
+		      > <a href="#" title="Data.Bool"
+		      >Bool</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Norf:Norf:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:PlughIntTuple2Bool:Plugh:1"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="Instances"
+				>Plugh</a
+				> <a href="#" title="Data.Int"
+				>Int</a
+				> (a, b) <a href="#" title="Data.Bool"
+				>Bool</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:PlughIntTuple2Bool:Plugh:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Instances</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="Instances"
+				  >Plugh</a
+				  > <a href="#" title="Data.Int"
+				  >Int</a
+				  > (a, b) <a href="#" title="Data.Bool"
+				  >Bool</a
+				  > = (a, [b])</div
+				></details
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:PlughIntListBool:Plugh:2"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="Instances"
+				>Plugh</a
+				> <a href="#" title="Data.Int"
+				>Int</a
+				> [a] <a href="#" title="Data.Bool"
+				>Bool</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:PlughIntListBool:Plugh:2"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Instances</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="Instances"
+				  >Plugh</a
+				  > <a href="#" title="Data.Int"
+				  >Int</a
+				  > [a] <a href="#" title="Data.Bool"
+				  >Bool</a
+				  > = a</div
+				></details
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:ThudIntList0:Thud:3"
+				></span
+				> <span class="keyword"
+				>data</span
+				> <a href="#" title="Instances"
+				>Thud</a
+				> <a href="#" title="Data.Int"
+				>Int</a
+				> [a]</span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:ThudIntList0:Thud:3"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Instances</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >data</span
+				  > <a href="#" title="Instances"
+				  >Thud</a
+				  > <a href="#" title="Data.Int"
+				  >Int</a
+				  > [a] = <a id="v:Thuuuud" class="def"
+				  >Thuuuud</a
+				  > <a href="#" title="Data.Bool"
+				  >Bool</a
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:ThudIntQuux0:Thud:4"
+				></span
+				> <span class="keyword"
+				>data</span
+				> <a href="#" title="Instances"
+				>Thud</a
+				> <a href="#" title="Data.Int"
+				>Int</a
+				> (<a href="#" title="Instances"
+				>Quux</a
+				> a [a] c)</span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:ThudIntQuux0:Thud:4"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >Instances</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >data</span
+				  > <a href="#" title="Instances"
+				  >Thud</a
+				  > <a href="#" title="Data.Int"
+				  >Int</a
+				  > (<a href="#" title="Instances"
+				  >Quux</a
+				  > a [a] c) <ul class="inst"
+				  ><li class="inst"
+				    >= <a id="v:Thuud" class="def"
+				      >Thuud</a
+				      > a</li
+				    ><li class="inst"
+				    >| <a id="v:Thuuud" class="def"
+				      >Thuuud</a
+				      > <a href="#" title="Data.Int"
+				      >Int</a
+				      > <a href="#" title="Data.Int"
+				      >Int</a
+				      ></li
+				    ></ul
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >norf</a
+			  > :: <a href="#" title="Instances"
+			  >Plugh</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  > c <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; (<a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; c) -&gt; <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Norf:Norf:2"
+		      ></span
+		      > <a href="#" title="Instances"
+		      >Norf</a
+		      > [a] [b]</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Norf:Norf:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Instances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >norf</a
+			  > :: <a href="#" title="Instances"
+			  >Plugh</a
+			  > [a] c [b] -&gt; [a] -&gt; ([a] -&gt; c) -&gt; [b] <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/LinearTypes.html b/utils/haddock/html-test/ref/LinearTypes.html
new file mode 100644
index 0000000000000000000000000000000000000000..19a8a7e4551c44dd09a0caa07066c603cd635444
--- /dev/null
+++ b/utils/haddock/html-test/ref/LinearTypes.html
@@ -0,0 +1,122 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >LinearTypes</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>LinearTypes</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >unrestricted</a
+	      > :: a -&gt; b</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >linear</a
+	      > :: a %1 -&gt; b</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >poly</a
+	      > :: <span class="keyword"
+	      >forall</span
+	      > a (m :: <a href="#" title="GHC.Exts"
+	      >Multiplicity</a
+	      >) b. a %m -&gt; b</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:unrestricted" class="def"
+	    >unrestricted</a
+	    > :: a -&gt; b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Does something unrestricted.</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:linear" class="def"
+	    >linear</a
+	    > :: a %1 -&gt; b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Does something linear.</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:poly" class="def"
+	    >poly</a
+	    > :: <span class="keyword"
+	    >forall</span
+	    > a (m :: <a href="#" title="GHC.Exts"
+	    >Multiplicity</a
+	    >) b. a %m -&gt; b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Does something polymorphic.</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Math.html b/utils/haddock/html-test/ref/Math.html
new file mode 100644
index 0000000000000000000000000000000000000000..6ae9e392ff92128737261c90084ebe7ea02bcdbb
--- /dev/null
+++ b/utils/haddock/html-test/ref/Math.html
@@ -0,0 +1,114 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Math</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Math</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >Math (display) for <code
+	    >normalDensity</code
+	    ></p
+	  ><p
+	  ><span class="mathjax"
+	    >\[
+ \int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}
+ \]</span
+	    ></p
+	  ><p
+	  ><span class="mathjax"
+	    >\(\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\)</span
+	    ></p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: <a href="#" title="Prelude"
+	      >Integer</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Math (inline) for <code
+	      >normalDensity</code
+	      >
+ <span class="mathjax"
+	      >\(\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\)</span
+	      >
+ <span class="mathjax"
+	      >\[\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\]</span
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Minimal.html b/utils/haddock/html-test/ref/Minimal.html
new file mode 100644
index 0000000000000000000000000000000000000000..f8fa63ffa9f7af0369d151c2c7a9c1c75aeefff1
--- /dev/null
+++ b/utils/haddock/html-test/ref/Minimal.html
@@ -0,0 +1,348 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Minimal</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Minimal</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >This tests the new MINIMAL pragma present in GHC 7.8</p
+	  ></div
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    ><a href="#" title="Minimal"
+	      >foo</a
+	      >, <a href="#" title="Minimal"
+	      >bar</a
+	      > | <a href="#" title="Minimal"
+	      >bar</a
+	      >, <a href="#" title="Minimal"
+	      >bat</a
+	      > | <a href="#" title="Minimal"
+	      >foo</a
+	      >, <a href="#" title="Minimal"
+	      >bat</a
+	      > | <a href="#" title="Minimal"
+	      >fooBarBat</a
+	      ></p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:foo" class="def"
+	      >foo</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Any two of these are required...</p
+	      ></div
+	    ><p class="src"
+	    ><a id="v:bar" class="def"
+	      >bar</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:bat" class="def"
+	      >bat</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:fooBarBat" class="def"
+	      >fooBarBat</a
+	      > :: (a, a, a) <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >.. or just this</p
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Weird" class="def"
+	    >Weird</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    >(<a href="#" title="Minimal"
+	      >a</a
+	      >, <a href="#" title="Minimal"
+	      >b</a
+	      >, <a href="#" title="Minimal"
+	      >c</a
+	      > | (<a href="#" title="Minimal"
+	      >d</a
+	      > | <a href="#" title="Minimal"
+	      >e</a
+	      >, (<a href="#" title="Minimal"
+	      >f</a
+	      > | <a href="#" title="Minimal"
+	      >g</a
+	      >)))</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:a" class="def"
+	      >a</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:b" class="def"
+	      >b</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:c" class="def"
+	      >c</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:d" class="def"
+	      >d</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:e" class="def"
+	      >e</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:f" class="def"
+	      >f</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:g" class="def"
+	      >g</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:NoMins" class="def"
+	    >NoMins</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    ><a href="#" title="Minimal"
+	      >x</a
+	      >, <a href="#" title="Minimal"
+	      >y</a
+	      ></p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:x" class="def"
+	      >x</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:y" class="def"
+	      >y</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:z" class="def"
+	      >z</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:FullMin" class="def"
+	    >FullMin</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:aaa" class="def"
+	      >aaa</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:bbb" class="def"
+	      >bbb</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:PartialMin" class="def"
+	    >PartialMin</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    ><a href="#" title="Minimal"
+	      >ccc</a
+	      >, ddd</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:ccc" class="def"
+	      >ccc</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:EmptyMin" class="def"
+	    >EmptyMin</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    >Nothing</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:eee" class="def"
+	      >eee</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:fff" class="def"
+	      >fff</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/ModuleWithWarning.html b/utils/haddock/html-test/ref/ModuleWithWarning.html
new file mode 100644
index 0000000000000000000000000000000000000000..a54331cd9203b8feefcc0857c9af4a698e5f0594
--- /dev/null
+++ b/utils/haddock/html-test/ref/ModuleWithWarning.html
@@ -0,0 +1,84 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >ModuleWithWarning</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>ModuleWithWarning</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><div class="warning"
+	  ><p
+	    >Warning: This is an unstable interface.  Prefer functions from <a href="#"
+	      >Prelude</a
+	      > instead!</p
+	    ></div
+	  ><p
+	  >Documentation for <a href="#"
+	    >ModuleWithWarning</a
+	    >.</p
+	  ></div
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/NamedDoc.html b/utils/haddock/html-test/ref/NamedDoc.html
new file mode 100644
index 0000000000000000000000000000000000000000..2e0f63211383396b1b0a539016a4fc48e1f9586c
--- /dev/null
+++ b/utils/haddock/html-test/ref/NamedDoc.html
@@ -0,0 +1,70 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >NamedDoc</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>NamedDoc</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="doc"
+	><p
+	  >bar</p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/NamespacedIdentifiers.html b/utils/haddock/html-test/ref/NamespacedIdentifiers.html
new file mode 100644
index 0000000000000000000000000000000000000000..2507c934a7a1c000feeae30ee65f18ba67585b39
--- /dev/null
+++ b/utils/haddock/html-test/ref/NamespacedIdentifiers.html
@@ -0,0 +1,150 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >NamespacedIdentifiers</title
+    ><link href="linuwial.css" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="quick-jump.css"
+     /><link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans:400,400i,700"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="index.html"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="doc-index.html"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>NamespacedIdentifiers</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#t:Foo"
+	      >Foo</a
+	      > = <a href="#v:Bar"
+	      >Bar</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#t:Bar"
+	      >Bar</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <a href="#t:Foo" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A link to:</p
+	    ><ul
+	    ><li
+	      >the type <code
+		><a href="NamespacedIdentifiers.html#t:Bar" title="NamespacedIdentifiers"
+		  >Bar</a
+		  ></code
+		></li
+	      ><li
+	      >the constructor <code
+		><a href="NamespacedIdentifiers.html#v:Bar" title="NamespacedIdentifiers"
+		  >Bar</a
+		  ></code
+		></li
+	      ><li
+	      >the unimported but qualified type <code
+		><a href="A.html#t:A" title="A"
+		  >A</a
+		  ></code
+		></li
+	      ><li
+	      >the unimported but qualified value <code
+		><a href="A.html#v:A" title="A"
+		  >A</a
+		  ></code
+		></li
+	      ></ul
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Bar" class="def"
+		  >Bar</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Bar" class="def"
+	    >Bar</a
+	    > <a href="#t:Bar" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A link to the value <code
+	      >Foo</code
+	      > (which shouldn't exist).</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Nesting.html b/utils/haddock/html-test/ref/Nesting.html
new file mode 100644
index 0000000000000000000000000000000000000000..5af30a4bcb0000b4b8c73b57fb9e90a0d3371a80
--- /dev/null
+++ b/utils/haddock/html-test/ref/Nesting.html
@@ -0,0 +1,364 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Nesting</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Nesting</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >d</a
+	      > :: t</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >e</a
+	      > :: t</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: t</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >g</a
+	      > :: t</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >h</a
+	      > :: t</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >i</a
+	      > :: t</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >j</a
+	      > :: t</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >k</a
+	      > :: t</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:d" class="def"
+	    >d</a
+	    > :: t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><ul
+	    ><li
+	      ><p
+		>We can</p
+		><ul
+		><li
+		  ><p
+		    >easily go back</p
+		    ><ol
+		    ><li value="1"
+		      >some indentation</li
+		      ></ol
+		    ></li
+		  ><li
+		  >levels</li
+		  ></ul
+		></li
+	      ></ul
+	    ><ol
+	    ><li value="1"
+	      ><pre
+		>back at the top</pre
+		></li
+	      ></ol
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:e" class="def"
+	    >e</a
+	    > :: t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><ul
+	    ><li
+	      ><p
+		>Beginning of list</p
+		><ul
+		><li
+		  >second list</li
+		  ></ul
+		></li
+	      ><li
+	      >Some indented list but
+the presence of this text pushes it out of nesting back to the top.</li
+	      ></ul
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><ul
+	    ><li
+	      ><p
+		>Beginning of list</p
+		><pre
+		>nested code
+    we preserve the space correctly
+</pre
+		></li
+	      ></ul
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:g" class="def"
+	    >g</a
+	    > :: t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><ul
+	    ><li
+	      ><p
+		>Beginning of list</p
+		><ul
+		><li
+		  >Nested list</li
+		  ></ul
+		></li
+	      ></ul
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:h" class="def"
+	    >h</a
+	    > :: t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><ul
+	    ><li
+	      ><p
+		>Beginning of list</p
+		><pre
+		>nested
+bird
+tracks</pre
+		></li
+	      ></ul
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:i" class="def"
+	    >i</a
+	    > :: t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><ul
+	    ><li
+	      ><p
+		>Beginning of list
+This belongs to the list above!</p
+		><pre
+		>nested
+bird
+tracks
+
+another line
+  with indentation</pre
+		><pre
+		>nested bird tracks
+  without leading space</pre
+		><ul
+		><li
+		  ><p
+		    >Next list
+More of the indented list.</p
+		    ><ul
+		    ><li
+		      ><p
+			>Deeper</p
+			><ul
+			><li
+			  ><p
+			    >Deeper</p
+			    ><ul
+			    ><li
+			      >Even deeper!</li
+			      ><li
+			      >No newline separation even in indented lists.</li
+			      ></ul
+			    ></li
+			  ></ul
+			></li
+		      ></ul
+		    ></li
+		  ></ul
+		></li
+	      ></ul
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:j" class="def"
+	    >j</a
+	    > :: t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><dl
+	    ><dt
+	      >All this</dt
+	      ><dd
+	      >Works for
+definition lists too.<pre
+		>nested
+bird
+tracks</pre
+		><ul
+		><li
+		  ><p
+		    >Next list
+with more of the indented list content.</p
+		    ><p
+		    >Even more content on a new line.</p
+		    ><ol
+		    ><li value="1"
+		      ><p
+			>Different type of list</p
+			><ol
+			><li value="2"
+			  >Deeper</li
+			  ></ol
+			><pre class="screen"
+			><code class="prompt"
+			  >&gt;&gt;&gt; </code
+			  ><strong class="userinput"
+			  ><code
+			    >Here's an example in a list
+</code
+			    ></strong
+			  >example result
+</pre
+			><dl
+			><dt
+			  >b</dt
+			  ><dd
+			  >Even deeper!</dd
+			  ><dt
+			  >c</dt
+			  ><dd
+			  >No newline separation even in indented lists.
+        We can have any paragraph level element that we normally
+        can, like headers</dd
+			  ></dl
+			><h3
+			>Level 3 header</h3
+			><p
+			>with some content&#8230;</p
+			><ul
+			><li
+			  >and even more lists inside</li
+			  ></ul
+			></li
+		      ></ol
+		    ></li
+		  ></ul
+		></dd
+	      ></dl
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:k" class="def"
+	    >k</a
+	    > :: t <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><ul
+	    ><li
+	      >list may start at arbitrary depth</li
+	      ><li
+	      >and consecutive items at that depth
+      belong to the same list</li
+	      ><li
+	      ><p
+		>of course we can still</p
+		><ul
+		><li
+		  >nest items like we are used to</li
+		  ></ul
+		></li
+	      ><li
+	      >and then get back to initial list</li
+	      ></ul
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/NoLayout.html b/utils/haddock/html-test/ref/NoLayout.html
new file mode 100644
index 0000000000000000000000000000000000000000..44ed6688cf78adfe5f42ff3afd4cc0df58efa56b
--- /dev/null
+++ b/utils/haddock/html-test/ref/NoLayout.html
@@ -0,0 +1,90 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >NoLayout</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>NoLayout</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >g</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:g" class="def"
+	    >g</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >the function <code
+	      ><a href="#" title="NoLayout"
+		>g</a
+		></code
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/NonGreedy.html b/utils/haddock/html-test/ref/NonGreedy.html
new file mode 100644
index 0000000000000000000000000000000000000000..7f5146bad355d78123b4791d122e69c64a0fb78c
--- /dev/null
+++ b/utils/haddock/html-test/ref/NonGreedy.html
@@ -0,0 +1,86 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >NonGreedy</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>NonGreedy</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><a href="#"
+	      >url1</a
+	      > <a href="#"
+	      >url2</a
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Operators.html b/utils/haddock/html-test/ref/Operators.html
new file mode 100644
index 0000000000000000000000000000000000000000..ea67771e62c6d74265a9bb501259f623be24521e
--- /dev/null
+++ b/utils/haddock/html-test/ref/Operators.html
@@ -0,0 +1,544 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Operators</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Operators</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >Test operators with or without fixity declarations</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >(+-)</a
+	      > :: a -&gt; a -&gt; a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >(*/)</a
+	      > :: a -&gt; a -&gt; a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: a -&gt; a -&gt; a</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Foo</a
+	      ><ul class="subs"
+	      ><li
+		>= <a href="#" title="Operators"
+		  >Foo</a
+		  > <a href="#"
+		  >`Bar`</a
+		  > <a href="#" title="Operators"
+		  >Foo</a
+		  ></li
+		><li
+		>| <a href="#" title="Operators"
+		  >Foo</a
+		  > <a href="#"
+		  >:-</a
+		  > <a href="#" title="Operators"
+		  >Foo</a
+		  ></li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >(:+)</a
+	      > :: a -&gt; a -&gt; [a]</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > a <a href="#"
+	      >&lt;-&gt;</a
+	      > b <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >(:&lt;-&gt;)</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > a b. a -&gt; b -&gt; a <a href="#" title="Operators"
+		  >&lt;-&gt;</a
+		  > b</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >type family</span
+	      > a <a href="#"
+	      >++</a
+	      > b</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data family</span
+	      > a <a href="#"
+	      >**</a
+	      > b</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > a <a href="#"
+	      >&gt;&lt;&gt;</a
+	      > b | a -&gt; b <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><span class="keyword"
+		  >type</span
+		  > a <a href="#"
+		  >&lt;&gt;&lt;</a
+		  > b</li
+		><li
+		><span class="keyword"
+		  >data</span
+		  > a <a href="#"
+		  >&gt;&lt;&lt;</a
+		  > b</li
+		><li
+		><a href="#"
+		  >(&gt;&gt;&lt;)</a
+		  > :: a -&gt; b -&gt; ()</li
+		><li
+		><a href="#"
+		  >(&lt;&lt;&gt;)</a
+		  > :: a -&gt; b -&gt; ()</li
+		><li
+		><a href="#"
+		  >(**&gt;)</a
+		  > :: a -&gt; a -&gt; ()</li
+		><li
+		><a href="#"
+		  >(**&lt;)</a
+		  > :: a -&gt; a -&gt; ()</li
+		><li
+		><a href="#"
+		  >(&gt;**)</a
+		  > :: a -&gt; a -&gt; ()</li
+		><li
+		><a href="#"
+		  >(&lt;**)</a
+		  > :: a -&gt; a -&gt; ()</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >type</span
+	      > <a href="#"
+	      >(&gt;-&lt;)</a
+	      > a b = a <a href="#" title="Operators"
+	      >&lt;-&gt;</a
+	      > b</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-43--45-" class="def"
+	    >(+-)</a
+	    > :: a -&gt; a -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Operator with no fixity</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-42--47-" class="def"
+	    >(*/)</a
+	    > :: a -&gt; a -&gt; a <span class="fixity"
+	    >infixr 7</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Operator with infixr 7</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: a -&gt; a -&gt; a <span class="fixity"
+	    >infixl 3</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Named function with infixl 3</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Data type with operator constructors</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a href="#" title="Operators"
+		  >Foo</a
+		  > <a id="v:Bar" class="def"
+		  >`Bar`</a
+		  > <a href="#" title="Operators"
+		  >Foo</a
+		  > <span class="fixity"
+		  >infixl 3</span
+		  ><span class="rightedge"
+		  ></span
+		  ></td
+		><td class="doc"
+		><p
+		  >Has infixl 3</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a href="#" title="Operators"
+		  >Foo</a
+		  > <a id="v::-45-" class="def"
+		  >:-</a
+		  > <a href="#" title="Operators"
+		  >Foo</a
+		  > <span class="fixity"
+		  >infixr 5</span
+		  ><span class="rightedge"
+		  ></span
+		  ></td
+		><td class="doc"
+		><p
+		  >Has infixr 5</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v::-43-" class="def"
+	    >(:+)</a
+	    > :: a -&gt; a -&gt; [a] <span class="fixity"
+	    >infixr 3</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Pattern synonym, infixr 3</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > a <a id="t:-60--45--62-" class="def"
+	    >&lt;-&gt;</a
+	    > b <span class="keyword"
+	    >where</span
+	    > <span class="fixity"
+	    >infixl 6</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Type name, infixl 6 and GADT constructor</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v::-60--45--62-" class="def"
+		  >(:&lt;-&gt;)</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > a b. a -&gt; b -&gt; a <a href="#" title="Operators"
+		  >&lt;-&gt;</a
+		  > b <span class="fixity"
+		  >infixr 6</span
+		  ><span class="rightedge"
+		  ></span
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type family</span
+	    > a <a id="t:-43--43-" class="def"
+	    >++</a
+	    > b <span class="fixity"
+	    >infix 3</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Type family with fixity</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > a <a id="t:-42--42-" class="def"
+	    >**</a
+	    > b <span class="fixity"
+	    >infix 9</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Data family with fixity</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > a <a id="t:-62--60--62-" class="def"
+	    >&gt;&lt;&gt;</a
+	    > b | a -&gt; b <span class="keyword"
+	    >where</span
+	    > <span class="fixity"
+	    >infixr 1</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Class with fixity, including associated types</p
+	    ></div
+	  ><div class="subs associated-types"
+	  ><p class="caption"
+	    >Associated Types</p
+	    ><p class="src"
+	    ><span class="keyword"
+	      >type</span
+	      > a <a id="t:-60--62--60-" class="def"
+	      >&lt;&gt;&lt;</a
+	      > b <span class="fixity"
+	      >infixl 2</span
+	      ><span class="rightedge"
+	      ></span
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><span class="keyword"
+	      >data</span
+	      > a <a id="t:-62--60--60-" class="def"
+	      >&gt;&lt;&lt;</a
+	      > b <span class="fixity"
+	      >infixl 3</span
+	      ><span class="rightedge"
+	      ></span
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:-62--62--60-" class="def"
+	      >(&gt;&gt;&lt;)</a
+	      > :: a -&gt; b -&gt; () <span class="fixity"
+	      >infixr 4</span
+	      ><span class="rightedge"
+	      ></span
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:-60--60--62-" class="def"
+	      >(&lt;&lt;&gt;)</a
+	      > :: a -&gt; b -&gt; () <span class="fixity"
+	      >infixl 5</span
+	      ><span class="rightedge"
+	      ></span
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:-42--42--62-" class="def"
+	      >(**&gt;)</a
+	      > :: a -&gt; a -&gt; () <span class="fixity"
+	      >infixr 8</span
+	      ><span class="rightedge"
+	      ></span
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Multiple fixities</p
+	      ></div
+	    ><p class="src"
+	    ><a id="v:-42--42--60-" class="def"
+	      >(**&lt;)</a
+	      > :: a -&gt; a -&gt; () <span class="fixity"
+	      >infixl 8</span
+	      ><span class="rightedge"
+	      ></span
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Multiple fixities</p
+	      ></div
+	    ><p class="src"
+	    ><a id="v:-62--42--42-" class="def"
+	      >(&gt;**)</a
+	      > :: a -&gt; a -&gt; () <span class="fixity"
+	      >infixr 8</span
+	      ><span class="rightedge"
+	      ></span
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Multiple fixities</p
+	      ></div
+	    ><p class="src"
+	    ><a id="v:-60--42--42-" class="def"
+	      >(&lt;**)</a
+	      > :: a -&gt; a -&gt; () <span class="fixity"
+	      >infixl 8</span
+	      ><span class="rightedge"
+	      ></span
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Multiple fixities</p
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type</span
+	    > <a id="t:-62--45--60-" class="def"
+	    >(&gt;-&lt;)</a
+	    > a b = a <a href="#" title="Operators"
+	    >&lt;-&gt;</a
+	    > b <span class="fixity"
+	    >infixl 6</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Type synonym with fixity</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/OrphanInstances.html b/utils/haddock/html-test/ref/OrphanInstances.html
new file mode 100644
index 0000000000000000000000000000000000000000..cad2a2d7a6603cd38ba4c45462a234c91a8f8549
--- /dev/null
+++ b/utils/haddock/html-test/ref/OrphanInstances.html
@@ -0,0 +1,116 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >OrphanInstances</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>OrphanInstances</p
+	></div
+      ><div id="table-of-contents"
+      ><div id="contents-list"
+	><p class="caption" onclick="window.scrollTo(0,0)"
+	  >Contents</p
+	  ><ul
+	  ><li
+	    ><a href="#"
+	      >Orphan instances</a
+	      ></li
+	    ></ul
+	  ></div
+	></div
+      ><div id="interface"
+      ><h1
+	>Orphan instances</h1
+	><div id="section.orphans"
+	><table
+	  ><tr
+	    ><td class="src clearfix"
+	      ><span class="inst-left"
+		><span class="instance details-toggle-control details-toggle" data-details-id="i:o:ic:AClass:AClass:1"
+		  ></span
+		  > <a href="#" title="OrphanInstancesClass"
+		  >AClass</a
+		  > <a href="#" title="OrphanInstancesType"
+		  >AType</a
+		  ></span
+		> <a href="#" class="selflink"
+		>#</a
+		></td
+	      ><td class="doc"
+	      ><p
+		>This is an orphan instance.</p
+		></td
+	      ></tr
+	    ><tr
+	    ><td colspan="2"
+	      ><details id="i:o:ic:AClass:AClass:1"
+		><summary class="hide-when-js-enabled"
+		  >Instance details</summary
+		  ><p
+		  ></p
+		  > <div class="subs methods"
+		  ><p class="caption"
+		    >Methods</p
+		    ><p class="src"
+		    ><a href="#"
+		      >aClass</a
+		      > :: <a href="#" title="OrphanInstancesType"
+		      >AType</a
+		      > -&gt; <a href="#" title="Data.Int"
+		      >Int</a
+		      > <a href="#" class="selflink"
+		      >#</a
+		      ></p
+		    ></div
+		  ></details
+		></td
+	      ></tr
+	    ></table
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/OrphanInstancesClass.html b/utils/haddock/html-test/ref/OrphanInstancesClass.html
new file mode 100644
index 0000000000000000000000000000000000000000..5445ddd7320a3865e251f93019da990b7ee1e4a6
--- /dev/null
+++ b/utils/haddock/html-test/ref/OrphanInstancesClass.html
@@ -0,0 +1,136 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >OrphanInstancesClass</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>OrphanInstancesClass</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:AClass" class="def"
+	    >AClass</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:aClass" class="def"
+	      >aClass</a
+	      > :: a -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      > <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:AClass"
+	    >Instances</h4
+	    ><details id="i:AClass" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:AClass:AClass:1"
+		      ></span
+		      > <a href="#" title="OrphanInstancesClass"
+		      >AClass</a
+		      > <a href="#" title="OrphanInstancesType"
+		      >AType</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >This is an orphan instance.</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:AClass:AClass:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>OrphanInstances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >aClass</a
+			  > :: <a href="#" title="OrphanInstancesType"
+			  >AType</a
+			  > -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/OrphanInstancesType.html b/utils/haddock/html-test/ref/OrphanInstancesType.html
new file mode 100644
index 0000000000000000000000000000000000000000..2b01525c97c8960d04004de6078307424d63ec4c
--- /dev/null
+++ b/utils/haddock/html-test/ref/OrphanInstancesType.html
@@ -0,0 +1,138 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >OrphanInstancesType</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>OrphanInstancesType</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:AType" class="def"
+	    >AType</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:AType" class="def"
+		  >AType</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:AType"
+	    >Instances</h4
+	    ><details id="i:AType" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:AType:AClass:1"
+		      ></span
+		      > <a href="#" title="OrphanInstancesClass"
+		      >AClass</a
+		      > <a href="#" title="OrphanInstancesType"
+		      >AType</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >This is an orphan instance.</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:AType:AClass:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>OrphanInstances</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >aClass</a
+			  > :: <a href="#" title="OrphanInstancesType"
+			  >AType</a
+			  > -&gt; <a href="#" title="Data.Int"
+			  >Int</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/PR643.html b/utils/haddock/html-test/ref/PR643.html
new file mode 100644
index 0000000000000000000000000000000000000000..bd0bef4c67ee7717f1dff95ac69483333b00f998
--- /dev/null
+++ b/utils/haddock/html-test/ref/PR643.html
@@ -0,0 +1,86 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >PR643</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>PR643</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >test</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:test" class="def"
+	    >test</a
+	    > :: () <span class="fixity"
+	    >infixr 5</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Some big documentation</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/PR643_1.html b/utils/haddock/html-test/ref/PR643_1.html
new file mode 100644
index 0000000000000000000000000000000000000000..91fd0eddcfe64449a5f44f8c350ac77a4c9f5ecf
--- /dev/null
+++ b/utils/haddock/html-test/ref/PR643_1.html
@@ -0,0 +1,86 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >PR643_1</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>PR643_1</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >test</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:test" class="def"
+	    >test</a
+	    > :: () <span class="fixity"
+	    >infixr 5</span
+	    ><span class="rightedge"
+	    ></span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Some big documentation</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/PatternSyns.html b/utils/haddock/html-test/ref/PatternSyns.html
new file mode 100644
index 0000000000000000000000000000000000000000..245beae6f0b1bffc732231b7ac63f1b83bbf7a46
--- /dev/null
+++ b/utils/haddock/html-test/ref/PatternSyns.html
@@ -0,0 +1,373 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >PatternSyns</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>PatternSyns</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >Testing some pattern synonyms</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >FooType</a
+	      > x = <a href="#"
+	      >FooCtor</a
+	      > x</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >Foo</a
+	      > :: x -&gt; <a href="#" title="PatternSyns"
+	      >FooType</a
+	      > x</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >Bar</a
+	      > :: x -&gt; <a href="#" title="PatternSyns"
+	      >FooType</a
+	      > (<a href="#" title="PatternSyns"
+	      >FooType</a
+	      > x)</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >(:&lt;-&gt;)</a
+	      > :: x1 -&gt; x2 -&gt; (<a href="#" title="PatternSyns"
+	      >FooType</a
+	      > x1, <a href="#" title="PatternSyns"
+	      >FooType</a
+	      > (<a href="#" title="PatternSyns"
+	      >FooType</a
+	      > x2))</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >BlubType</a
+	      > = <a href="#" title="Prelude"
+	      >Show</a
+	      > x =&gt;  <a href="#"
+	      >BlubCtor</a
+	      > x</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >Blub</a
+	      > :: () =&gt; <a href="#" title="Prelude"
+	      >Show</a
+	      > x =&gt; x -&gt; <a href="#" title="PatternSyns"
+	      >BlubType</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > a <a href="#"
+	      >&gt;&lt;</a
+	      > (b :: k) = <a href="#"
+	      >Empty</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >E</a
+	      > :: a <a href="#" title="PatternSyns"
+	      >&gt;&lt;</a
+	      > b</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >pattern</span
+	      > <a href="#"
+	      >PatWithExplicitSig</a
+	      > :: <a href="#" title="Data.Eq"
+	      >Eq</a
+	      > somex =&gt; somex -&gt; <a href="#" title="PatternSyns"
+	      >FooType</a
+	      > somex</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:FooType" class="def"
+	    >FooType</a
+	    > x <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >FooType doc</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:FooCtor" class="def"
+		  >FooCtor</a
+		  > x</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:Foo" class="def"
+	    >Foo</a
+	    > :: x -&gt; <a href="#" title="PatternSyns"
+	    >FooType</a
+	    > x <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Pattern synonym for <code
+	      ><a href="#" title="PatternSyns"
+		>Foo</a
+		></code
+	      > x</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:Bar" class="def"
+	    >Bar</a
+	    > :: x -&gt; <a href="#" title="PatternSyns"
+	    >FooType</a
+	    > (<a href="#" title="PatternSyns"
+	    >FooType</a
+	    > x) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Pattern synonym for <code
+	      ><a href="#" title="PatternSyns"
+		>Bar</a
+		></code
+	      > x</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v::-60--45--62-" class="def"
+	    >(:&lt;-&gt;)</a
+	    > :: x1 -&gt; x2 -&gt; (<a href="#" title="PatternSyns"
+	    >FooType</a
+	    > x1, <a href="#" title="PatternSyns"
+	    >FooType</a
+	    > (<a href="#" title="PatternSyns"
+	    >FooType</a
+	    > x2)) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Pattern synonym for (<code
+	      ><a href="#" title="PatternSyns"
+		>:&lt;-&gt;</a
+		></code
+	      >)</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:BlubType" class="def"
+	    >BlubType</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >BlubType is existentially quantified</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a href="#" title="Prelude"
+		  >Show</a
+		  > x =&gt;  <a id="v:BlubCtor" class="def"
+		  >BlubCtor</a
+		  > x</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:Blub" class="def"
+	    >Blub</a
+	    > :: () =&gt; <a href="#" title="Prelude"
+	    >Show</a
+	    > x =&gt; x -&gt; <a href="#" title="PatternSyns"
+	    >BlubType</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Pattern synonym for <code
+	      ><a href="#" title="PatternSyns"
+		>Blub</a
+		></code
+	      > x</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > a <a id="t:-62--60-" class="def"
+	    >&gt;&lt;</a
+	    > (b :: k) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for (<code
+	      >&gt;&lt;</code
+	      >)</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Empty" class="def"
+		  >Empty</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:E" class="def"
+	    >E</a
+	    > :: a <a href="#" title="PatternSyns"
+	    >&gt;&lt;</a
+	    > b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Pattern for <code
+	      ><a href="#" title="PatternSyns"
+		>Empty</a
+		></code
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >pattern</span
+	    > <a id="v:PatWithExplicitSig" class="def"
+	    >PatWithExplicitSig</a
+	    > :: <a href="#" title="Data.Eq"
+	    >Eq</a
+	    > somex =&gt; somex -&gt; <a href="#" title="PatternSyns"
+	    >FooType</a
+	    > somex <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Earlier ghc versions didn't allow explicit signatures
+ on pattern synonyms.</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/PromotedTypes.html b/utils/haddock/html-test/ref/PromotedTypes.html
new file mode 100644
index 0000000000000000000000000000000000000000..75879b3a7befc1e5fd6723e8f8c4692233a04702
--- /dev/null
+++ b/utils/haddock/html-test/ref/PromotedTypes.html
@@ -0,0 +1,236 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >PromotedTypes</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>PromotedTypes</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:RevList" class="def"
+	    >RevList</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:RNil" class="def"
+		  >RNil</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>(<a href="#" title="PromotedTypes"
+		  >RevList</a
+		  > a) <a id="v::-62-" class="def"
+		  >:&gt;</a
+		  > a</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Pattern" class="def"
+	    >Pattern</a
+	    > (a :: [<a href="#" title="Data.Kind"
+	    >Type</a
+	    >]) <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Nil" class="def"
+		  >Nil</a
+		  > :: <a href="#" title="PromotedTypes"
+		  >Pattern</a
+		  > ('[] :: [<a href="#" title="Data.Kind"
+		  >Type</a
+		  >])</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Cons" class="def"
+		  >Cons</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > h (t :: [<a href="#" title="Data.Kind"
+		  >Type</a
+		  >]). <a href="#" title="Data.Maybe"
+		  >Maybe</a
+		  > h -&gt; <a href="#" title="PromotedTypes"
+		  >Pattern</a
+		  > t -&gt; <a href="#" title="PromotedTypes"
+		  >Pattern</a
+		  > (h ': t)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:RevPattern" class="def"
+	    >RevPattern</a
+	    > (a :: <a href="#" title="PromotedTypes"
+	    >RevList</a
+	    > <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:RevNil" class="def"
+		  >RevNil</a
+		  > :: <a href="#" title="PromotedTypes"
+		  >RevPattern</a
+		  > ('<a href="#" title="PromotedTypes"
+		  >RNil</a
+		  > :: <a href="#" title="PromotedTypes"
+		  >RevList</a
+		  > <a href="#" title="Data.Kind"
+		  >Type</a
+		  >)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:RevCons" class="def"
+		  >RevCons</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > h (t :: <a href="#" title="PromotedTypes"
+		  >RevList</a
+		  > <a href="#" title="Data.Kind"
+		  >Type</a
+		  >). <a href="#" title="Data.Maybe"
+		  >Maybe</a
+		  > h -&gt; <a href="#" title="PromotedTypes"
+		  >RevPattern</a
+		  > t -&gt; <a href="#" title="PromotedTypes"
+		  >RevPattern</a
+		  > (t '<a href="#" title="PromotedTypes"
+		  >:&gt;</a
+		  > h)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Tuple" class="def"
+	    >Tuple</a
+	    > (a :: (<a href="#" title="Data.Kind"
+	    >Type</a
+	    >, <a href="#" title="Data.Kind"
+	    >Type</a
+	    >)) <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Tuple" class="def"
+		  >Tuple</a
+		  > :: <span class="keyword"
+		  >forall</span
+		  > a1 b. a1 -&gt; b -&gt; <a href="#" title="PromotedTypes"
+		  >Tuple</a
+		  > '(a1, b)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Properties.html b/utils/haddock/html-test/ref/Properties.html
new file mode 100644
index 0000000000000000000000000000000000000000..aa9bc4adc4063c752c30be9788eacb752708f216
--- /dev/null
+++ b/utils/haddock/html-test/ref/Properties.html
@@ -0,0 +1,96 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Properties</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Properties</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >fib</a
+	      > :: <a href="#" title="Prelude"
+	      >Integer</a
+	      > -&gt; <a href="#" title="Prelude"
+	      >Integer</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:fib" class="def"
+	    >fib</a
+	    > :: <a href="#" title="Prelude"
+	    >Integer</a
+	    > -&gt; <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Fibonacci number of given <code
+	      ><a href="#" title="Prelude"
+		>Integer</a
+		></code
+	      >.</p
+	    ><pre
+	    >fib n &lt;= fib (n + 1)</pre
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/PruneWithWarning.html b/utils/haddock/html-test/ref/PruneWithWarning.html
new file mode 100644
index 0000000000000000000000000000000000000000..ba03144ea76ada484736bb3cf8d2e61b2c8a9fbb
--- /dev/null
+++ b/utils/haddock/html-test/ref/PruneWithWarning.html
@@ -0,0 +1,71 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >PruneWithWarning</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>PruneWithWarning</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >What is tested here:</p
+	  ><ul
+	  ><li
+	    >If a binding has a deprecation message but no documentation, it is pruned
+   when <code
+	      >OPTIONS_HADDOCK prune</code
+	      > is used.</li
+	    ></ul
+	  ></div
+	></div
+      ><div id="interface"
+      ></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/QuantifiedConstraints.html b/utils/haddock/html-test/ref/QuantifiedConstraints.html
new file mode 100644
index 0000000000000000000000000000000000000000..8838facb1a50ad29bc7b4ae26cc3da4bc33ebdf7
--- /dev/null
+++ b/utils/haddock/html-test/ref/QuantifiedConstraints.html
@@ -0,0 +1,108 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >QuantifiedConstraints</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>QuantifiedConstraints</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:fooed" class="def"
+	      >fooed</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:needsParensAroundContext" class="def"
+	    >needsParensAroundContext</a
+	    > :: (<span class="keyword"
+	    >forall</span
+	    > x. <a href="#" title="QuantifiedConstraints"
+	    >Foo</a
+	    > (f x)) =&gt; f <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:needsNoParensAroundContext" class="def"
+	    >needsNoParensAroundContext</a
+	    > :: <a href="#" title="QuantifiedConstraints"
+	    >Foo</a
+	    > (f <a href="#" title="Data.Int"
+	    >Int</a
+	    >) =&gt; f <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/QuasiExpr.html b/utils/haddock/html-test/ref/QuasiExpr.html
new file mode 100644
index 0000000000000000000000000000000000000000..25f4b0fabaed30125a42058d21db89d6de580b21
--- /dev/null
+++ b/utils/haddock/html-test/ref/QuasiExpr.html
@@ -0,0 +1,350 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >QuasiExpr</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>QuasiExpr</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Expr" class="def"
+	    >Expr</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:IntExpr" class="def"
+		  >IntExpr</a
+		  > <a href="#" title="Prelude"
+		  >Integer</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:AntiIntExpr" class="def"
+		  >AntiIntExpr</a
+		  > <a href="#" title="Data.String"
+		  >String</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:BinopExpr" class="def"
+		  >BinopExpr</a
+		  > <a href="#" title="QuasiExpr"
+		  >BinOp</a
+		  > <a href="#" title="QuasiExpr"
+		  >Expr</a
+		  > <a href="#" title="QuasiExpr"
+		  >Expr</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:AntiExpr" class="def"
+		  >AntiExpr</a
+		  > <a href="#" title="Data.String"
+		  >String</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Expr"
+	    >Instances</h4
+	    ><details id="i:Expr" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Expr:Show:1"
+		      ></span
+		      > <a href="#" title="Prelude"
+		      >Show</a
+		      > <a href="#" title="QuasiExpr"
+		      >Expr</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Expr:Show:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>QuasiExpr</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >showsPrec</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="QuasiExpr"
+			  >Expr</a
+			  > -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >show</a
+			  > :: <a href="#" title="QuasiExpr"
+			  >Expr</a
+			  > -&gt; <a href="#" title="Data.String"
+			  >String</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >showList</a
+			  > :: [<a href="#" title="QuasiExpr"
+			  >Expr</a
+			  >] -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:BinOp" class="def"
+	    >BinOp</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:AddOp" class="def"
+		  >AddOp</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:SubOp" class="def"
+		  >SubOp</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:MulOp" class="def"
+		  >MulOp</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:DivOp" class="def"
+		  >DivOp</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:BinOp"
+	    >Instances</h4
+	    ><details id="i:BinOp" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:BinOp:Show:1"
+		      ></span
+		      > <a href="#" title="Prelude"
+		      >Show</a
+		      > <a href="#" title="QuasiExpr"
+		      >BinOp</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:BinOp:Show:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>QuasiExpr</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >showsPrec</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="QuasiExpr"
+			  >BinOp</a
+			  > -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >show</a
+			  > :: <a href="#" title="QuasiExpr"
+			  >BinOp</a
+			  > -&gt; <a href="#" title="Data.String"
+			  >String</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >showList</a
+			  > :: [<a href="#" title="QuasiExpr"
+			  >BinOp</a
+			  >] -&gt; <a href="#" title="Prelude"
+			  >ShowS</a
+			  > <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:eval" class="def"
+	    >eval</a
+	    > :: <a href="#" title="QuasiExpr"
+	    >Expr</a
+	    > -&gt; <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:expr" class="def"
+	    >expr</a
+	    > :: <a href="#" title="Language.Haskell.TH.Quote"
+	    >QuasiQuoter</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:parseExprExp" class="def"
+	    >parseExprExp</a
+	    > :: <a href="#" title="Data.String"
+	    >String</a
+	    > -&gt; <a href="#" title="Language.Haskell.TH"
+	    >Q</a
+	    > <a href="#" title="Language.Haskell.TH"
+	    >Exp</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/QuasiQuote.html b/utils/haddock/html-test/ref/QuasiQuote.html
new file mode 100644
index 0000000000000000000000000000000000000000..155f27d8e894de3b509222a4d85a50a60f040a7a
--- /dev/null
+++ b/utils/haddock/html-test/ref/QuasiQuote.html
@@ -0,0 +1,68 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >QuasiQuote</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>QuasiQuote</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:val" class="def"
+	    >val</a
+	    > :: <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/SectionLabels.html b/utils/haddock/html-test/ref/SectionLabels.html
new file mode 100644
index 0000000000000000000000000000000000000000..5137afa45fba8bea6f817f573be678d8a44b8c17
--- /dev/null
+++ b/utils/haddock/html-test/ref/SectionLabels.html
@@ -0,0 +1,96 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >SectionLabels</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>SectionLabels</p
+	></div
+      ><div id="table-of-contents"
+      ><div id="contents-list"
+	><p class="caption" onclick="window.scrollTo(0,0)"
+	  >Contents</p
+	  ><ul
+	  ><li
+	    ><a href="#"
+	      >Section heading</a
+	      ></li
+	    ></ul
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >n</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><a href="#" id="g:custom"
+	><h1
+	  >Section heading</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:n" class="def"
+	    >n</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/SpuriousSuperclassConstraints.html b/utils/haddock/html-test/ref/SpuriousSuperclassConstraints.html
new file mode 100644
index 0000000000000000000000000000000000000000..6dadd6d7b78905a84ac726958cba111fa0911bb6
--- /dev/null
+++ b/utils/haddock/html-test/ref/SpuriousSuperclassConstraints.html
@@ -0,0 +1,250 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >SpuriousSuperclassConstraints</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>SpuriousSuperclassConstraints</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >What is tested here:</p
+	  ><p
+	  >Due to a change in GHC 7.6.1 we had a bug that superclass contraints were
+ included in the instances list.  Edward K. repported it here:</p
+	  ><p
+	  ><a href="#"
+	    >http://www.haskell.org/pipermail/haskell-cafe/2012-September/103600.html</a
+	    ></p
+	  ><p
+	  >And here is the corresponding thread on glasgow-haskell-users:</p
+	  ><p
+	  ><a href="#"
+	    >http://www.haskell.org/pipermail/glasgow-haskell-users/2012-September/022914.html</a
+	    ></p
+	  ><p
+	  >It has been fixed in:</p
+	  ><pre
+	  >6ccf78e15a525282fef61bc4f58a279aa9c21771
+Fix spurious superclass constraints bug.</pre
+	  ></div
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:SomeType" class="def"
+	    >SomeType</a
+	    > (f :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:SomeType"
+	    >Instances</h4
+	    ><details id="i:SomeType" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:SomeType:Applicative:1"
+		      ></span
+		      > <a href="#" title="Control.Applicative"
+		      >Applicative</a
+		      > f =&gt; <a href="#" title="Control.Applicative"
+		      >Applicative</a
+		      > (<a href="#" title="SpuriousSuperclassConstraints"
+		      >SomeType</a
+		      > f)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:SomeType:Applicative:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>SpuriousSuperclassConstraints</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >pure</a
+			  > :: a -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;*&gt;)</a
+			  > :: <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f (a -&gt; b) -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f a -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >liftA2</a
+			  > :: (a -&gt; b -&gt; c) -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f a -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f b -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f c <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(*&gt;)</a
+			  > :: <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f a -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f b -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;*)</a
+			  > :: <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f a -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f b -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:SomeType:Functor:2"
+		      ></span
+		      > <a href="#" title="Control.Monad"
+		      >Functor</a
+		      > (<a href="#" title="SpuriousSuperclassConstraints"
+		      >SomeType</a
+		      > f)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:SomeType:Functor:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>SpuriousSuperclassConstraints</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >fmap</a
+			  > :: (a -&gt; b) -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f a -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >(&lt;$)</a
+			  > :: a -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f b -&gt; <a href="#" title="SpuriousSuperclassConstraints"
+			  >SomeType</a
+			  > f a <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/T23616.html b/utils/haddock/html-test/ref/T23616.html
new file mode 100644
index 0000000000000000000000000000000000000000..7c2f53bb95f806f314d2750a58806d71e596a374
--- /dev/null
+++ b/utils/haddock/html-test/ref/T23616.html
@@ -0,0 +1,64 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >T23616</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>T23616</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:null" class="def"
+	    >null</a
+	    > :: <a href="#" title="Data.Foldable"
+	    >Foldable</a
+	    > t =&gt; t a -&gt; <a href="#" title="Data.Bool"
+	    >Bool</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/T24294.html b/utils/haddock/html-test/ref/T24294.html
new file mode 100644
index 0000000000000000000000000000000000000000..37a918af86c9711705bdb3539b353035f5a203e0
--- /dev/null
+++ b/utils/haddock/html-test/ref/T24294.html
@@ -0,0 +1,84 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >T24294</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>T24294</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >unfoldr</a
+	      > :: a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:unfoldr" class="def"
+	    >unfoldr</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><code
+	      ><a href="#" title="T24294"
+		>unfoldr</a
+		></code
+	      > needs to link to local definition and not to <code
+	      ><a href="#" title="Data.List"
+		>unfoldr</a
+		></code
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/TH.html b/utils/haddock/html-test/ref/TH.html
new file mode 100644
index 0000000000000000000000000000000000000000..0695f202ec08875cad7204dcde5ffd17c6590d79
--- /dev/null
+++ b/utils/haddock/html-test/ref/TH.html
@@ -0,0 +1,70 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >TH</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>TH</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:decl" class="def"
+	    >decl</a
+	    > :: <a href="#" title="Language.Haskell.TH"
+	    >Q</a
+	    > [<a href="#" title="Language.Haskell.TH"
+	    >Dec</a
+	    >] <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/TH2.html b/utils/haddock/html-test/ref/TH2.html
new file mode 100644
index 0000000000000000000000000000000000000000..f9191fb414a78c456058c8bbcd1bff3215b6e66a
--- /dev/null
+++ b/utils/haddock/html-test/ref/TH2.html
@@ -0,0 +1,66 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >TH2</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>TH2</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: p -&gt; p <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Table.html b/utils/haddock/html-test/ref/Table.html
new file mode 100644
index 0000000000000000000000000000000000000000..01f741198b8cc9c11ea6810e7b6b975f857e7278
--- /dev/null
+++ b/utils/haddock/html-test/ref/Table.html
@@ -0,0 +1,248 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Table</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Table</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >This tests the table markup</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >tableWithHeader</a
+	      > :: a -&gt; a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >tableWithoutHeader</a
+	      > :: a -&gt; a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >fancyTable</a
+	      > :: a -&gt; a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:tableWithHeader" class="def"
+	    >tableWithHeader</a
+	    > :: a -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Table with header.</p
+	    ><table
+	    ><thead
+	      ><tr
+		><th
+		  >code</th
+		  ><th
+		  >message</th
+		  ><th
+		  >description</th
+		  ></tr
+		></thead
+	      ><tbody
+	      ><tr
+		><td
+		  >200</td
+		  ><td
+		  ><code
+		    >OK</code
+		    ></td
+		  ><td
+		  >operation successful</td
+		  ></tr
+		><tr
+		><td
+		  >204</td
+		  ><td
+		  ><code
+		    >No Content</code
+		    ></td
+		  ><td
+		  >operation successful, no body returned</td
+		  ></tr
+		></tbody
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:tableWithoutHeader" class="def"
+	    >tableWithoutHeader</a
+	    > :: a -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Table without header.</p
+	    ><table
+	    ><tbody
+	      ><tr
+		><td
+		  >200</td
+		  ><td
+		  ><code
+		    >OK</code
+		    ></td
+		  ><td
+		  >operation successful</td
+		  ></tr
+		><tr
+		><td
+		  >204</td
+		  ><td
+		  ><code
+		    >No Content</code
+		    ></td
+		  ><td
+		  >operation successful, no body returned</td
+		  ></tr
+		><tr
+		><td
+		  >404</td
+		  ><td
+		  ><code
+		    >Not Found</code
+		    ></td
+		  ><td
+		  >resource not found</td
+		  ></tr
+		></tbody
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:fancyTable" class="def"
+	    >fancyTable</a
+	    > :: a -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Fancy table.</p
+	    ><table
+	    ><thead
+	      ><tr
+		><th
+		  >Header row, column 1
+(header rows optional)</th
+		  ><th
+		  >Header 2
+</th
+		  ><th
+		  >Header 3
+</th
+		  ><th
+		  >Header 4
+</th
+		  ></tr
+		></thead
+	      ><tbody
+	      ><tr
+		><td
+		  >body row 1, column 1</td
+		  ><td
+		  >column 2</td
+		  ><td
+		  >column 3</td
+		  ><td
+		  >column 4</td
+		  ></tr
+		><tr
+		><td
+		  ><code
+		    ><a href="#" title="Table"
+		      >tableWithHeader</a
+		      ></code
+		    ></td
+		  ><td colspan="3"
+		  >Cells may span columns.</td
+		  ></tr
+		><tr
+		><td
+		  >body row 3</td
+		  ><td rowspan="2"
+		  >Cells may
+span rows.
+</td
+		  ><td colspan="2" rowspan="2"
+		  ><span class="mathjax"
+		    >\[
+f(n) = \sum_{i=1}
+\]</span
+		    ></td
+		  ></tr
+		><tr
+		><td
+		  >body row 4</td
+		  ></tr
+		></tbody
+	      ></table
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Test.html b/utils/haddock/html-test/ref/Test.html
new file mode 100644
index 0000000000000000000000000000000000000000..e2966dfd54afc31f70e958319b24edc0c56b1e23
--- /dev/null
+++ b/utils/haddock/html-test/ref/Test.html
@@ -0,0 +1,2480 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Test</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th valign="top"
+	    >Copyright</th
+	    ><td
+	    >(c) Simon Marlow 2002</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >License</th
+	    ><td
+	    >BSD-style</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Maintainer</th
+	    ><td
+	    >libraries@haskell.org</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Stability</th
+	    ><td
+	    >provisional</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Portability</th
+	    ><td
+	    >portable</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Test</p
+	></div
+      ><div id="table-of-contents"
+      ><div id="contents-list"
+	><p class="caption" onclick="window.scrollTo(0,0)"
+	  >Contents</p
+	  ><ul
+	  ><li
+	    ><a href="#"
+	      >Type declarations</a
+	      ><ul
+	      ><li
+		><a href="#"
+		  >Data types</a
+		  ></li
+		><li
+		><a href="#"
+		  >Records</a
+		  ></li
+		></ul
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Class declarations</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Function types</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Auxiliary stuff</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >A hidden module</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >A visible module</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Existential / Universal types</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >Type signatures with argument docs</a
+	      ></li
+	    ><li
+	    ><a href="#"
+	      >A section</a
+	      ><ul
+	      ><li
+		><a href="#"
+		  >A subsection</a
+		  ></li
+		></ul
+	      ></li
+	    ></ul
+	  ></div
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >This module illustrates &amp; tests most of the features of Haddock.
+ Testing references from the description: <code
+	    ><a href="#" title="Test"
+	      >T</a
+	      ></code
+	    >, <code
+	    ><a href="#" title="Test"
+	      >f</a
+	      ></code
+	    >, <code
+	    ><a href="#" title="Test"
+	      >g</a
+	      ></code
+	    >, <code
+	    ><a href="#" title="Visible"
+	      >visible</a
+	      ></code
+	    >.</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >T</a
+	      > a b<ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >A</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > (<a href="#" title="Data.Maybe"
+		  >Maybe</a
+		  > <a href="#" title="GHC.Exts"
+		  >Float</a
+		  >)</li
+		><li
+		>| <a href="#"
+		  >B</a
+		  > (<a href="#" title="Test"
+		  >T</a
+		  > a b, <a href="#" title="Test"
+		  >T</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > <a href="#" title="GHC.Exts"
+		  >Float</a
+		  >)</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >T2</a
+	      > a b</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >T3</a
+	      > a b<ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >A1</a
+		  > a</li
+		><li
+		>| <a href="#"
+		  >B1</a
+		  > b</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >T4</a
+	      > a b<ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >A2</a
+		  > a</li
+		><li
+		>| <a href="#"
+		  >B2</a
+		  > b</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >T5</a
+	      > a b<ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >A3</a
+		  > a</li
+		><li
+		>| <a href="#"
+		  >B3</a
+		  > b</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >T6</a
+	      ><ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >A4</a
+		  ></li
+		><li
+		>| <a href="#"
+		  >B4</a
+		  ></li
+		><li
+		>| <a href="#"
+		  >C4</a
+		  ></li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >newtype</span
+	      > <a href="#"
+	      >N1</a
+	      > a = <a href="#"
+	      >N1</a
+	      > a</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >newtype</span
+	      > <a href="#"
+	      >N2</a
+	      > (a :: <a href="#" title="Data.Kind"
+	      >Type</a
+	      > -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      >) b = <a href="#"
+	      >N2</a
+	      > {<ul class="subs"
+	      ><li
+		><a href="#"
+		  >n</a
+		  > :: a b</li
+		></ul
+	      >}</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >newtype</span
+	      > <a href="#"
+	      >N3</a
+	      > (a :: <a href="#" title="Data.Kind"
+	      >Type</a
+	      > -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      >) b = <a href="#"
+	      >N3</a
+	      > {<ul class="subs"
+	      ><li
+		><a href="#"
+		  >n3</a
+		  > :: a b</li
+		></ul
+	      >}</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >N4</a
+	      > a b</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >newtype</span
+	      > <a href="#"
+	      >N5</a
+	      > (a :: <a href="#" title="Data.Kind"
+	      >Type</a
+	      > -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      >) b = <a href="#"
+	      >N5</a
+	      > {<ul class="subs"
+	      ><li
+		><a href="#"
+		  >n5</a
+		  > :: a b</li
+		></ul
+	      >}</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >newtype</span
+	      > <a href="#"
+	      >N6</a
+	      > (a :: <a href="#" title="Data.Kind"
+	      >Type</a
+	      > -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      >) b = <a href="#"
+	      >N6</a
+	      > {<ul class="subs"
+	      ><li
+		><a href="#"
+		  >n6</a
+		  > :: a b</li
+		></ul
+	      >}</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >newtype</span
+	      > <a href="#"
+	      >N7</a
+	      > (a :: <a href="#" title="Data.Kind"
+	      >Type</a
+	      > -&gt; <a href="#" title="Data.Kind"
+	      >Type</a
+	      >) b = <a href="#"
+	      >N7</a
+	      > {<ul class="subs"
+	      ><li
+		><a href="#"
+		  >n7</a
+		  > :: a b</li
+		></ul
+	      >}</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >R</a
+	      ><ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >C1</a
+		  > { <ul class="subs"
+		  ><li
+		    ><a href="#"
+		      >p</a
+		      > :: <a href="#" title="Data.Int"
+		      >Int</a
+		      ></li
+		    ><li
+		    ><a href="#"
+		      >q</a
+		      > :: <span class="keyword"
+		      >forall</span
+		      > a. a -&gt; a</li
+		    ><li
+		    ><a href="#"
+		      >r</a
+		      > :: <a href="#" title="Data.Int"
+		      >Int</a
+		      ></li
+		    ><li
+		    ><a href="#"
+		      >s</a
+		      > :: <a href="#" title="Data.Int"
+		      >Int</a
+		      ></li
+		    ></ul
+		  > }</li
+		><li
+		>| <a href="#"
+		  >C2</a
+		  > { <ul class="subs"
+		  ><li
+		    ><a href="#"
+		      >t</a
+		      > :: T1 -&gt; <a href="#" title="Test"
+		      >T2</a
+		      > <a href="#" title="Data.Int"
+		      >Int</a
+		      > <a href="#" title="Data.Int"
+		      >Int</a
+		      > -&gt; <a href="#" title="Test"
+		      >T3</a
+		      > <a href="#" title="Data.Bool"
+		      >Bool</a
+		      > <a href="#" title="Data.Bool"
+		      >Bool</a
+		      > -&gt; <a href="#" title="Test"
+		      >T4</a
+		      > <a href="#" title="GHC.Exts"
+		      >Float</a
+		      > <a href="#" title="GHC.Exts"
+		      >Float</a
+		      > -&gt; <a href="#" title="Test"
+		      >T5</a
+		      > () ()</li
+		    ><li
+		    ><a href="#"
+		      >u</a
+		      > :: <a href="#" title="Data.Int"
+		      >Int</a
+		      ></li
+		    ><li
+		    ><a href="#"
+		      >v</a
+		      > :: <a href="#" title="Data.Int"
+		      >Int</a
+		      ></li
+		    ></ul
+		  > }</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >R1</a
+	      > = <a href="#"
+	      >C3</a
+	      > {<ul class="subs"
+	      ><li
+		><a href="#"
+		  >s1</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  ></li
+		><li
+		><a href="#"
+		  >s2</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  ></li
+		><li
+		><a href="#"
+		  >s3</a
+		  > :: <a href="#" title="Data.Int"
+		  >Int</a
+		  ></li
+		></ul
+	      >}</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >p</a
+	      > :: <a href="#" title="Test"
+	      >R</a
+	      > -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >q</a
+	      > :: <a href="#" title="Test"
+	      >R</a
+	      > -&gt; <span class="keyword"
+	      >forall</span
+	      > a. a -&gt; a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >u</a
+	      > :: <a href="#" title="Test"
+	      >R</a
+	      > -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#" title="Test"
+	      >D</a
+	      > a =&gt; <a href="#"
+	      >C</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >a</a
+		  > :: <a href="#" title="Prelude"
+		  >IO</a
+		  > a</li
+		><li
+		><a href="#"
+		  >b</a
+		  > :: [a]</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >D</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >d</a
+		  > :: <a href="#" title="Test"
+		  >T</a
+		  > a b</li
+		><li
+		><a href="#"
+		  >e</a
+		  > :: (a, a)</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >E</a
+	      > a</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >F</a
+	      > a <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><a href="#"
+		  >ff</a
+		  > :: a</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >a</a
+	      > :: <a href="#" title="Test"
+	      >C</a
+	      > a =&gt; <a href="#" title="Prelude"
+	      >IO</a
+	      > a</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: <a href="#" title="Test"
+	      >C</a
+	      > a =&gt; a -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >g</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; <a href="#" title="Prelude"
+	      >IO</a
+	      > CInt</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >hidden</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    >module <a href="#"
+	      >Visible</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Ex</a
+	      > a<ul class="subs"
+	      ><li
+		>= <a href="#" title="Test"
+		  >C</a
+		  > b =&gt;  <a href="#"
+		  >Ex1</a
+		  > b</li
+		><li
+		>| <a href="#"
+		  >Ex2</a
+		  > b</li
+		><li
+		>| <a href="#" title="Test"
+		  >C</a
+		  > a =&gt;  <a href="#"
+		  >Ex3</a
+		  > b</li
+		><li
+		>| <a href="#"
+		  >Ex4</a
+		  > (<span class="keyword"
+		  >forall</span
+		  > a1. a1 -&gt; a1)</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >k</a
+	      > :: <a href="#" title="Test"
+	      >T</a
+	      > () () -&gt; <a href="#" title="Test"
+	      >T2</a
+	      > <a href="#" title="Data.Int"
+	      >Int</a
+	      > <a href="#" title="Data.Int"
+	      >Int</a
+	      > -&gt; (<a href="#" title="Test"
+	      >T3</a
+	      > <a href="#" title="Data.Bool"
+	      >Bool</a
+	      > <a href="#" title="Data.Bool"
+	      >Bool</a
+	      > -&gt; <a href="#" title="Test"
+	      >T4</a
+	      > <a href="#" title="GHC.Exts"
+	      >Float</a
+	      > <a href="#" title="GHC.Exts"
+	      >Float</a
+	      >) -&gt; <a href="#" title="Test"
+	      >T5</a
+	      > () () -&gt; <a href="#" title="Prelude"
+	      >IO</a
+	      > ()</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >l</a
+	      > :: (<a href="#" title="Data.Int"
+	      >Int</a
+	      >, <a href="#" title="Data.Int"
+	      >Int</a
+	      >, <a href="#" title="GHC.Exts"
+	      >Float</a
+	      >) -&gt; <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >m</a
+	      > :: <a href="#" title="Test"
+	      >R</a
+	      > -&gt; <a href="#" title="Test"
+	      >N1</a
+	      > () -&gt; <a href="#" title="Prelude"
+	      >IO</a
+	      > <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >o</a
+	      > :: <a href="#" title="GHC.Exts"
+	      >Float</a
+	      > -&gt; <a href="#" title="Prelude"
+	      >IO</a
+	      > <a href="#" title="GHC.Exts"
+	      >Float</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >f'</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >withType</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >withoutType</a
+	      > :: a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><a href="#" id="g:1"
+	><h1
+	  >Type declarations</h1
+	  ></a
+	><a href="#" id="g:2"
+	><h2
+	  >Data types</h2
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:T" class="def"
+	    >T</a
+	    > a b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This comment applies to the <em
+	      >following</em
+	      > declaration
+ and it continues until the next non-comment line</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:A" class="def"
+		  >A</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > (<a href="#" title="Data.Maybe"
+		  >Maybe</a
+		  > <a href="#" title="GHC.Exts"
+		  >Float</a
+		  >)</td
+		><td class="doc"
+		><p
+		  >This comment describes the <code
+		    ><a href="#" title="Test"
+		      >A</a
+		      ></code
+		    > constructor</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:B" class="def"
+		  >B</a
+		  > (<a href="#" title="Test"
+		  >T</a
+		  > a b, <a href="#" title="Test"
+		  >T</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > <a href="#" title="GHC.Exts"
+		  >Float</a
+		  >)</td
+		><td class="doc"
+		><p
+		  >This comment describes the <code
+		    ><a href="#" title="Test"
+		      >B</a
+		      ></code
+		    > constructor</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:T2" class="def"
+	    >T2</a
+	    > a b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >An abstract data declaration</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:T3" class="def"
+	    >T3</a
+	    > a b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A data declaration with no documentation annotations on the constructors</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:A1" class="def"
+		  >A1</a
+		  > a</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:B1" class="def"
+		  >B1</a
+		  > b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:T4" class="def"
+	    >T4</a
+	    > a b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:A2" class="def"
+		  >A2</a
+		  > a</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:B2" class="def"
+		  >B2</a
+		  > b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:T5" class="def"
+	    >T5</a
+	    > a b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:A3" class="def"
+		  >A3</a
+		  > a</td
+		><td class="doc"
+		><p
+		  >documents <code
+		    ><a href="#" title="Test"
+		      >A3</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:B3" class="def"
+		  >B3</a
+		  > b</td
+		><td class="doc"
+		><p
+		  >documents <code
+		    ><a href="#" title="Test"
+		      >B3</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:T6" class="def"
+	    >T6</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Testing alternative comment styles</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:A4" class="def"
+		  >A4</a
+		  ></td
+		><td class="doc"
+		><p
+		  >This is the doc for <code
+		    ><a href="#" title="Test"
+		      >A4</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:B4" class="def"
+		  >B4</a
+		  ></td
+		><td class="doc"
+		><p
+		  >This is the doc for <code
+		    ><a href="#" title="Test"
+		      >B4</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:C4" class="def"
+		  >C4</a
+		  ></td
+		><td class="doc"
+		><p
+		  >This is the doc for <code
+		    ><a href="#" title="Test"
+		      >C4</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:N1" class="def"
+	    >N1</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A newtype</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:N1" class="def"
+		  >N1</a
+		  > a</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:N2" class="def"
+	    >N2</a
+	    > (a :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A newtype with a fieldname</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:N2" class="def"
+		  >N2</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:n" class="def"
+			  >n</a
+			  > :: a b</dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:N3" class="def"
+	    >N3</a
+	    > (a :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A newtype with a fieldname, documentation on the field</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:N3" class="def"
+		  >N3</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:n3" class="def"
+			  >n3</a
+			  > :: a b</dfn
+			><div class="doc"
+			><p
+			  >this is the <code
+			    ><a href="#" title="Test"
+			      >n3</a
+			      ></code
+			    > field</p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:N4" class="def"
+	    >N4</a
+	    > a b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >An abstract newtype - we show this one as data rather than newtype because
+ the difference isn't visible to the programmer for an abstract type.</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:N5" class="def"
+	    >N5</a
+	    > (a :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:N5" class="def"
+		  >N5</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:n5" class="def"
+			  >n5</a
+			  > :: a b</dfn
+			><div class="doc"
+			><p
+			  >no docs on the datatype or the constructor</p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:N6" class="def"
+	    >N6</a
+	    > (a :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:N6" class="def"
+		  >N6</a
+		  ></td
+		><td class="doc"
+		><p
+		  >docs on the constructor only</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:n6" class="def"
+			  >n6</a
+			  > :: a b</dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:N7" class="def"
+	    >N7</a
+	    > (a :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >docs on the newtype and the constructor</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:N7" class="def"
+		  >N7</a
+		  ></td
+		><td class="doc"
+		><p
+		  >The <code
+		    ><a href="#" title="Test"
+		      >N7</a
+		      ></code
+		    > constructor</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:n7" class="def"
+			  >n7</a
+			  > :: a b</dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><a href="#" id="g:3"
+	><h2
+	  >Records</h2
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:R" class="def"
+	    >R</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This is the documentation for the <code
+	      ><a href="#" title="Test"
+		>R</a
+		></code
+	      > record, which has four fields,
+ <code
+	      ><a href="#" title="Test"
+		>p</a
+		></code
+	      >, <code
+	      ><a href="#" title="Test"
+		>q</a
+		></code
+	      >, <code
+	      ><a href="#" title="Test"
+		>r</a
+		></code
+	      >, and <code
+	      ><a href="#" title="Test"
+		>s</a
+		></code
+	      >.</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:C1" class="def"
+		  >C1</a
+		  ></td
+		><td class="doc"
+		><p
+		  >This is the <code
+		    ><a href="#" title="Test"
+		      >C1</a
+		      ></code
+		    > record constructor, with the following fields:</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:p" class="def"
+			  >p</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >This comment applies to the <code
+			    ><a href="#" title="Test"
+			      >p</a
+			      ></code
+			    > field</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:q" class="def"
+			  >q</a
+			  > :: <span class="keyword"
+			  >forall</span
+			  > a. a -&gt; a</dfn
+			><div class="doc"
+			><p
+			  >This comment applies to the <code
+			    ><a href="#" title="Test"
+			      >q</a
+			      ></code
+			    > field</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:r" class="def"
+			  >r</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >This comment applies to both <code
+			    ><a href="#" title="Test"
+			      >r</a
+			      ></code
+			    > and <code
+			    ><a href="#" title="Test"
+			      >s</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:s" class="def"
+			  >s</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >This comment applies to both <code
+			    ><a href="#" title="Test"
+			      >r</a
+			      ></code
+			    > and <code
+			    ><a href="#" title="Test"
+			      >s</a
+			      ></code
+			    ></p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:C2" class="def"
+		  >C2</a
+		  ></td
+		><td class="doc"
+		><p
+		  >This is the <code
+		    ><a href="#" title="Test"
+		      >C2</a
+		      ></code
+		    > record constructor, also with some fields:</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:t" class="def"
+			  >t</a
+			  > :: T1 -&gt; <a href="#" title="Test"
+			  >T2</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  > -&gt; <a href="#" title="Test"
+			  >T3</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > <a href="#" title="Data.Bool"
+			  >Bool</a
+			  > -&gt; <a href="#" title="Test"
+			  >T4</a
+			  > <a href="#" title="GHC.Exts"
+			  >Float</a
+			  > <a href="#" title="GHC.Exts"
+			  >Float</a
+			  > -&gt; <a href="#" title="Test"
+			  >T5</a
+			  > () ()</dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:u" class="def"
+			  >u</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:v" class="def"
+			  >v</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:R1" class="def"
+	    >R1</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Testing different record commenting styles</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:C3" class="def"
+		  >C3</a
+		  ></td
+		><td class="doc"
+		><p
+		  >This is the <code
+		    ><a href="#" title="Test"
+		      >C3</a
+		      ></code
+		    > record constructor</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:s1" class="def"
+			  >s1</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >The <code
+			    ><a href="#" title="Test"
+			      >s1</a
+			      ></code
+			    > record selector</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:s2" class="def"
+			  >s2</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >The <code
+			    ><a href="#" title="Test"
+			      >s2</a
+			      ></code
+			    > record selector</p
+			  ></div
+			></li
+		      ><li
+		      ><dfn class="src"
+			><a id="v:s3" class="def"
+			  >s3</a
+			  > :: <a href="#" title="Data.Int"
+			  >Int</a
+			  ></dfn
+			><div class="doc"
+			><p
+			  >The <code
+			    ><a href="#" title="Test"
+			      >s3</a
+			      ></code
+			    > record selector</p
+			  ></div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="doc"
+	><p
+	  >test that we can export record selectors on their own:</p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:p" class="def"
+	    >p</a
+	    > :: <a href="#" title="Test"
+	    >R</a
+	    > -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This comment applies to the <code
+	      ><a href="#" title="Test"
+		>p</a
+		></code
+	      > field</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:q" class="def"
+	    >q</a
+	    > :: <a href="#" title="Test"
+	    >R</a
+	    > -&gt; <span class="keyword"
+	    >forall</span
+	    > a. a -&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This comment applies to the <code
+	      ><a href="#" title="Test"
+		>q</a
+		></code
+	      > field</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:u" class="def"
+	    >u</a
+	    > :: <a href="#" title="Test"
+	    >R</a
+	    > -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><a href="#" id="g:4"
+	><h1
+	  >Class declarations</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a href="#" title="Test"
+	    >D</a
+	    > a =&gt; <a id="t:C" class="def"
+	    >C</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This comment applies to the <em
+	      >previous</em
+	      > declaration (the <code
+	      ><a href="#" title="Test"
+		>C</a
+		></code
+	      > class)</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:a" class="def"
+	      >a</a
+	      > :: <a href="#" title="Prelude"
+	      >IO</a
+	      > a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >this is a description of the <code
+		><a href="#" title="Test"
+		  >a</a
+		  ></code
+		> method</p
+	      ></div
+	    ><p class="src"
+	    ><a id="v:b" class="def"
+	      >b</a
+	      > :: [a] <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >this is a description of the <code
+		><a href="#" title="Test"
+		  >b</a
+		  ></code
+		> method</p
+	      ></div
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:D" class="def"
+	    >D</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This is a class declaration with no separate docs for the methods</p
+	    ></div
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:d" class="def"
+	      >d</a
+	      > :: <a href="#" title="Test"
+	      >T</a
+	      > a b <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><p class="src"
+	    ><a id="v:e" class="def"
+	      >e</a
+	      > :: (a, a) <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:D"
+	    >Instances</h4
+	    ><details id="i:D" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:D:D:1"
+		      ></span
+		      > <a href="#" title="Test"
+		      >D</a
+		      > <a href="#" title="GHC.Exts"
+		      >Float</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:D:D:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Test</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >d</a
+			  > :: <a href="#" title="Test"
+			  >T</a
+			  > <a href="#" title="GHC.Exts"
+			  >Float</a
+			  > b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >e</a
+			  > :: (<a href="#" title="GHC.Exts"
+			  >Float</a
+			  >, <a href="#" title="GHC.Exts"
+			  >Float</a
+			  >) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:D:D:2"
+		      ></span
+		      > <a href="#" title="Test"
+		      >D</a
+		      > <a href="#" title="Data.Int"
+		      >Int</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:D:D:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>Test</a
+			></p
+		      > <div class="subs methods"
+		      ><p class="caption"
+			>Methods</p
+			><p class="src"
+			><a href="#"
+			  >d</a
+			  > :: <a href="#" title="Test"
+			  >T</a
+			  > <a href="#" title="Data.Int"
+			  >Int</a
+			  > b <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			><p class="src"
+			><a href="#"
+			  >e</a
+			  > :: (<a href="#" title="Data.Int"
+			  >Int</a
+			  >, <a href="#" title="Data.Int"
+			  >Int</a
+			  >) <a href="#" class="selflink"
+			  >#</a
+			  ></p
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:E" class="def"
+	    >E</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >This is a class declaration with no methods (or no methods exported)</p
+	    ></div
+	  ><div class="subs minimal"
+	  ><p class="caption"
+	    >Minimal complete definition</p
+	    ><p class="src"
+	    >ee</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:F" class="def"
+	    >F</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:ff" class="def"
+	      >ff</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ></div
+	  ></div
+	><div class="doc"
+	><p
+	  >Test that we can export a class method on its own:</p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:a" class="def"
+	    >a</a
+	    > :: <a href="#" title="Test"
+	    >C</a
+	    > a =&gt; <a href="#" title="Prelude"
+	    >IO</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >this is a description of the <code
+	      ><a href="#" title="Test"
+		>a</a
+		></code
+	      > method</p
+	    ></div
+	  ></div
+	><a href="#" id="g:5"
+	><h1
+	  >Function types</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: <a href="#" title="Test"
+	    >C</a
+	    > a =&gt; a -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >In a comment string we can refer to identifiers in scope with
+single quotes like this: <code
+	      ><a href="#" title="Test"
+		>T</a
+		></code
+	      >, and we can refer to modules by
+using double quotes: <a href="#"
+	      >Foo</a
+	      >.  We can add emphasis <em
+	      >like this</em
+	      >.</p
+	    ><ul
+	    ><li
+	      >This is a bulleted list</li
+	      ><li
+	      >This is the next item (different kind of bullet)</li
+	      ></ul
+	    ><ol
+	    ><li value="1"
+	      >This is an ordered list</li
+	      ><li value="2"
+	      >This is the next item (different kind of bullet)</li
+	      ></ol
+	    ><dl
+	    ><dt
+	      >cat</dt
+	      ><dd
+	      >a small, furry, domesticated mammal</dd
+	      ><dt
+	      >pineapple</dt
+	      ><dd
+	      >a fruit grown in the tropics</dd
+	      ></dl
+	    ><pre
+	    >     This is a block of code, which can include other markup: <code
+	      ><a href="#" title="Test"
+		>R</a
+		></code
+	      >
+     formatting
+               is
+                 significant
+</pre
+	    ><pre
+	    >this is another block of code</pre
+	    ><p
+	    >We can also include URLs in documentation: <a href="#"
+	      >http://www.haskell.org/</a
+	      >.</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:g" class="def"
+	    >g</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > -&gt; <a href="#" title="Prelude"
+	    >IO</a
+	    > CInt <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >we can export foreign declarations too</p
+	    ></div
+	  ></div
+	><a href="#" id="g:6"
+	><h1
+	  >Auxiliary stuff</h1
+	  ></a
+	><div class="doc"
+	><p
+	  >This is some documentation that is attached to a name ($aux1)
+ rather than a source declaration.  The documentation may be
+ referred to in the export list using its name.</p
+	  ><pre
+	  > code block in named doc</pre
+	  ></div
+	><div class="doc"
+	><p
+	  >This is some documentation that is attached to a name ($aux2)</p
+	  ></div
+	><div class="doc"
+	><pre
+	  > code block on its own in named doc</pre
+	  ></div
+	><div class="doc"
+	><pre
+	  > code block on its own in named doc (after newline)</pre
+	  ></div
+	><div class="doc"
+	><p
+	  >a nested, named doc comment</p
+	  ><p
+	  >with a paragraph,</p
+	  ><pre
+	  > and a code block</pre
+	  ></div
+	><div class="doc"
+	><pre
+	  >test
+test1</pre
+	  ><pre
+	  > test2
+  test3
+</pre
+	  ></div
+	><div class="doc"
+	><pre
+	  >test1
+test2
+</pre
+	  ></div
+	><div class="doc"
+	><pre
+	  >test3
+test4</pre
+	  ></div
+	><div class="doc"
+	><pre
+	  >test1
+test2
+</pre
+	  ><pre
+	  >test3
+test4</pre
+	  ></div
+	><div class="doc"
+	><pre
+	  >test3
+test4</pre
+	  ><pre
+	  >test1
+test2
+</pre
+	  ></div
+	><div class="doc"
+	><p
+	  >aux11:</p
+	  ><pre
+	  >test3
+test4</pre
+	  ><pre
+	  >test1
+test2
+</pre
+	  ></div
+	><div class="doc"
+	><pre
+	  >foo</pre
+	  ><pre
+	  >bar</pre
+	  ></div
+	><div class="doc"
+	><p
+	  >This is some inline documentation in the export list</p
+	  ><pre
+	  >a code block using bird-tracks
+each line must begin with &gt; (which isn't significant unless it
+is at the beginning of the line).</pre
+	  ></div
+	><a href="#" id="g:7"
+	><h1
+	  >A hidden module</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:hidden" class="def"
+	    >hidden</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><a href="#" id="g:8"
+	><h1
+	  >A visible module</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  >module <a href="#"
+	    >Visible</a
+	    ></p
+	  ></div
+	><div class="doc"
+	><p
+	  >nested-style doc comments </p
+	  ></div
+	><a href="#" id="g:9"
+	><h1
+	  >Existential / Universal types</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Ex" class="def"
+	    >Ex</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A data-type using existential/universal types</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a href="#" title="Test"
+		  >C</a
+		  > b =&gt;  <a id="v:Ex1" class="def"
+		  >Ex1</a
+		  > b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Ex2" class="def"
+		  >Ex2</a
+		  > b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a href="#" title="Test"
+		  >C</a
+		  > a =&gt;  <a id="v:Ex3" class="def"
+		  >Ex3</a
+		  > b</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:Ex4" class="def"
+		  >Ex4</a
+		  > (<span class="keyword"
+		  >forall</span
+		  > a1. a1 -&gt; a1)</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><a href="#" id="g:10"
+	><h1
+	  >Type signatures with argument docs</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:k" class="def"
+	    >k</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: <a href="#" title="Test"
+		  >T</a
+		  > () ()</td
+		><td class="doc"
+		><p
+		  >This argument has type <code
+		    ><a href="#" title="Test"
+		      >T</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="Test"
+		  >T2</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc"
+		><p
+		  >This argument has type 'T2 Int Int'</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; (<a href="#" title="Test"
+		  >T3</a
+		  > <a href="#" title="Data.Bool"
+		  >Bool</a
+		  > <a href="#" title="Data.Bool"
+		  >Bool</a
+		  > -&gt; <a href="#" title="Test"
+		  >T4</a
+		  > <a href="#" title="GHC.Exts"
+		  >Float</a
+		  > <a href="#" title="GHC.Exts"
+		  >Float</a
+		  >)</td
+		><td class="doc"
+		><p
+		  >This argument has type <code
+		    >T3 Bool Bool -&gt; T4 Float Float</code
+		    ></p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="Test"
+		  >T5</a
+		  > () ()</td
+		><td class="doc"
+		><p
+		  >This argument has a very long description that should
+ hopefully cause some wrapping to happen when it is finally
+ rendered by Haddock in the generated HTML page.</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="Prelude"
+		  >IO</a
+		  > ()</td
+		><td class="doc"
+		><p
+		  >This is the result type</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="doc"
+	  ><p
+	    >This is a function with documentation for each argument</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:l" class="def"
+	    >l</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: (<a href="#" title="Data.Int"
+		  >Int</a
+		  >, <a href="#" title="Data.Int"
+		  >Int</a
+		  >, <a href="#" title="GHC.Exts"
+		  >Float</a
+		  >)</td
+		><td class="doc"
+		><p
+		  >takes a triple</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc"
+		><p
+		  >returns an <code
+		    ><a href="#" title="Data.Int"
+		      >Int</a
+		      ></code
+		    ></p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:m" class="def"
+	    >m</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: <a href="#" title="Test"
+		  >R</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="Test"
+		  >N1</a
+		  > ()</td
+		><td class="doc"
+		><p
+		  >one of the arguments</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="Prelude"
+		  >IO</a
+		  > <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc"
+		><p
+		  >and the return value</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="doc"
+	  ><p
+	    >This function has some arg docs</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:o" class="def"
+	    >o</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs arguments"
+	  ><p class="caption"
+	    >Arguments</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		>:: <a href="#" title="GHC.Exts"
+		  >Float</a
+		  ></td
+		><td class="doc"
+		><p
+		  >The input float</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		>-&gt; <a href="#" title="Prelude"
+		  >IO</a
+		  > <a href="#" title="GHC.Exts"
+		  >Float</a
+		  ></td
+		><td class="doc"
+		><p
+		  >The output float</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="doc"
+	  ><p
+	    >A foreign import with argument docs</p
+	    ></div
+	  ></div
+	><a href="#" id="g:11"
+	><h1
+	  >A section</h1
+	  ></a
+	><a href="#" id="g:12"
+	><h2
+	  >A subsection</h2
+	  ></a
+	><div class="doc"
+	><pre
+	  >a literal line</pre
+	  ><p
+	  >$ a non <em
+	    >literal</em
+	    > line $</p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f-39-" class="def"
+	    >f'</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >a function with a prime can be referred to as <code
+	      ><a href="#" title="Test"
+		>f'</a
+		></code
+	      >
+ but f' doesn't get link'd 'f''</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:withType" class="def"
+	    >withType</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Comment on a definition with type signature</p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:withoutType" class="def"
+	    >withoutType</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Comment on a definition without type signature</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Threaded.html b/utils/haddock/html-test/ref/Threaded.html
new file mode 100644
index 0000000000000000000000000000000000000000..f5ac3046aa53d1f9aa8c968127122d83d6d6a227
--- /dev/null
+++ b/utils/haddock/html-test/ref/Threaded.html
@@ -0,0 +1,99 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Threaded</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Threaded</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >Ensures haddock built with <code
+	    >-threaded</code
+	    >.</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: <a href="#" title="Prelude"
+	      >Integer</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    ><code
+	      >$(forkTH)</code
+	      > fails at compile time if haddock isn't using the
+ threaded RTS.</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Threaded_TH.html b/utils/haddock/html-test/ref/Threaded_TH.html
new file mode 100644
index 0000000000000000000000000000000000000000..ed3023003172683c30ecd4d3e30e853e90b0b6d5
--- /dev/null
+++ b/utils/haddock/html-test/ref/Threaded_TH.html
@@ -0,0 +1,104 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Threaded_TH</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Threaded_TH</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >Imported by <code
+	    >Threaded</code
+	    >, since a TH splice can't be used in the
+ module where it is defined.</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >forkTH</a
+	      > :: <a href="#" title="Language.Haskell.TH"
+	      >Q</a
+	      > <a href="#" title="Language.Haskell.TH"
+	      >Exp</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:forkTH" class="def"
+	    >forkTH</a
+	    > :: <a href="#" title="Language.Haskell.TH"
+	    >Q</a
+	    > <a href="#" title="Language.Haskell.TH"
+	    >Exp</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >forkOS requires the threaded RTS, so this TH fails if haddock was
+ built without <code
+	      >-threaded</code
+	      >.</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Ticket112.html b/utils/haddock/html-test/ref/Ticket112.html
new file mode 100644
index 0000000000000000000000000000000000000000..34998258d32c7c8dff2700c777152214f844e914
--- /dev/null
+++ b/utils/haddock/html-test/ref/Ticket112.html
@@ -0,0 +1,86 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Ticket112</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >None</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Ticket112</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >...given a raw <code
+	      ><a href="#" title="GHC.Exts"
+		>Addr#</a
+		></code
+	      > to the string, and the length of the string.</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Ticket61.html b/utils/haddock/html-test/ref/Ticket61.html
new file mode 100644
index 0000000000000000000000000000000000000000..3b219168581fe8e0c43eeaa5ba3a79d88bc9929c
--- /dev/null
+++ b/utils/haddock/html-test/ref/Ticket61.html
@@ -0,0 +1,84 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Ticket61</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Ticket61</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:C" class="def"
+	    >C</a
+	    > a <span class="keyword"
+	    >where</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs methods"
+	  ><p class="caption"
+	    >Methods</p
+	    ><p class="src"
+	    ><a id="v:f" class="def"
+	      >f</a
+	      > :: a <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >A comment about f</p
+	      ></div
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Ticket75.html b/utils/haddock/html-test/ref/Ticket75.html
new file mode 100644
index 0000000000000000000000000000000000000000..f9349d945507ac7be4f863e11b5e097fcc7fcb7c
--- /dev/null
+++ b/utils/haddock/html-test/ref/Ticket75.html
@@ -0,0 +1,122 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Ticket75</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Ticket75</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > a <a href="#"
+	      >:-</a
+	      > b = <a href="#"
+	      >Q</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >f</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > a <a id="t::-45-" class="def"
+	    >:-</a
+	    > b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:Q" class="def"
+		  >Q</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A reference to <code
+	      ><a href="#" title="Ticket75"
+		>:-</a
+		></code
+	      ></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/TitledPicture.html b/utils/haddock/html-test/ref/TitledPicture.html
new file mode 100644
index 0000000000000000000000000000000000000000..dd10e1be74208d4498abf7779788ed34df746e34
--- /dev/null
+++ b/utils/haddock/html-test/ref/TitledPicture.html
@@ -0,0 +1,116 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >TitledPicture</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>TitledPicture</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >foo</a
+	      > :: <a href="#" title="Prelude"
+	      >Integer</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >bar</a
+	      > :: <a href="#" title="Prelude"
+	      >Integer</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:foo" class="def"
+	    >foo</a
+	    > :: <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Picture for <code
+	      ><a href="#" title="TitledPicture"
+		>foo</a
+		></code
+	      > without a title <img src="bar"
+	       /></p
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:bar" class="def"
+	    >bar</a
+	    > :: <a href="#" title="Prelude"
+	    >Integer</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Picture for <code
+	      ><a href="#" title="TitledPicture"
+		>bar</a
+		></code
+	      > with title <img src="un&#8739;&#8705;&#8728;" title="&#948;&#8712;"
+	       /></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/TypeFamilies.html b/utils/haddock/html-test/ref/TypeFamilies.html
new file mode 100644
index 0000000000000000000000000000000000000000..da57515ac9c9a2c132fbb26f5451d5135036626f
--- /dev/null
+++ b/utils/haddock/html-test/ref/TypeFamilies.html
@@ -0,0 +1,2172 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >TypeFamilies</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>TypeFamilies</p
+	></div
+      ><div id="description"
+      ><p class="caption"
+	>Description</p
+	><div class="doc"
+	><p
+	  >Doc for: module TypeFamilies</p
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >X</a
+	      ><ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >X</a
+		  ></li
+		><li
+		>| <a href="#"
+		  >XX</a
+		  ></li
+		><li
+		>| <a href="#"
+		  >XXX</a
+		  ></li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Y</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Z</a
+	      ><ul class="subs"
+	      ><li
+		>= <a href="#"
+		  >ZA</a
+		  ></li
+		><li
+		>| <a href="#"
+		  >ZB</a
+		  ></li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >Test</a
+	      > (a :: k)</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >type family</span
+	      > <a href="#"
+	      >Foo</a
+	      > a :: k</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data family</span
+	      > <a href="#"
+	      >Bat</a
+	      > (a :: k)</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > <a href="#"
+	      >Assoc</a
+	      > (a :: k) <span class="keyword"
+	      >where</span
+	      ><ul class="subs"
+	      ><li
+		><span class="keyword"
+		  >data</span
+		  > <a href="#"
+		  >AssocD</a
+		  > (a :: k)</li
+		><li
+		><span class="keyword"
+		  >type</span
+		  > <a href="#"
+		  >AssocT</a
+		  > (a :: k)</li
+		></ul
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >type family</span
+	      > <a href="#"
+	      >Bar</a
+	      > b <span class="keyword"
+	      >where ...</span
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >type family</span
+	      > (a :: k) <a href="#"
+	      >&lt;&gt;</a
+	      > (b :: k) :: k</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >class</span
+	      > (a :: k) <a href="#"
+	      >&gt;&lt;</a
+	      > (b :: k)</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:X" class="def"
+	    >X</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for: data X</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:X" class="def"
+		  >X</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Doc for: X</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:XX" class="def"
+		  >XX</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Doc for: XX</p
+		  ></td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:XXX" class="def"
+		  >XXX</a
+		  ></td
+		><td class="doc"
+		><p
+		  >Doc for: XXX</p
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:X"
+	    >Instances</h4
+	    ><details id="i:X" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:Assoc:1"
+		      ></span
+		      > <a href="#" title="TypeFamilies"
+		      >Assoc</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: instance Assoc X</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:Assoc:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:AssocDTYPEX0:AssocD:1"
+				></span
+				> <span class="keyword"
+				>data</span
+				> <a href="#" title="TypeFamilies"
+				>AssocD</a
+				> <a href="#" title="TypeFamilies"
+				>X</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:AssocDTYPEX0:AssocD:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >TypeFamilies</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >data</span
+				  > <a href="#" title="TypeFamilies"
+				  >AssocD</a
+				  > <a href="#" title="TypeFamilies"
+				  >X</a
+				  > = <a id="v:AssocX" class="def"
+				  >AssocX</a
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:AssocTTYPEX:AssocT:2"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="TypeFamilies"
+				>AssocT</a
+				> <a href="#" title="TypeFamilies"
+				>X</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:AssocTTYPEX:AssocT:2"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >TypeFamilies</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="TypeFamilies"
+				  >AssocT</a
+				  > <a href="#" title="TypeFamilies"
+				  >X</a
+				  > = <a href="#" title="TypeFamilies"
+				  >Foo</a
+				  > <a href="#" title="TypeFamilies"
+				  >X</a
+				  > :: <a href="#" title="Data.Kind"
+				  >Type</a
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:Test:2"
+		      ></span
+		      > <a href="#" title="TypeFamilies"
+		      >Test</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: instance Test X</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:Test:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:-62--60-:3"
+		      ></span
+		      > '<a href="#" title="TypeFamilies"
+		      >XX</a
+		      > <a href="#" title="TypeFamilies"
+		      >&gt;&lt;</a
+		      > '<a href="#" title="TypeFamilies"
+		      >XXX</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:-62--60-:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:Foo:4"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies2"
+		      >Foo</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >External instance</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:Foo:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies2"
+			>Foo</a
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> = <a href="#" title="TypeFamilies"
+			>Y</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:AssocD:5"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies"
+		      >AssocD</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:AssocD:5"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies"
+			>AssocD</a
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> = <a id="v:AssocX" class="def"
+			>AssocX</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:AssocT:6"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >AssocT</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:AssocT:6"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>AssocT</a
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> = <a href="#" title="TypeFamilies"
+			>Foo</a
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> :: <a href="#" title="Data.Kind"
+			>Type</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:Bat:7"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies"
+		      >Bat</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: data instance Bat X</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:Bat:7"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies"
+			>Bat</a
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> <ul class="inst"
+			><li class="inst"
+			  >= <a id="v:BatX" class="def"
+			    >BatX</a
+			    > <a href="#" title="TypeFamilies"
+			    >X</a
+			    ></li
+			  ><li class="inst"
+			  >| <a id="v:BatXX" class="def"
+			    >BatXX</a
+			    > { <ul class="subs"
+			    ><li
+			      ><a id="v:aaa" class="def"
+				>aaa</a
+				> :: <a href="#" title="TypeFamilies"
+				>X</a
+				></li
+			      ><li
+			      ><a id="v:bbb" class="def"
+				>bbb</a
+				> :: <a href="#" title="TypeFamilies"
+				>Y</a
+				></li
+			      ></ul
+			    > }</li
+			  ></ul
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:Foo:8"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >Foo</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: type instance Foo X = Y</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:Foo:8"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>Foo</a
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> = <a href="#" title="TypeFamilies"
+			>Y</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:-60--62-:9"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > '<a href="#" title="TypeFamilies"
+		      >XXX</a
+		      > <a href="#" title="TypeFamilies"
+		      >&lt;&gt;</a
+		      > '<a href="#" title="TypeFamilies"
+		      >XX</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:-60--62-:9"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> '<a href="#" title="TypeFamilies"
+			>XXX</a
+			> <a href="#" title="TypeFamilies"
+			>&lt;&gt;</a
+			> '<a href="#" title="TypeFamilies"
+			>XX</a
+			> = '<a href="#" title="TypeFamilies"
+			>X</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:X:-60--62-:10"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      > <a href="#" title="TypeFamilies"
+		      >&lt;&gt;</a
+		      > (a :: <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:X:-60--62-:10"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> <a href="#" title="TypeFamilies"
+			>&lt;&gt;</a
+			> (a :: <a href="#" title="Data.Kind"
+			>Type</a
+			>) = <a href="#" title="TypeFamilies"
+			>X</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Y" class="def"
+	    >Y</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for: data Y</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Y"
+	    >Instances</h4
+	    ><details id="i:Y" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Y:Assoc:1"
+		      ></span
+		      > <a href="#" title="TypeFamilies"
+		      >Assoc</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: instance Assoc Y</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Y:Assoc:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:AssocDTYPEY0:AssocD:1"
+				></span
+				> <span class="keyword"
+				>data</span
+				> <a href="#" title="TypeFamilies"
+				>AssocD</a
+				> <a href="#" title="TypeFamilies"
+				>Y</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:AssocDTYPEY0:AssocD:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >TypeFamilies</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >data</span
+				  > <a href="#" title="TypeFamilies"
+				  >AssocD</a
+				  > <a href="#" title="TypeFamilies"
+				  >Y</a
+				  > = <a id="v:AssocY" class="def"
+				  >AssocY</a
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:AssocTTYPEY:AssocT:2"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="TypeFamilies"
+				>AssocT</a
+				> <a href="#" title="TypeFamilies"
+				>Y</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:AssocTTYPEY:AssocT:2"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >TypeFamilies</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="TypeFamilies"
+				  >AssocT</a
+				  > <a href="#" title="TypeFamilies"
+				  >Y</a
+				  > = <a href="#" title="TypeFamilies"
+				  >Bat</a
+				  > <a href="#" title="TypeFamilies"
+				  >Y</a
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Y:Test:2"
+		      ></span
+		      > <a href="#" title="TypeFamilies"
+		      >Test</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: instance Test Y</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Y:Test:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Y:Bar:3"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies2"
+		      >Bar</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Y:Bar:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies2"
+			>Bar</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Y:AssocD:4"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies"
+		      >AssocD</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Y:AssocD:4"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies"
+			>AssocD</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			> = <a id="v:AssocY" class="def"
+			>AssocY</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Y:AssocT:5"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >AssocT</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Y:AssocT:5"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>AssocT</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			> = <a href="#" title="TypeFamilies"
+			>Bat</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Y:Bat:6"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies"
+		      >Bat</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: data instance Bat Y</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Y:Bat:6"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies"
+			>Bat</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			> = <a id="v:BatY" class="def"
+			>BatY</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Y:Foo:7"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >Foo</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: type instance Foo Y = X</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Y:Foo:7"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>Foo</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			> = <a href="#" title="TypeFamilies"
+			>X</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Y:-60--62-:8"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      > <a href="#" title="TypeFamilies"
+		      >&lt;&gt;</a
+		      > (a :: <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Y:-60--62-:8"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			> <a href="#" title="TypeFamilies"
+			>&lt;&gt;</a
+			> (a :: <a href="#" title="Data.Kind"
+			>Type</a
+			>) = a</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Z" class="def"
+	    >Z</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for: data Z</p
+	    ></div
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:ZA" class="def"
+		  >ZA</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a id="v:ZB" class="def"
+		  >ZB</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Z"
+	    >Instances</h4
+	    ><details id="i:Z" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Z:Bat:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies"
+		      >Bat</a
+		      > (z :: <a href="#" title="TypeFamilies"
+		      >Z</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: data instance Bat Z</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:Z:Bat:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies"
+			>Bat</a
+			> (z :: <a href="#" title="TypeFamilies"
+			>Z</a
+			>) <span class="keyword"
+			>where</span
+			><ul class="inst"
+			><li class="inst"
+			  ><a id="v:BatZ1" class="def"
+			    >BatZ1</a
+			    > :: <a href="#" title="TypeFamilies"
+			    >Z</a
+			    > -&gt; <a href="#" title="TypeFamilies"
+			    >Bat</a
+			    > '<a href="#" title="TypeFamilies"
+			    >ZA</a
+			    ></li
+			  ><li class="inst"
+			  ><a id="v:BatZ2" class="def"
+			    >BatZ2</a
+			    > :: {..} -&gt; <a href="#" title="TypeFamilies"
+			    >Bat</a
+			    > '<a href="#" title="TypeFamilies"
+			    >ZB</a
+			    ></li
+			  ></ul
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Test" class="def"
+	    >Test</a
+	    > (a :: k) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for: class Test a</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Test"
+	    >Instances</h4
+	    ><details id="i:Test" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Test:Test:1"
+		      ></span
+		      > <a href="#" title="TypeFamilies"
+		      >Test</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: instance Test X</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Test:Test:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Test:Test:2"
+		      ></span
+		      > <a href="#" title="TypeFamilies"
+		      >Test</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: instance Test Y</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Test:Test:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type family</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > a :: k <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for: type family Foo a</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo"
+	    >Instances</h4
+	    ><details id="i:Foo" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo:Foo:1"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >Foo</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: type instance Foo X = Y</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo:Foo:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>Foo</a
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> = <a href="#" title="TypeFamilies"
+			>Y</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo:Foo:2"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >Foo</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: type instance Foo Y = X</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo:Foo:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>Foo</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			> = <a href="#" title="TypeFamilies"
+			>X</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:Bat" class="def"
+	    >Bat</a
+	    > (a :: k) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for: data family Bat a</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Bat"
+	    >Instances</h4
+	    ><details id="i:Bat" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Bat:Bat:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies"
+		      >Bat</a
+		      > (z :: <a href="#" title="TypeFamilies"
+		      >Z</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: data instance Bat Z</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Bat:Bat:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies"
+			>Bat</a
+			> (z :: <a href="#" title="TypeFamilies"
+			>Z</a
+			>) <span class="keyword"
+			>where</span
+			><ul class="inst"
+			><li class="inst"
+			  ><a id="v:BatZ1" class="def"
+			    >BatZ1</a
+			    > :: <a href="#" title="TypeFamilies"
+			    >Z</a
+			    > -&gt; <a href="#" title="TypeFamilies"
+			    >Bat</a
+			    > '<a href="#" title="TypeFamilies"
+			    >ZA</a
+			    ></li
+			  ><li class="inst"
+			  ><a id="v:BatZ2" class="def"
+			    >BatZ2</a
+			    > :: {..} -&gt; <a href="#" title="TypeFamilies"
+			    >Bat</a
+			    > '<a href="#" title="TypeFamilies"
+			    >ZB</a
+			    ></li
+			  ></ul
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Bat:Bat:2"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies"
+		      >Bat</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: data instance Bat X</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Bat:Bat:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies"
+			>Bat</a
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> <ul class="inst"
+			><li class="inst"
+			  >= <a id="v:BatX" class="def"
+			    >BatX</a
+			    > <a href="#" title="TypeFamilies"
+			    >X</a
+			    ></li
+			  ><li class="inst"
+			  >| <a id="v:BatXX" class="def"
+			    >BatXX</a
+			    > { <ul class="subs"
+			    ><li
+			      ><a id="v:aaa" class="def"
+				>aaa</a
+				> :: <a href="#" title="TypeFamilies"
+				>X</a
+				></li
+			      ><li
+			      ><a id="v:bbb" class="def"
+				>bbb</a
+				> :: <a href="#" title="TypeFamilies"
+				>Y</a
+				></li
+			      ></ul
+			    > }</li
+			  ></ul
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Bat:Bat:3"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies"
+		      >Bat</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: data instance Bat Y</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Bat:Bat:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies"
+			>Bat</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			> = <a id="v:BatY" class="def"
+			>BatY</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > <a id="t:Assoc" class="def"
+	    >Assoc</a
+	    > (a :: k) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for: class Assoc a</p
+	    ></div
+	  ><div class="subs associated-types"
+	  ><p class="caption"
+	    >Associated Types</p
+	    ><p class="src"
+	    ><span class="keyword"
+	      >data</span
+	      > <a id="t:AssocD" class="def"
+	      >AssocD</a
+	      > (a :: k) <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Doc for: data AssocD a</p
+	      ></div
+	    ><p class="src"
+	    ><span class="keyword"
+	      >type</span
+	      > <a id="t:AssocT" class="def"
+	      >AssocT</a
+	      > (a :: k) <a href="#" class="selflink"
+	      >#</a
+	      ></p
+	    ><div class="doc"
+	    ><p
+	      >Doc for: type AssocT a</p
+	      ></div
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Assoc"
+	    >Instances</h4
+	    ><details id="i:Assoc" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Assoc:Assoc:1"
+		      ></span
+		      > <a href="#" title="TypeFamilies"
+		      >Assoc</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: instance Assoc X</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Assoc:Assoc:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:AssocDTYPEX0:AssocD:1"
+				></span
+				> <span class="keyword"
+				>data</span
+				> <a href="#" title="TypeFamilies"
+				>AssocD</a
+				> <a href="#" title="TypeFamilies"
+				>X</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:AssocDTYPEX0:AssocD:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >TypeFamilies</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >data</span
+				  > <a href="#" title="TypeFamilies"
+				  >AssocD</a
+				  > <a href="#" title="TypeFamilies"
+				  >X</a
+				  > = <a id="v:AssocX" class="def"
+				  >AssocX</a
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:AssocTTYPEX:AssocT:2"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="TypeFamilies"
+				>AssocT</a
+				> <a href="#" title="TypeFamilies"
+				>X</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:AssocTTYPEX:AssocT:2"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >TypeFamilies</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="TypeFamilies"
+				  >AssocT</a
+				  > <a href="#" title="TypeFamilies"
+				  >X</a
+				  > = <a href="#" title="TypeFamilies"
+				  >Foo</a
+				  > <a href="#" title="TypeFamilies"
+				  >X</a
+				  > :: <a href="#" title="Data.Kind"
+				  >Type</a
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:Assoc:Assoc:2"
+		      ></span
+		      > <a href="#" title="TypeFamilies"
+		      >Assoc</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Doc for: instance Assoc Y</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:Assoc:Assoc:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="subs associated-types"
+		      ><p class="caption"
+			>Associated Types</p
+			><table
+			><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:AssocDTYPEY0:AssocD:1"
+				></span
+				> <span class="keyword"
+				>data</span
+				> <a href="#" title="TypeFamilies"
+				>AssocD</a
+				> <a href="#" title="TypeFamilies"
+				>Y</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:AssocDTYPEY0:AssocD:1"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >TypeFamilies</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >data</span
+				  > <a href="#" title="TypeFamilies"
+				  >AssocD</a
+				  > <a href="#" title="TypeFamilies"
+				  >Y</a
+				  > = <a id="v:AssocY" class="def"
+				  >AssocY</a
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ><tr
+			  ><td class="src clearfix"
+			    ><span class="inst-left"
+			      ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:D:R:AssocTTYPEY:AssocT:2"
+				></span
+				> <span class="keyword"
+				>type</span
+				> <a href="#" title="TypeFamilies"
+				>AssocT</a
+				> <a href="#" title="TypeFamilies"
+				>Y</a
+				></span
+			      ></td
+			    ><td class="doc empty"
+			    >&nbsp;</td
+			    ></tr
+			  ><tr
+			  ><td colspan="2"
+			    ><details id="i:if:D:R:AssocTTYPEY:AssocT:2"
+			      ><summary class="hide-when-js-enabled"
+				>Instance details</summary
+				><p
+				>Defined in <a href="#"
+				  >TypeFamilies</a
+				  ></p
+				> <div class="src"
+				><span class="keyword"
+				  >type</span
+				  > <a href="#" title="TypeFamilies"
+				  >AssocT</a
+				  > <a href="#" title="TypeFamilies"
+				  >Y</a
+				  > = <a href="#" title="TypeFamilies"
+				  >Bat</a
+				  > <a href="#" title="TypeFamilies"
+				  >Y</a
+				  ></div
+				></details
+			      ></td
+			    ></tr
+			  ></table
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type family</span
+	    > <a id="t:Bar" class="def"
+	    >Bar</a
+	    > b <span class="keyword"
+	    >where ...</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Doc for: type family Bar b</p
+	    ></div
+	  ><div class="subs equations"
+	  ><p class="caption"
+	    >Equations</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a href="#" title="TypeFamilies"
+		  >Bar</a
+		  > <a href="#" title="TypeFamilies"
+		  >X</a
+		  > = <a href="#" title="TypeFamilies"
+		  >X</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a href="#" title="TypeFamilies"
+		  >Bar</a
+		  > y = <a href="#" title="TypeFamilies"
+		  >Y</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type family</span
+	    > (a :: k) <a id="t:-60--62-" class="def"
+	    >&lt;&gt;</a
+	    > (b :: k) :: k <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:-60--62-"
+	    >Instances</h4
+	    ><details id="i:-60--62-" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:-60--62-:-60--62-:1"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > '<a href="#" title="TypeFamilies"
+		      >XXX</a
+		      > <a href="#" title="TypeFamilies"
+		      >&lt;&gt;</a
+		      > '<a href="#" title="TypeFamilies"
+		      >XX</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:-60--62-:-60--62-:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> '<a href="#" title="TypeFamilies"
+			>XXX</a
+			> <a href="#" title="TypeFamilies"
+			>&lt;&gt;</a
+			> '<a href="#" title="TypeFamilies"
+			>XX</a
+			> = '<a href="#" title="TypeFamilies"
+			>X</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:-60--62-:-60--62-:2"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      > <a href="#" title="TypeFamilies"
+		      >&lt;&gt;</a
+		      > (a :: <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:-60--62-:-60--62-:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> <a href="#" title="TypeFamilies"
+			>&lt;&gt;</a
+			> (a :: <a href="#" title="Data.Kind"
+			>Type</a
+			>) = <a href="#" title="TypeFamilies"
+			>X</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:-60--62-:-60--62-:3"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      > <a href="#" title="TypeFamilies"
+		      >&lt;&gt;</a
+		      > (a :: <a href="#" title="Data.Kind"
+		      >Type</a
+		      >)</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:-60--62-:-60--62-:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			> <a href="#" title="TypeFamilies"
+			>&lt;&gt;</a
+			> (a :: <a href="#" title="Data.Kind"
+			>Type</a
+			>) = a</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > (a :: k) <a id="t:-62--60-" class="def"
+	    >&gt;&lt;</a
+	    > (b :: k) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:-62--60-"
+	    >Instances</h4
+	    ><details id="i:-62--60-" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:ic:-62--60-:-62--60-:1"
+		      ></span
+		      > '<a href="#" title="TypeFamilies"
+		      >XX</a
+		      > <a href="#" title="TypeFamilies"
+		      >&gt;&lt;</a
+		      > '<a href="#" title="TypeFamilies"
+		      >XXX</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:ic:-62--60-:-62--60-:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/TypeFamilies2.html b/utils/haddock/html-test/ref/TypeFamilies2.html
new file mode 100644
index 0000000000000000000000000000000000000000..1be5da836c16e4fa6dcb678ba06313f70531f04c
--- /dev/null
+++ b/utils/haddock/html-test/ref/TypeFamilies2.html
@@ -0,0 +1,400 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >TypeFamilies2</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>TypeFamilies2</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >W</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >type family</span
+	      > <a href="#"
+	      >Foo</a
+	      > a</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data family</span
+	      > <a href="#"
+	      >Bar</a
+	      > a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:W" class="def"
+	    >W</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Exported type</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:W"
+	    >Instances</h4
+	    ><details id="i:W" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:W:Bar:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies2"
+		      >Bar</a
+		      > <a href="#" title="TypeFamilies2"
+		      >W</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Shown because BarX is still exported despite Z being hidden</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:W:Bar:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies2</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies2"
+			>Bar</a
+			> <a href="#" title="TypeFamilies2"
+			>W</a
+			> = <a id="v:BarX" class="def"
+			>BarX</a
+			> Z</div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:W:Foo:2"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies2"
+		      >Foo</a
+		      > <a href="#" title="TypeFamilies2"
+		      >W</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Should be visible, but with a hidden right hand side</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:id:W:Foo:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies2</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies2"
+			>Foo</a
+			> <a href="#" title="TypeFamilies2"
+			>W</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type family</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Exported type family</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Foo"
+	    >Instances</h4
+	    ><details id="i:Foo" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo:Foo:1"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies2"
+		      >Foo</a
+		      > <a href="#" title="TypeFamilies"
+		      >X</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >External instance</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo:Foo:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies2"
+			>Foo</a
+			> <a href="#" title="TypeFamilies"
+			>X</a
+			> = <a href="#" title="TypeFamilies"
+			>Y</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Foo:Foo:2"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies2"
+		      >Foo</a
+		      > <a href="#" title="TypeFamilies2"
+		      >W</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Should be visible, but with a hidden right hand side</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Foo:Foo:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies2</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies2"
+			>Foo</a
+			> <a href="#" title="TypeFamilies2"
+			>W</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:Bar" class="def"
+	    >Bar</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >Exported data family</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Bar"
+	    >Instances</h4
+	    ><details id="i:Bar" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Bar:Bar:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies2"
+		      >Bar</a
+		      > <a href="#" title="TypeFamilies"
+		      >Y</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Bar:Bar:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies2"
+			>Bar</a
+			> <a href="#" title="TypeFamilies"
+			>Y</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Bar:Bar:2"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies2"
+		      >Bar</a
+		      > <a href="#" title="TypeFamilies2"
+		      >W</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc"
+		  ><p
+		    >Shown because BarX is still exported despite Z being hidden</p
+		    ></td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Bar:Bar:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies2</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies2"
+			>Bar</a
+			> <a href="#" title="TypeFamilies2"
+			>W</a
+			> = <a id="v:BarX" class="def"
+			>BarX</a
+			> Z</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/TypeFamilies3.html b/utils/haddock/html-test/ref/TypeFamilies3.html
new file mode 100644
index 0000000000000000000000000000000000000000..e1c8372138c254f9bc59288f9f93ed91d39c06fc
--- /dev/null
+++ b/utils/haddock/html-test/ref/TypeFamilies3.html
@@ -0,0 +1,368 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >TypeFamilies3</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>TypeFamilies3</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >type family</span
+	      > <a href="#"
+	      >Foo</a
+	      > a <span class="keyword"
+	      >where ...</span
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >type family</span
+	      > <a href="#"
+	      >Bar</a
+	      > a</li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data family</span
+	      > <a href="#"
+	      >Baz</a
+	      > a</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type family</span
+	    > <a id="t:Foo" class="def"
+	    >Foo</a
+	    > a <span class="keyword"
+	    >where ...</span
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A closed type family</p
+	    ></div
+	  ><div class="subs equations"
+	  ><p class="caption"
+	    >Equations</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a href="#" title="TypeFamilies3"
+		  >Foo</a
+		  > () = <a href="#" title="Data.Int"
+		  >Int</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td class="src"
+		><a href="#" title="TypeFamilies3"
+		  >Foo</a
+		  > _1 = ()</td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >type family</span
+	    > <a id="t:Bar" class="def"
+	    >Bar</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >An open family</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Bar"
+	    >Instances</h4
+	    ><details id="i:Bar" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Bar:Bar:1"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies3"
+		      >Bar</a
+		      > ()</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Bar:Bar:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies3</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies3"
+			>Bar</a
+			> () = <a href="#" title="Data.Int"
+			>Int</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Bar:Bar:2"
+		      ></span
+		      > <span class="keyword"
+		      >type</span
+		      > <a href="#" title="TypeFamilies3"
+		      >Bar</a
+		      > <a href="#" title="Data.Int"
+		      >Int</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Bar:Bar:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies3</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>type</span
+			> <a href="#" title="TypeFamilies3"
+			>Bar</a
+			> <a href="#" title="Data.Int"
+			>Int</a
+			> = ()</div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data family</span
+	    > <a id="t:Baz" class="def"
+	    >Baz</a
+	    > a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >A data family</p
+	    ></div
+	  ><div class="subs instances"
+	  ><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Baz"
+	    >Instances</h4
+	    ><details id="i:Baz" open="open"
+	    ><summary class="hide-when-js-enabled"
+	      >Instances details</summary
+	      ><table
+	      ><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Baz:Baz:1"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies3"
+		      >Baz</a
+		      > ()</span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Baz:Baz:1"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies3</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies3"
+			>Baz</a
+			> () = <a id="v:Baz1" class="def"
+			>Baz1</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Baz:Baz:2"
+		      ></span
+		      > <span class="keyword"
+		      >newtype</span
+		      > <a href="#" title="TypeFamilies3"
+		      >Baz</a
+		      > <a href="#" title="GHC.Exts"
+		      >Double</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Baz:Baz:2"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies3</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>newtype</span
+			> <a href="#" title="TypeFamilies3"
+			>Baz</a
+			> <a href="#" title="GHC.Exts"
+			>Double</a
+			> = <a id="v:Baz3" class="def"
+			>Baz3</a
+			> <a href="#" title="GHC.Exts"
+			>Float</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		><tr
+		><td class="src clearfix"
+		  ><span class="inst-left"
+		    ><span class="instance details-toggle-control details-toggle" data-details-id="i:if:Baz:Baz:3"
+		      ></span
+		      > <span class="keyword"
+		      >data</span
+		      > <a href="#" title="TypeFamilies3"
+		      >Baz</a
+		      > <a href="#" title="Data.Int"
+		      >Int</a
+		      ></span
+		    > <a href="#" class="selflink"
+		    >#</a
+		    ></td
+		  ><td class="doc empty"
+		  >&nbsp;</td
+		  ></tr
+		><tr
+		><td colspan="2"
+		  ><details id="i:if:Baz:Baz:3"
+		    ><summary class="hide-when-js-enabled"
+		      >Instance details</summary
+		      ><p
+		      >Defined in <a href="#"
+			>TypeFamilies3</a
+			></p
+		      > <div class="src"
+		      ><span class="keyword"
+			>data</span
+			> <a href="#" title="TypeFamilies3"
+			>Baz</a
+			> <a href="#" title="Data.Int"
+			>Int</a
+			> = <a id="v:Baz2" class="def"
+			>Baz2</a
+			> <a href="#" title="Data.Bool"
+			>Bool</a
+			></div
+		      ></details
+		    ></td
+		  ></tr
+		></table
+	      ></details
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/TypeOperators.html b/utils/haddock/html-test/ref/TypeOperators.html
new file mode 100644
index 0000000000000000000000000000000000000000..46bd18df719e5eafb6587c3fb2d8d077a9c2a8c4
--- /dev/null
+++ b/utils/haddock/html-test/ref/TypeOperators.html
@@ -0,0 +1,218 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >TypeOperators</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>TypeOperators</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > a <a id="t::-45-:" class="def"
+	    >:-:</a
+	    > b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > (a <a id="t::-43-:" class="def"
+	    >:+:</a
+	    > b) c <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Op" class="def"
+	    >Op</a
+	    > a b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >newtype</span
+	    > <a id="t:O" class="def"
+	    >O</a
+	    > (g :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) (f :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="subs constructors"
+	  ><p class="caption"
+	    >Constructors</p
+	    ><table
+	    ><tr
+	      ><td class="src"
+		><a id="v:O" class="def"
+		  >O</a
+		  ></td
+		><td class="doc empty"
+		>&nbsp;</td
+		></tr
+	      ><tr
+	      ><td colspan="2"
+		><div class="subs fields"
+		  ><p class="caption"
+		    >Fields</p
+		    ><ul
+		    ><li
+		      ><dfn class="src"
+			><a id="v:unO" class="def"
+			  >unO</a
+			  > :: g (f a)</dfn
+			><div class="doc empty"
+			>&nbsp;</div
+			></li
+		      ></ul
+		    ></div
+		  ></td
+		></tr
+	      ></table
+	    ></div
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >class</span
+	    > a <a id="t:-60--61--62-" class="def"
+	    >&lt;=&gt;</a
+	    > b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:biO" class="def"
+	    >biO</a
+	    > :: <span class="keyword"
+	    >forall</span
+	    > (g :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) (f :: <a href="#" title="Data.Kind"
+	    >Type</a
+	    > -&gt; <a href="#" title="Data.Kind"
+	    >Type</a
+	    >) a. <a href="#" title="TypeOperators"
+	    >O</a
+	    > g f a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:f" class="def"
+	    >f</a
+	    > :: a <a href="#" title="Data.Type.Equality"
+	    >~</a
+	    > b =&gt; a -&gt; b <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:g" class="def"
+	    >g</a
+	    > :: (a <a href="#" title="Data.Type.Equality"
+	    >~</a
+	    > b, b <a href="#" title="Data.Type.Equality"
+	    >~</a
+	    > c) =&gt; a -&gt; c <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:x" class="def"
+	    >x</a
+	    > :: (a <a href="#" title="TypeOperators"
+	    >:-:</a
+	    > a) <a href="#" title="TypeOperators"
+	    >&lt;=&gt;</a
+	    > <a href="#" title="TypeOperators"
+	    >Op</a
+	    > a a =&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:y" class="def"
+	    >y</a
+	    > :: (a <a href="#" title="TypeOperators"
+	    >&lt;=&gt;</a
+	    > a, <a href="#" title="TypeOperators"
+	    >Op</a
+	    > a a <a href="#" title="TypeOperators"
+	    >&lt;=&gt;</a
+	    > a) =&gt; a <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/UnboxedStuff.html b/utils/haddock/html-test/ref/UnboxedStuff.html
new file mode 100644
index 0000000000000000000000000000000000000000..8bb5ad209c80bf1b8895beb4191eac84773de8f4
--- /dev/null
+++ b/utils/haddock/html-test/ref/UnboxedStuff.html
@@ -0,0 +1,206 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >UnboxedStuff</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>UnboxedStuff</p
+	></div
+      ><div id="table-of-contents"
+      ><div id="contents-list"
+	><p class="caption" onclick="window.scrollTo(0,0)"
+	  >Contents</p
+	  ><ul
+	  ><li
+	    ><a href="#"
+	      >Unboxed type constructors</a
+	      ></li
+	    ></ul
+	  ></div
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >X</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Y</a
+	      ></li
+	    ><li class="src short"
+	    ><span class="keyword"
+	      >data</span
+	      > <a href="#"
+	      >Z</a
+	      ></li
+	    ><li class="src short"
+	    ><a href="#"
+	      >unboxedUnit</a
+	      > :: (# #) -&gt; (# #)</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >unboxedTuple</a
+	      > :: (# <a href="#" title="UnboxedStuff"
+	      >X</a
+	      >, <a href="#" title="UnboxedStuff"
+	      >Y</a
+	      > #) -&gt; (# <a href="#" title="UnboxedStuff"
+	      >X</a
+	      >, <a href="#" title="UnboxedStuff"
+	      >Y</a
+	      >, <a href="#" title="UnboxedStuff"
+	      >Z</a
+	      > #)</li
+	    ><li class="src short"
+	    ><a href="#"
+	      >unboxedSum</a
+	      > :: (# <a href="#" title="UnboxedStuff"
+	      >X</a
+	      > |  <a href="#" title="UnboxedStuff"
+	      >Y</a
+	      > #) -&gt; (# <a href="#" title="UnboxedStuff"
+	      >X</a
+	      > |  <a href="#" title="UnboxedStuff"
+	      >Y</a
+	      > |  <a href="#" title="UnboxedStuff"
+	      >Z</a
+	      > #)</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:X" class="def"
+	    >X</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Y" class="def"
+	    >Y</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><span class="keyword"
+	    >data</span
+	    > <a id="t:Z" class="def"
+	    >Z</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><a href="#" id="g:1"
+	><h1
+	  >Unboxed type constructors</h1
+	  ></a
+	><div class="top"
+	><p class="src"
+	  ><a id="v:unboxedUnit" class="def"
+	    >unboxedUnit</a
+	    > :: (# #) -&gt; (# #) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:unboxedTuple" class="def"
+	    >unboxedTuple</a
+	    > :: (# <a href="#" title="UnboxedStuff"
+	    >X</a
+	    >, <a href="#" title="UnboxedStuff"
+	    >Y</a
+	    > #) -&gt; (# <a href="#" title="UnboxedStuff"
+	    >X</a
+	    >, <a href="#" title="UnboxedStuff"
+	    >Y</a
+	    >, <a href="#" title="UnboxedStuff"
+	    >Z</a
+	    > #) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	><div class="top"
+	><p class="src"
+	  ><a id="v:unboxedSum" class="def"
+	    >unboxedSum</a
+	    > :: (# <a href="#" title="UnboxedStuff"
+	    >X</a
+	    > |  <a href="#" title="UnboxedStuff"
+	    >Y</a
+	    > #) -&gt; (# <a href="#" title="UnboxedStuff"
+	    >X</a
+	    > |  <a href="#" title="UnboxedStuff"
+	    >Y</a
+	    > |  <a href="#" title="UnboxedStuff"
+	    >Z</a
+	    > #) <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Unicode.html b/utils/haddock/html-test/ref/Unicode.html
new file mode 100644
index 0000000000000000000000000000000000000000..29ad66afdd803c734530272b269ba68de8d6045e
--- /dev/null
+++ b/utils/haddock/html-test/ref/Unicode.html
@@ -0,0 +1,86 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Unicode</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Unicode</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >x</a
+	      > :: <a href="#" title="Data.Int"
+	      >Int</a
+	      ></li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:x" class="def"
+	    >x</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >&#947;&#955;&#974;&#963;&#963;&#945;</p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Unicode2.html b/utils/haddock/html-test/ref/Unicode2.html
new file mode 100644
index 0000000000000000000000000000000000000000..d1e94dbd1bcb8b6b2a4a35d3bedf92a4b8e4df4a
--- /dev/null
+++ b/utils/haddock/html-test/ref/Unicode2.html
@@ -0,0 +1,108 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Unicode2</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Unicode2</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >&#252;</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:-252-" class="def"
+	    >&#252;</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >All of the following work with a unicode character &#252;:</p
+	    ><ul
+	    ><li
+	      >an italicized <em
+		>&#252;</em
+		></li
+	      ><li
+	      >inline code <code
+		>&#252;</code
+		></li
+	      ><li
+	      >a code block:</li
+	      ></ul
+	    ><pre
+	    >&#252;</pre
+	    ><ul
+	    ><li
+	      >a url <a href="#"
+		>https://www.google.com/search?q=&#252;</a
+		></li
+	      ><li
+	      >a link to <code
+		><a href="#" title="Unicode2"
+		  >&#252;</a
+		  ></code
+		></li
+	      ></ul
+	    ></div
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/Visible.html b/utils/haddock/html-test/ref/Visible.html
new file mode 100644
index 0000000000000000000000000000000000000000..c8f6b26d5b3fe81ebd549e96a22926170e88e566
--- /dev/null
+++ b/utils/haddock/html-test/ref/Visible.html
@@ -0,0 +1,70 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><meta name="viewport" content="width=device-width, initial-scale=1"
+     /><title
+    >Visible</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script type="text/x-mathjax-config"
+    >MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><span class="caption empty"
+      >&nbsp;</span
+      ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe-Inferred</td
+	    ></tr
+	  ><tr
+	  ><th
+	    >Language</th
+	    ><td
+	    >Haskell2010</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Visible</p
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:visible" class="def"
+	    >visible</a
+	    > :: <a href="#" title="Data.Int"
+	    >Int</a
+	    > -&gt; <a href="#" title="Data.Int"
+	    >Int</a
+	    > <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ></div
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/haddock-util.js b/utils/haddock/html-test/ref/haddock-util.js
new file mode 100644
index 0000000000000000000000000000000000000000..05bdaef509bd418ec63cf00e71338fcd77524baf
--- /dev/null
+++ b/utils/haddock/html-test/ref/haddock-util.js
@@ -0,0 +1,186 @@
+// Haddock JavaScript utilities
+
+var rspace = /\s\s+/g,
+    rtrim = /^\s+|\s+$/g;
+
+function spaced(s) { return (" " + s + " ").replace(rspace, " "); }
+function trim(s)   { return s.replace(rtrim, ""); }
+
+function hasClass(elem, value) {
+  var className = spaced(elem.className || "");
+  return className.indexOf( " " + value + " " ) >= 0;
+}
+
+function addClass(elem, value) {
+  var className = spaced(elem.className || "");
+  if ( className.indexOf( " " + value + " " ) < 0 ) {
+    elem.className = trim(className + " " + value);
+  }
+}
+
+function removeClass(elem, value) {
+  var className = spaced(elem.className || "");
+  className = className.replace(" " + value + " ", " ");
+  elem.className = trim(className);
+}
+
+function toggleClass(elem, valueOn, valueOff, bool) {
+  if (bool == null) { bool = ! hasClass(elem, valueOn); }
+  if (bool) {
+    removeClass(elem, valueOff);
+    addClass(elem, valueOn);
+  }
+  else {
+    removeClass(elem, valueOn);
+    addClass(elem, valueOff);
+  }
+  return bool;
+}
+
+
+function makeClassToggle(valueOn, valueOff)
+{
+  return function(elem, bool) {
+    return toggleClass(elem, valueOn, valueOff, bool);
+  }
+}
+
+toggleShow = makeClassToggle("show", "hide");
+toggleCollapser = makeClassToggle("collapser", "expander");
+
+function toggleSection(id)
+{
+  var b = toggleShow(document.getElementById("section." + id));
+  toggleCollapser(document.getElementById("control." + id), b);
+  rememberCollapsed(id, b);
+  return b;
+}
+
+var collapsed = {};
+function rememberCollapsed(id, b)
+{
+  if(b)
+    delete collapsed[id]
+  else
+    collapsed[id] = null;
+
+  var sections = [];
+  for(var i in collapsed)
+  {
+    if(collapsed.hasOwnProperty(i))
+      sections.push(i);
+  }
+  // cookie specific to this page; don't use setCookie which sets path=/
+  document.cookie = "collapsed=" + escape(sections.join('+'));
+}
+
+function restoreCollapsed()
+{
+  var cookie = getCookie("collapsed");
+  if(!cookie)
+    return;
+
+  var ids = cookie.split('+');
+  for(var i in ids)
+  {
+    if(document.getElementById("section." + ids[i]))
+      toggleSection(ids[i]);
+  }
+}
+
+function setCookie(name, value) {
+  document.cookie = name + "=" + escape(value) + ";path=/;";
+}
+
+function clearCookie(name) {
+  document.cookie = name + "=;path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT;";
+}
+
+function getCookie(name) {
+  var nameEQ = name + "=";
+  var ca = document.cookie.split(';');
+  for(var i=0;i < ca.length;i++) {
+    var c = ca[i];
+    while (c.charAt(0)==' ') c = c.substring(1,c.length);
+    if (c.indexOf(nameEQ) == 0) {
+      return unescape(c.substring(nameEQ.length,c.length));
+    }
+  }
+  return null;
+}
+
+function addMenuItem(html) {
+  var menu = document.getElementById("page-menu");
+  if (menu) {
+    var btn = menu.firstChild.cloneNode(false);
+    btn.innerHTML = html;
+    menu.appendChild(btn);
+  }
+}
+
+function styles() {
+  var i, a, es = document.getElementsByTagName("link"), rs = [];
+  for (i = 0; a = es[i]; i++) {
+    if(a.rel.indexOf("style") != -1 && a.title) {
+      rs.push(a);
+    }
+  }
+  return rs;
+}
+
+function addStyleMenu() {
+  var as = styles();
+  var i, a, btns = "";
+  for(i=0; a = as[i]; i++) {
+    btns += "<li><a href='#' onclick=\"setActiveStyleSheet('"
+      + a.title + "'); return false;\">"
+      + a.title + "</a></li>"
+  }
+  if (as.length > 1) {
+    var h = "<div id='style-menu-holder'>"
+      + "<a href='#' onclick='styleMenu(); return false;'>Style &#9662;</a>"
+      + "<ul id='style-menu' class='hide'>" + btns + "</ul>"
+      + "</div>";
+    addMenuItem(h);
+  }
+}
+
+function setActiveStyleSheet(title) {
+  var as = styles();
+  var i, a, found;
+  for(i=0; a = as[i]; i++) {
+    a.disabled = true;
+          // need to do this always, some browsers are edge triggered
+    if(a.title == title) {
+      found = a;
+    }
+  }
+  if (found) {
+    found.disabled = false;
+    setCookie("haddock-style", title);
+  }
+  else {
+    as[0].disabled = false;
+    clearCookie("haddock-style");
+  }
+  styleMenu(false);
+}
+
+function resetStyle() {
+  var s = getCookie("haddock-style");
+  if (s) setActiveStyleSheet(s);
+}
+
+
+function styleMenu(show) {
+  var m = document.getElementById('style-menu');
+  if (m) toggleShow(m, show);
+}
+
+
+function pageLoad() {
+  addStyleMenu();
+  resetStyle();
+  restoreCollapsed();
+}
+
diff --git a/utils/haddock/html-test/ref/hslogo-16.png b/utils/haddock/html-test/ref/hslogo-16.png
new file mode 100644
index 0000000000000000000000000000000000000000..0ff8579fbd897417b0d6dad6e920f8882138a7c0
Binary files /dev/null and b/utils/haddock/html-test/ref/hslogo-16.png differ
diff --git a/utils/haddock/html-test/ref/mini_A.html b/utils/haddock/html-test/ref/mini_A.html
new file mode 100644
index 0000000000000000000000000000000000000000..fa89131e6ce9e538e63f50bfd064777d6e00a901
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_A.html
@@ -0,0 +1,61 @@
+<!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
+    >A</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >A</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >A</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >other</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >test2</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >X</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >reExport</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_AdvanceTypes.html b/utils/haddock/html-test/ref/mini_AdvanceTypes.html
new file mode 100644
index 0000000000000000000000000000000000000000..c7d21915cc77bb31ad966ca5e5f1b6a3315285f5
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_AdvanceTypes.html
@@ -0,0 +1,35 @@
+<!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
+    >AdvanceTypes</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >AdvanceTypes</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Pattern</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_B.html b/utils/haddock/html-test/ref/mini_B.html
new file mode 100644
index 0000000000000000000000000000000000000000..5ce5772cc84a6d983eac854b5f815c7983d16393
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_B.html
@@ -0,0 +1,47 @@
+<!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
+    >B</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >B</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >test</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >reExport</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >X</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Bug1.html b/utils/haddock/html-test/ref/mini_Bug1.html
new file mode 100644
index 0000000000000000000000000000000000000000..d7aea0ed9797fa02355cc3456fa153b347b3ea4c
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Bug1.html
@@ -0,0 +1,35 @@
+<!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
+    >Bug1</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Bug1</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >T</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Bug2.html b/utils/haddock/html-test/ref/mini_Bug2.html
new file mode 100644
index 0000000000000000000000000000000000000000..58fc5ba335de777ffe2c45cc306776986b0ab5e2
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Bug2.html
@@ -0,0 +1,33 @@
+<!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
+    >Bug2</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Bug2</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >x</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Bug3.html b/utils/haddock/html-test/ref/mini_Bug3.html
new file mode 100644
index 0000000000000000000000000000000000000000..1b0d1b33f79e67b2e5f75c383bf2a0e04a2b5ffc
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Bug3.html
@@ -0,0 +1,33 @@
+<!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
+    >Bug3</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Bug3</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Bug4.html b/utils/haddock/html-test/ref/mini_Bug4.html
new file mode 100644
index 0000000000000000000000000000000000000000..d17d2f2b89e1d0c27bc4f8bd84f79ece43df22ac
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Bug4.html
@@ -0,0 +1,33 @@
+<!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
+    >Bug4</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Bug4</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Bug6.html b/utils/haddock/html-test/ref/mini_Bug6.html
new file mode 100644
index 0000000000000000000000000000000000000000..e60f418901de420fd2bee79cc930329d97467f9f
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Bug6.html
@@ -0,0 +1,67 @@
+<!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
+    >Bug6</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Bug6</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >A</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >B</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >C</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >D</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >E</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Bug7.html b/utils/haddock/html-test/ref/mini_Bug7.html
new file mode 100644
index 0000000000000000000000000000000000000000..776984893c273a45251b3956d2c9d37bd5081055
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Bug7.html
@@ -0,0 +1,43 @@
+<!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
+    >Bug7</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Bug7</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Foo</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >Bar</a
+	  > x y</p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Bug8.html b/utils/haddock/html-test/ref/mini_Bug8.html
new file mode 100644
index 0000000000000000000000000000000000000000..9d0293073d77262cad088f2d275857ef320ebf19
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Bug8.html
@@ -0,0 +1,65 @@
+<!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
+    >Bug8</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Bug8</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Typ</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >(--&gt;)</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >(---&gt;)</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >s</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >t</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >main</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_BugDeprecated.html b/utils/haddock/html-test/ref/mini_BugDeprecated.html
new file mode 100644
index 0000000000000000000000000000000000000000..8a35d4d6a0c1e641773c3ae5373b7a2158ae2092
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_BugDeprecated.html
@@ -0,0 +1,63 @@
+<!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
+    >BugDeprecated</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >BugDeprecated</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >bar</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >baz</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >one</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >two</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >three</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_BugExportHeadings.html b/utils/haddock/html-test/ref/mini_BugExportHeadings.html
new file mode 100644
index 0000000000000000000000000000000000000000..50ac8cfcd789635d3306baaa29dc05c40175f8d9
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_BugExportHeadings.html
@@ -0,0 +1,75 @@
+<!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
+    >BugExportHeadings</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >BugExportHeadings</p
+      ></div
+    ><div id="interface"
+    ><h1
+      >Foo</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ><h1
+      >Bar</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >bar</a
+	  ></p
+	></div
+      ><h1
+      >Baz</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >baz</a
+	  ></p
+	></div
+      ><h1
+      >One</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >one</a
+	  ></p
+	></div
+      ><h1
+      >Two</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >two</a
+	  ></p
+	></div
+      ><h1
+      >Three</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >three</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Bugs.html b/utils/haddock/html-test/ref/mini_Bugs.html
new file mode 100644
index 0000000000000000000000000000000000000000..94992ddf6a3a72b35e08a91389083c6f244c1144
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Bugs.html
@@ -0,0 +1,35 @@
+<!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
+    >Bugs</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Bugs</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >A</a
+	  > a</p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_CrossPackageDocs.html b/utils/haddock/html-test/ref/mini_CrossPackageDocs.html
new file mode 100644
index 0000000000000000000000000000000000000000..4c0588baffa0170e347aa5a46d9713cacc01130a
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_CrossPackageDocs.html
@@ -0,0 +1,45 @@
+<!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
+    >CrossPackageDocs</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();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >CrossPackageDocs</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >map</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >IsString</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >runInteractiveProcess</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedClass.html b/utils/haddock/html-test/ref/mini_DeprecatedClass.html
new file mode 100644
index 0000000000000000000000000000000000000000..234778f07f0064e7c691f3fd68cc07e2e5c33186
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedClass.html
@@ -0,0 +1,43 @@
+<!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
+    >DeprecatedClass</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedClass</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >SomeClass</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >SomeOtherClass</a
+	  > a</p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedData.html b/utils/haddock/html-test/ref/mini_DeprecatedData.html
new file mode 100644
index 0000000000000000000000000000000000000000..b4042bb896777cced6076fc22e4138048ed1b0dc
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedData.html
@@ -0,0 +1,43 @@
+<!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
+    >DeprecatedData</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedData</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Foo</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >One</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedFunction.html b/utils/haddock/html-test/ref/mini_DeprecatedFunction.html
new file mode 100644
index 0000000000000000000000000000000000000000..3739b392fdbec98f23eed333895d3f6a6b7fabb6
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedFunction.html
@@ -0,0 +1,39 @@
+<!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
+    >DeprecatedFunction</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedFunction</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >bar</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedFunction2.html b/utils/haddock/html-test/ref/mini_DeprecatedFunction2.html
new file mode 100644
index 0000000000000000000000000000000000000000..a66fc19bd21a30d29eafe9ecbec9353ce9192798
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedFunction2.html
@@ -0,0 +1,33 @@
+<!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
+    >DeprecatedFunction2</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedFunction2</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedFunction3.html b/utils/haddock/html-test/ref/mini_DeprecatedFunction3.html
new file mode 100644
index 0000000000000000000000000000000000000000..770dfad53c7eb0c3b9d5580b0b7556f0cba72d45
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedFunction3.html
@@ -0,0 +1,33 @@
+<!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
+    >DeprecatedFunction3</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedFunction3</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedModule.html b/utils/haddock/html-test/ref/mini_DeprecatedModule.html
new file mode 100644
index 0000000000000000000000000000000000000000..d70284b128516b25c1c1a163099d685b54f47656
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedModule.html
@@ -0,0 +1,33 @@
+<!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
+    >DeprecatedModule</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedModule</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedModule2.html b/utils/haddock/html-test/ref/mini_DeprecatedModule2.html
new file mode 100644
index 0000000000000000000000000000000000000000..a0773dcc9f05daa0596d767b0dd07a9723e17eec
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedModule2.html
@@ -0,0 +1,33 @@
+<!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
+    >DeprecatedModule2</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedModule2</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedNewtype.html b/utils/haddock/html-test/ref/mini_DeprecatedNewtype.html
new file mode 100644
index 0000000000000000000000000000000000000000..165bcd4c7a22f5a1503bdf219783b4c2242c5abe
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedNewtype.html
@@ -0,0 +1,43 @@
+<!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
+    >DeprecatedNewtype</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedNewtype</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >SomeNewType</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >SomeOtherNewType</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedReExport.html b/utils/haddock/html-test/ref/mini_DeprecatedReExport.html
new file mode 100644
index 0000000000000000000000000000000000000000..22dfddf45af72d932546308802caf1120634da9a
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedReExport.html
@@ -0,0 +1,37 @@
+<!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
+    >DeprecatedReExport</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedReExport</p
+      ></div
+    ><div id="interface"
+    ><h1
+      >Re-exported from an other module</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ><h1
+      >Re-exported from an other package</h1
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedRecord.html b/utils/haddock/html-test/ref/mini_DeprecatedRecord.html
new file mode 100644
index 0000000000000000000000000000000000000000..0f40051238ccdcebab543067b5f9c54430e52ab6
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedRecord.html
@@ -0,0 +1,35 @@
+<!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
+    >DeprecatedRecord</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedRecord</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedTypeFamily.html b/utils/haddock/html-test/ref/mini_DeprecatedTypeFamily.html
new file mode 100644
index 0000000000000000000000000000000000000000..b430034a49c8effffe5f8e4a2a6c8ab77251dfa7
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedTypeFamily.html
@@ -0,0 +1,43 @@
+<!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
+    >DeprecatedTypeFamily</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedTypeFamily</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data family</span
+	  > <a href=""
+	  >SomeTypeFamily</a
+	  > k :: * -&gt; *</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data family</span
+	  > <a href=""
+	  >SomeOtherTypeFamily</a
+	  > k :: * -&gt; *</p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_DeprecatedTypeSynonym.html b/utils/haddock/html-test/ref/mini_DeprecatedTypeSynonym.html
new file mode 100644
index 0000000000000000000000000000000000000000..44cb232dfa47a2272e87b99258c4de45995d8e5e
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_DeprecatedTypeSynonym.html
@@ -0,0 +1,43 @@
+<!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
+    >DeprecatedTypeSynonym</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >DeprecatedTypeSynonym</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >type</span
+	  > <a href="" target="main"
+	  >TypeSyn</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >type</span
+	  > <a href="" target="main"
+	  >OtherTypeSyn</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Examples.html b/utils/haddock/html-test/ref/mini_Examples.html
new file mode 100644
index 0000000000000000000000000000000000000000..9b3a5610465a59ecea073a66e5e41b67c963dc9f
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Examples.html
@@ -0,0 +1,33 @@
+<!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
+    >Examples</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Examples</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >fib</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_FunArgs.html b/utils/haddock/html-test/ref/mini_FunArgs.html
new file mode 100644
index 0000000000000000000000000000000000000000..5f19fe0b5ad7fb9fcf9b4ef91dcadd9bd72e3815
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_FunArgs.html
@@ -0,0 +1,57 @@
+<!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
+    >FunArgs</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >FunArgs</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >f</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >g</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >h</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >i</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >j</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_GADTRecords.html b/utils/haddock/html-test/ref/mini_GADTRecords.html
new file mode 100644
index 0000000000000000000000000000000000000000..b6b7ae6e2edadb5e392652bd6ee088b54e5468ac
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_GADTRecords.html
@@ -0,0 +1,35 @@
+<!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
+    >GADTRecords</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >GADTRecords</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >H1</a
+	  > a b</p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Hash.html b/utils/haddock/html-test/ref/mini_Hash.html
new file mode 100644
index 0000000000000000000000000000000000000000..0c7590bb749a5bbbfe7c4382fd4637712e69d562
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Hash.html
@@ -0,0 +1,73 @@
+<!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
+    >Hash</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Hash</p
+      ></div
+    ><div id="interface"
+    ><h1
+      >The <code
+	>HashTable</code
+	> type</h1
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >HashTable</a
+	  > key val</p
+	></div
+      ><h2
+      >Operations on <code
+	>HashTable</code
+	>s</h2
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >new</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >insert</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >lookup</a
+	  ></p
+	></div
+      ><h1
+      >The <code
+	>Hash</code
+	> class</h1
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >Hash</a
+	  > a</p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_HiddenInstances.html b/utils/haddock/html-test/ref/mini_HiddenInstances.html
new file mode 100644
index 0000000000000000000000000000000000000000..1ffecbf833692fb132df4b733d8cbcbcfea448a8
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_HiddenInstances.html
@@ -0,0 +1,43 @@
+<!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
+    >HiddenInstances</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >HiddenInstances</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >VisibleClass</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >VisibleData</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_HiddenInstancesB.html b/utils/haddock/html-test/ref/mini_HiddenInstancesB.html
new file mode 100644
index 0000000000000000000000000000000000000000..8ca461b60e0aca643cbfbc1256b3e47062a9b275
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_HiddenInstancesB.html
@@ -0,0 +1,43 @@
+<!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
+    >HiddenInstancesB</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >HiddenInstancesB</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >Foo</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Bar</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Hyperlinks.html b/utils/haddock/html-test/ref/mini_Hyperlinks.html
new file mode 100644
index 0000000000000000000000000000000000000000..0e0c3e8046d6b73f4bf78466b25d3978461ff8e4
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Hyperlinks.html
@@ -0,0 +1,33 @@
+<!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
+    >Hyperlinks</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Hyperlinks</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_IgnoreExports.html b/utils/haddock/html-test/ref/mini_IgnoreExports.html
new file mode 100644
index 0000000000000000000000000000000000000000..e97867f4284fff1cd8cf3a4cc35447f18264b761
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_IgnoreExports.html
@@ -0,0 +1,39 @@
+<!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
+    >IgnoreExports</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >IgnoreExports</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >bar</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Math.html b/utils/haddock/html-test/ref/mini_Math.html
new file mode 100644
index 0000000000000000000000000000000000000000..23e7a9ced69efb12c5cbceab3aa23ce8b3d9021d
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Math.html
@@ -0,0 +1,33 @@
+<!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
+    >Math</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Math</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >f</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_ModuleWithWarning.html b/utils/haddock/html-test/ref/mini_ModuleWithWarning.html
new file mode 100644
index 0000000000000000000000000000000000000000..988db4711b2a6d6be1a51997c6aefb54d020b21d
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_ModuleWithWarning.html
@@ -0,0 +1,33 @@
+<!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
+    >ModuleWithWarning</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >ModuleWithWarning</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_NamedDoc.html b/utils/haddock/html-test/ref/mini_NamedDoc.html
new file mode 100644
index 0000000000000000000000000000000000000000..5a8e4ad9ed65d11b3d3bcdcdfbe248c727327262
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_NamedDoc.html
@@ -0,0 +1,27 @@
+<!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
+    >NamedDoc</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >NamedDoc</p
+      ></div
+    ><div id="interface"
+    ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_NoLayout.html b/utils/haddock/html-test/ref/mini_NoLayout.html
new file mode 100644
index 0000000000000000000000000000000000000000..9400ad54a0cb30b3de7e2a91b732377fd1e6deb5
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_NoLayout.html
@@ -0,0 +1,33 @@
+<!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
+    >NoLayout</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >NoLayout</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >g</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_NonGreedy.html b/utils/haddock/html-test/ref/mini_NonGreedy.html
new file mode 100644
index 0000000000000000000000000000000000000000..78f0e8475d54eec776ccfdb82fa41e5e236bb3f3
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_NonGreedy.html
@@ -0,0 +1,33 @@
+<!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
+    >NonGreedy</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >NonGreedy</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >f</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Properties.html b/utils/haddock/html-test/ref/mini_Properties.html
new file mode 100644
index 0000000000000000000000000000000000000000..86b2364c58664592590c583d866c3f6c27ec33e1
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Properties.html
@@ -0,0 +1,33 @@
+<!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
+    >Properties</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Properties</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >fib</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_PruneWithWarning.html b/utils/haddock/html-test/ref/mini_PruneWithWarning.html
new file mode 100644
index 0000000000000000000000000000000000000000..379a701ed2dcf479143113a8632a0b9189ab5221
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_PruneWithWarning.html
@@ -0,0 +1,27 @@
+<!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
+    >PruneWithWarning</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >PruneWithWarning</p
+      ></div
+    ><div id="interface"
+    ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_QuasiExpr.html b/utils/haddock/html-test/ref/mini_QuasiExpr.html
new file mode 100644
index 0000000000000000000000000000000000000000..6c2c97f7627faea9b1356d52242cbc05e0a91a39
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_QuasiExpr.html
@@ -0,0 +1,61 @@
+<!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
+    >QuasiExpr</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >QuasiExpr</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Expr</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >BinOp</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >eval</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >expr</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >parseExprExp</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_QuasiQuote.html b/utils/haddock/html-test/ref/mini_QuasiQuote.html
new file mode 100644
index 0000000000000000000000000000000000000000..fec1abb786472da801d4e7c11d7e6f009f79267e
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_QuasiQuote.html
@@ -0,0 +1,33 @@
+<!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
+    >QuasiQuote</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >QuasiQuote</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >val</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_SpuriousSuperclassConstraints.html b/utils/haddock/html-test/ref/mini_SpuriousSuperclassConstraints.html
new file mode 100644
index 0000000000000000000000000000000000000000..c6b2d1aa8598eac3e4e4d3b93359491ba5e3ac49
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_SpuriousSuperclassConstraints.html
@@ -0,0 +1,35 @@
+<!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
+    >SpuriousSuperclassConstraints</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >SpuriousSuperclassConstraints</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >SomeType</a
+	  > f a</p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_TH.html b/utils/haddock/html-test/ref/mini_TH.html
new file mode 100644
index 0000000000000000000000000000000000000000..cbf260b464da1b7bc00278265fbe853c02da9a34
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_TH.html
@@ -0,0 +1,33 @@
+<!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
+    >TH</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >TH</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >decl</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_TH2.html b/utils/haddock/html-test/ref/mini_TH2.html
new file mode 100644
index 0000000000000000000000000000000000000000..6a29ad562e0737b826c39a2b8fc5133349c39a3b
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_TH2.html
@@ -0,0 +1,33 @@
+<!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
+    >TH2</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >TH2</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >f</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Test.html b/utils/haddock/html-test/ref/mini_Test.html
new file mode 100644
index 0000000000000000000000000000000000000000..571b4abdcddd397f3a034c9f5b1f3b1146b96c6b
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Test.html
@@ -0,0 +1,259 @@
+<!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
+    >Test</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Test</p
+      ></div
+    ><div id="interface"
+    ><h1
+      >Type declarations</h1
+      ><h2
+      >Data types</h2
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >T</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >T2</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >T3</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >T4</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >T5</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >T6</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >N1</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >N2</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >N3</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >N4</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >N5</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >N6</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >N7</a
+	  > a b</p
+	></div
+      ><h2
+      >Records</h2
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >R</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >R1</a
+	  ></p
+	></div
+      ><h1
+      >Class declarations</h1
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >C</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >D</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >E</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >F</a
+	  > a</p
+	></div
+      ><h1
+      >Function types</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >f</a
+	  ></p
+	></div
+      ><h1
+      >Auxiliary stuff</h1
+      ><h1
+      >A hidden module</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >hidden</a
+	  ></p
+	></div
+      ><h1
+      >A visible module</h1
+      ><h1
+      >Existential / Universal types</h1
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Ex</a
+	  > a</p
+	></div
+      ><h1
+      >Type signatures with argument docs</h1
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >k</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >l</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >m</a
+	  ></p
+	></div
+      ><h1
+      >A section</h1
+      ><h2
+      >A subsection</h2
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >f'</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >withType</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >withoutType</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Ticket112.html b/utils/haddock/html-test/ref/mini_Ticket112.html
new file mode 100644
index 0000000000000000000000000000000000000000..3c6bf31f42ef140ec7130be8f8a4952f5bac719e
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Ticket112.html
@@ -0,0 +1,33 @@
+<!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
+    >Ticket112</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Ticket112</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >f</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Ticket253_1.html b/utils/haddock/html-test/ref/mini_Ticket253_1.html
new file mode 100644
index 0000000000000000000000000000000000000000..9d04945d7a0eb84df2602853912440a06dc62b1e
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Ticket253_1.html
@@ -0,0 +1,31 @@
+<!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
+    >Ticket253_1</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();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Ticket253_1</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Ticket253_2.html b/utils/haddock/html-test/ref/mini_Ticket253_2.html
new file mode 100644
index 0000000000000000000000000000000000000000..ea62c2ad6ad77b80701f68407889cc8c0c31a16e
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Ticket253_2.html
@@ -0,0 +1,39 @@
+<!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
+    >Ticket253_2</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();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Ticket253_2</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >bar</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Baz</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Ticket61.html b/utils/haddock/html-test/ref/mini_Ticket61.html
new file mode 100644
index 0000000000000000000000000000000000000000..78a0dfbaeaeddbde1f8eb99850d722dcf7e8ee94
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Ticket61.html
@@ -0,0 +1,35 @@
+<!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
+    >Ticket61</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Ticket61</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >C</a
+	  > a</p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Ticket75.html b/utils/haddock/html-test/ref/mini_Ticket75.html
new file mode 100644
index 0000000000000000000000000000000000000000..08d934d9a97dfd96db0c5b3c7d9a7b40ab10f29e
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Ticket75.html
@@ -0,0 +1,41 @@
+<!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
+    >Ticket75</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Ticket75</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > a <a href="" target="main"
+	  >:-</a
+	  > b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >f</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_TitledPicture.html b/utils/haddock/html-test/ref/mini_TitledPicture.html
new file mode 100644
index 0000000000000000000000000000000000000000..c5a95bcd515b69a0059113582a0e047123f20d09
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_TitledPicture.html
@@ -0,0 +1,39 @@
+<!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
+    >TitledPicture</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >TitledPicture</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >foo</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >bar</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_TypeFamilies.html b/utils/haddock/html-test/ref/mini_TypeFamilies.html
new file mode 100644
index 0000000000000000000000000000000000000000..10e65e521ac50de892545e4e89210cd8c0380308
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_TypeFamilies.html
@@ -0,0 +1,107 @@
+<!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
+    >TypeFamilies</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >TypeFamilies</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >X</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Y</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Z</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >Test</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >type family</span
+	  > <a href=""
+	  >Foo</a
+	  > a :: k</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data family</span
+	  > <a href=""
+	  >Bat</a
+	  > a :: *</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > <a href="" target="main"
+	  >Assoc</a
+	  > a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >type family</span
+	  > <a href=""
+	  >Bar</a
+	  > b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >type family</span
+	  > a <a href=""
+	  >&lt;&gt;</a
+	  > b :: k</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > a <a href="" target="main"
+	  >&gt;&lt;</a
+	  > b</p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_TypeOperators.html b/utils/haddock/html-test/ref/mini_TypeOperators.html
new file mode 100644
index 0000000000000000000000000000000000000000..a5c321bff2636ba1a2b465b34caea306bc41f4ed
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_TypeOperators.html
@@ -0,0 +1,97 @@
+<!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
+    >TypeOperators</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >TypeOperators</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > a <a href="" target="main"
+	  >:-:</a
+	  > b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > (a <a href="" target="main"
+	  >:+:</a
+	  > b) c</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >Op</a
+	  > a b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >data</span
+	  > <a href="" target="main"
+	  >O</a
+	  > g f a</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><span class="keyword"
+	  >class</span
+	  > a <a href="" target="main"
+	  >&lt;=&gt;</a
+	  > b</p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >biO</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >f</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >g</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >x</a
+	  ></p
+	></div
+      ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >y</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Unicode.html b/utils/haddock/html-test/ref/mini_Unicode.html
new file mode 100644
index 0000000000000000000000000000000000000000..df06b1c62babc97f03114d5ff2c5dbd0dd2d8ada
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Unicode.html
@@ -0,0 +1,33 @@
+<!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
+    >Unicode</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Unicode</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >x</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/mini_Visible.html b/utils/haddock/html-test/ref/mini_Visible.html
new file mode 100644
index 0000000000000000000000000000000000000000..8a92d3f5beff216ef379408217f034e4105dc808
--- /dev/null
+++ b/utils/haddock/html-test/ref/mini_Visible.html
@@ -0,0 +1,33 @@
+<!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
+    >Visible</title
+    ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+     /><script src="haddock-util.js" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ><script type="text/javascript"
+    >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+    ></head
+  ><body id="mini"
+  ><div id="module-header"
+    ><p class="caption"
+      >Visible</p
+      ></div
+    ><div id="interface"
+    ><div class="top"
+      ><p class="src"
+	><a href="" target="main"
+	  >visible</a
+	  ></p
+	></div
+      ></div
+    ></body
+  ></html
+>
diff --git a/utils/haddock/html-test/ref/minus.gif b/utils/haddock/html-test/ref/minus.gif
new file mode 100644
index 0000000000000000000000000000000000000000..1deac2fe1a42e35b994f1b855488f392c50f6a89
Binary files /dev/null and b/utils/haddock/html-test/ref/minus.gif differ
diff --git a/utils/haddock/html-test/ref/ocean.css b/utils/haddock/html-test/ref/ocean.css
new file mode 100644
index 0000000000000000000000000000000000000000..3ebb14de39cc6dba88474e13ac8fefcdcedeb5b9
--- /dev/null
+++ b/utils/haddock/html-test/ref/ocean.css
@@ -0,0 +1,610 @@
+/* @group Fundamentals */
+
+* { margin: 0; padding: 0 }
+
+/* Is this portable? */
+html {
+  background-color: white;
+  width: 100%;
+  height: 100%;
+}
+
+body {
+  background: white;
+  color: black;
+  text-align: left;
+  min-height: 100%;
+  position: relative;
+}
+
+p {
+  margin: 0.8em 0;
+}
+
+ul, ol {
+  margin: 0.8em 0 0.8em 2em;
+}
+
+dl {
+  margin: 0.8em 0;
+}
+
+dt {
+  font-weight: bold;
+}
+dd {
+  margin-left: 2em;
+}
+
+a { text-decoration: none; }
+a[href]:link { color: rgb(196,69,29); }
+a[href]:visited { color: rgb(171,105,84); }
+a[href]:hover { text-decoration:underline; }
+
+a[href].def:link, a[href].def:visited { color: black; }
+a[href].def:hover { color: rgb(78, 98, 114); }
+
+/* @end */
+
+/* @group Fonts & Sizes */
+
+/* Basic technique & IE workarounds from YUI 3
+   For reasons, see:
+      http://yui.yahooapis.com/3.1.1/build/cssfonts/fonts.css
+ */
+
+body {
+	font:13px/1.4 sans-serif;
+	*font-size:small; /* for IE */
+	*font:x-small; /* for IE in quirks mode */
+}
+
+h1 { font-size: 146.5%; /* 19pt */ }
+h2 { font-size: 131%;   /* 17pt */ }
+h3 { font-size: 116%;   /* 15pt */ }
+h4 { font-size: 100%;   /* 13pt */ }
+h5 { font-size: 100%;   /* 13pt */ }
+
+select, input, button, textarea {
+	font:99% sans-serif;
+}
+
+table {
+	font-size:inherit;
+	font:100%;
+}
+
+pre, code, kbd, samp, tt, .src {
+	font-family:monospace;
+	*font-size:108%;
+	line-height: 124%;
+}
+
+.links, .link {
+  font-size: 85%; /* 11pt */
+}
+
+#module-header .caption {
+  font-size: 182%; /* 24pt */
+}
+
+.info  {
+  font-size: 85%; /* 11pt */
+}
+
+#table-of-contents, #synopsis  {
+  /* font-size: 85%; /* 11pt */
+}
+
+
+/* @end */
+
+/* @group Common */
+
+.caption, h1, h2, h3, h4, h5, h6 {
+  font-weight: bold;
+  color: rgb(78,98,114);
+  margin: 0.8em 0 0.4em;
+}
+
+* + h1, * + h2, * + h3, * + h4, * + h5, * + h6 {
+  margin-top: 2em;
+}
+
+h1 + h2, h2 + h3, h3 + h4, h4 + h5, h5 + h6 {
+  margin-top: inherit;
+}
+
+ul.links {
+  list-style: none;
+  text-align: left;
+  float: right;
+  display: inline-table;
+  margin: 0 0 0 1em;
+}
+
+ul.links li {
+  display: inline;
+  border-left: 1px solid #d5d5d5;
+  white-space: nowrap;
+  padding: 0;
+}
+
+ul.links li a {
+  padding: 0.2em 0.5em;
+}
+
+.hide { display: none; }
+.show { display: inherit; }
+.clear { clear: both; }
+
+.collapser {
+  background-image: url(minus.gif);
+  background-repeat: no-repeat;
+}
+.expander {
+  background-image: url(plus.gif);
+  background-repeat: no-repeat;
+}
+.collapser, .expander {
+  padding-left: 14px;
+  margin-left: -14px;
+  cursor: pointer;
+}
+p.caption.collapser,
+p.caption.expander {
+  background-position: 0 0.4em;
+}
+
+.instance.collapser, .instance.expander {
+  margin-left: 0px;
+  background-position: left center;
+  min-width: 9px;
+  min-height: 9px;
+}
+
+
+pre {
+  padding: 0.25em;
+  margin: 0.8em 0;
+  background: rgb(229,237,244);
+  overflow: auto;
+  border-bottom: 0.25em solid white;
+  /* white border adds some space below the box to compensate
+     for visual extra space that paragraphs have between baseline
+     and the bounding box */
+}
+
+.src {
+  background: #f0f0f0;
+  padding: 0.2em 0.5em;
+}
+
+.keyword { font-weight: normal; }
+.def { font-weight: bold; }
+
+@media print {
+  #footer { display: none; }
+}
+
+/* @end */
+
+/* @group Page Structure */
+
+#content {
+  margin: 0 auto;
+  padding: 0 2em 6em;
+}
+
+#package-header {
+  background: rgb(41,56,69);
+  border-top: 5px solid rgb(78,98,114);
+  color: #ddd;
+  padding: 0.2em;
+  position: relative;
+  text-align: left;
+}
+
+#package-header .caption {
+  background: url(hslogo-16.png) no-repeat 0em;
+  color: white;
+  margin: 0 2em;
+  font-weight: normal;
+  font-style: normal;
+  padding-left: 2em;
+}
+
+#package-header a:link, #package-header a:visited { color: white; }
+#package-header a:hover { background: rgb(78,98,114); }
+
+#module-header .caption {
+  color: rgb(78,98,114);
+  font-weight: bold;
+  border-bottom: 1px solid #ddd;
+}
+
+table.info {
+  float: right;
+  padding: 0.5em 1em;
+  border: 1px solid #ddd;
+  color: rgb(78,98,114);
+  background-color: #fff;
+  max-width: 40%;
+  border-spacing: 0;
+  position: relative;
+  top: -0.5em;
+  margin: 0 0 0 2em;
+}
+
+.info th {
+	padding: 0 1em 0 0;
+}
+
+div#style-menu-holder {
+  position: relative;
+  z-index: 2;
+  display: inline;
+}
+
+#style-menu {
+  position: absolute;
+  z-index: 1;
+  overflow: visible;
+  background: #374c5e;
+  margin: 0;
+  text-align: center;
+  right: 0;
+  padding: 0;
+  top: 1.25em;
+}
+
+#style-menu li {
+	display: list-item;
+	border-style: none;
+	margin: 0;
+	padding: 0;
+	color: #000;
+	list-style-type: none;
+}
+
+#style-menu li + li {
+	border-top: 1px solid #919191;
+}
+
+#style-menu a {
+  width: 6em;
+  padding: 3px;
+  display: block;
+}
+
+#footer {
+  background: #ddd;
+  border-top: 1px solid #aaa;
+  padding: 0.5em 0;
+  color: #666;
+  text-align: center;
+  position: absolute;
+  bottom: 0;
+  width: 100%;
+  height: 3em;
+}
+
+/* @end */
+
+/* @group Front Matter */
+
+#table-of-contents {
+  float: right;
+  clear: right;
+  background: #faf9dc;
+  border: 1px solid #d8d7ad;
+  padding: 0.5em 1em;
+  max-width: 20em;
+  margin: 0.5em 0 1em 1em;
+}
+
+#table-of-contents .caption {
+  text-align: center;
+  margin: 0;
+}
+
+#table-of-contents ul {
+  list-style: none;
+  margin: 0;
+}
+
+#table-of-contents ul ul {
+  margin-left: 2em;
+}
+
+#description .caption {
+  display: none;
+}
+
+#synopsis {
+  display: none;
+}
+
+.no-frame #synopsis {
+  display: block;
+  position: fixed;
+  right: 0;
+  height: 80%;
+  top: 10%;
+  padding: 0;
+  max-width: 75%;
+}
+
+#synopsis .caption {
+  float: left;
+  width: 29px;
+  color: rgba(255,255,255,0);
+  height: 110px;
+  margin: 0;
+  font-size: 1px;
+  padding: 0;
+}
+
+#synopsis p.caption.collapser {
+  background: url(synopsis.png) no-repeat -64px -8px;
+}
+
+#synopsis p.caption.expander {
+  background: url(synopsis.png) no-repeat 0px -8px;
+}
+
+#synopsis ul {
+  height: 100%;
+  overflow: auto;
+  padding: 0.5em;
+  margin: 0;
+}
+
+#synopsis ul ul {
+  overflow: hidden;
+}
+
+#synopsis ul,
+#synopsis ul li.src {
+  background-color: #faf9dc;
+  white-space: nowrap;
+  list-style: none;
+  margin-left: 0;
+}
+
+/* @end */
+
+/* @group Main Content */
+
+#interface div.top { margin: 2em 0; }
+#interface h1 + div.top,
+#interface h2 + div.top,
+#interface h3 + div.top,
+#interface h4 + div.top,
+#interface h5 + div.top {
+ 	margin-top: 1em;
+}
+#interface .src .selflink,
+#interface .src .link {
+  float: right;
+  color: #919191;
+  background: #f0f0f0;
+  padding: 0 0.5em 0.2em;
+  margin: 0 -0.5em 0 0;
+}
+#interface .src .selflink {
+  border-left: 1px solid #919191;
+  margin: 0 -0.5em 0 0.5em;
+}
+
+#interface span.fixity {
+  color: #919191;
+  border-left: 1px solid #919191;
+  padding: 0.2em 0.5em 0.2em 0.5em;
+  margin: 0 -1em 0 1em;
+}
+
+#interface span.rightedge {
+  border-left: 1px solid #919191;
+  padding: 0.2em 0 0.2em 0;
+  margin: 0 0 0 1em;
+}
+
+#interface table { border-spacing: 2px; }
+#interface td {
+  vertical-align: top;
+  padding-left: 0.5em;
+}
+#interface td.src {
+  white-space: nowrap;
+}
+#interface td.doc p {
+  margin: 0;
+}
+#interface td.doc p + p {
+  margin-top: 0.8em;
+}
+
+.clearfix:after {
+  clear: both;
+  content: " ";
+  display: block;
+  height: 0;
+  visibility: hidden;
+}
+
+.subs ul {
+  list-style: none;
+  display: table;
+  margin: 0;
+}
+
+.subs ul li {
+  display: table-row;
+}
+
+.subs ul li dfn {
+  display: table-cell;
+  font-style: normal;
+  font-weight: bold;
+  margin: 1px 0;
+  white-space: nowrap;
+}
+
+.subs ul li > .doc {
+  display: table-cell;
+  padding-left: 0.5em;
+  margin-bottom: 0.5em;
+}
+
+.subs ul li > .doc p {
+  margin: 0;
+}
+
+/* Render short-style data instances */
+.inst ul {
+  height: 100%;
+  padding: 0.5em;
+  margin: 0;
+}
+
+.inst, .inst li {
+  list-style: none;
+  margin-left: 1em;
+}
+
+/* Workaround for bug in Firefox (issue #384) */
+.inst-left {
+  float: left;
+}
+
+.top p.src {
+  border-top: 1px solid #ccc;
+}
+
+.subs, .doc {
+  /* use this selector for one level of indent */
+  padding-left: 2em;
+}
+
+.warning {
+  color: red;
+}
+
+.arguments {
+  margin-top: -0.4em;
+}
+.arguments .caption {
+  display: none;
+}
+
+.fields { padding-left: 1em; }
+
+.fields .caption { display: none; }
+
+.fields p { margin: 0 0; }
+
+/* this seems bulky to me
+.methods, .constructors {
+  background: #f8f8f8;
+  border: 1px solid #eee;
+}
+*/
+
+/* @end */
+
+/* @group Auxillary Pages */
+
+
+.extension-list {
+    list-style-type: none;
+    margin-left: 0;
+}
+
+#mini {
+  margin: 0 auto;
+  padding: 0 1em 1em;
+}
+
+#mini > * {
+  font-size: 93%; /* 12pt */
+}
+
+#mini #module-list .caption,
+#mini #module-header .caption {
+  font-size: 125%; /* 15pt */
+}
+
+#mini #interface h1,
+#mini #interface h2,
+#mini #interface h3,
+#mini #interface h4 {
+  font-size: 109%; /* 13pt */
+  margin: 1em 0 0;
+}
+
+#mini #interface .top,
+#mini #interface .src {
+  margin: 0;
+}
+
+#mini #module-list ul {
+  list-style: none;
+  margin: 0;
+}
+
+#alphabet ul {
+	list-style: none;
+	padding: 0;
+	margin: 0.5em 0 0;
+	text-align: center;
+}
+
+#alphabet li {
+	display: inline;
+	margin: 0 0.25em;
+}
+
+#alphabet a {
+	font-weight: bold;
+}
+
+#index .caption,
+#module-list .caption { font-size: 131%; /* 17pt */ }
+
+#index table {
+  margin-left: 2em;
+}
+
+#index .src {
+  font-weight: bold;
+}
+#index .alt {
+  font-size: 77%; /* 10pt */
+  font-style: italic;
+  padding-left: 2em;
+}
+
+#index td + td {
+  padding-left: 1em;
+}
+
+#module-list ul {
+  list-style: none;
+  margin: 0 0 0 2em;
+}
+
+#module-list li {
+  clear: right;
+}
+
+#module-list span.collapser,
+#module-list span.expander {
+  background-position: 0 0.3em;
+}
+
+#module-list .package {
+  float: right;
+}
+
+/* @end */
diff --git a/utils/haddock/html-test/ref/plus.gif b/utils/haddock/html-test/ref/plus.gif
new file mode 100644
index 0000000000000000000000000000000000000000..2d15c14173d23f664b955cd24f51c82f5f09d91d
Binary files /dev/null and b/utils/haddock/html-test/ref/plus.gif differ
diff --git a/utils/haddock/html-test/ref/synopsis.png b/utils/haddock/html-test/ref/synopsis.png
new file mode 100644
index 0000000000000000000000000000000000000000..85fb86ec84907bcc86531dc82871948ff4d471fa
Binary files /dev/null and b/utils/haddock/html-test/ref/synopsis.png differ
diff --git a/utils/haddock/html-test/run b/utils/haddock/html-test/run
new file mode 100755
index 0000000000000000000000000000000000000000..c14ab7b5dd27811983d5ef66014deac02ee50f9b
--- /dev/null
+++ b/utils/haddock/html-test/run
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+export HADDOCK_PATH=$(which haddock)
+LIB_PATH="$(dirname "$BASH_SOURCE")/../haddock-test/src/"
+MAIN_PATH="$(dirname "$BASH_SOURCE")/Main.hs"
+if [ -z "$RUNHASKELL" ]; then RUNHASKELL=runhaskell; fi
+$RUNHASKELL -i:"$LIB_PATH" $MAIN_PATH $@
diff --git a/utils/haddock/html-test/src/A.hs b/utils/haddock/html-test/src/A.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e23190417f7e411f5eb75e769b814fda5ad4ed4b
--- /dev/null
+++ b/utils/haddock/html-test/src/A.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE Haskell2010 #-}
+module A where
+
+data A = A
+
+other :: Int
+other = 2
+
+-- | Doc for test2
+test2 :: Bool
+test2 = False
+
+-- | Should show up on the page for both modules A and B
+data X = X -- ^ Doc for consructor
+
+-- | Should show up on the page for both modules A and B
+reExport :: Int
+reExport = 1
diff --git a/utils/haddock/html-test/src/B.hs b/utils/haddock/html-test/src/B.hs
new file mode 100644
index 0000000000000000000000000000000000000000..ce7a945c6e7516ad809686aea005afc339dd2201
--- /dev/null
+++ b/utils/haddock/html-test/src/B.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE Haskell2010 #-}
+module B ( module A, test, reExport, X(..) ) where
+import A ( A(..), test2, reExport, X(..) )
+
+-- | This link shouldn't work: 'other'.
+--   These links should work: 'A.other', 'Data.List.sortBy', 'test2', 'A.test2', 'Data.Maybe.fromMaybe'.
+--   Module link: "Prelude".
+test :: Int
+test = 1
diff --git a/utils/haddock/html-test/src/Bold.hs b/utils/haddock/html-test/src/Bold.hs
new file mode 100644
index 0000000000000000000000000000000000000000..91bc671504df9c652a1889b1cfaab65ff73913c5
--- /dev/null
+++ b/utils/haddock/html-test/src/Bold.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bold where
+-- | Some __bold text__.
+--
+-- * __Bold__ in a list
+--
+-- [__bold in a definition__] list
+--
+-- @ bold __in__ a __code__ block @
+foo = undefined
diff --git a/utils/haddock/html-test/src/Bug1.hs b/utils/haddock/html-test/src/Bug1.hs
new file mode 100644
index 0000000000000000000000000000000000000000..6df1b9e2d9155d022503a85228a628033f3f15f4
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug1 where
+
+-- | We should have different anchors for constructors and types\/classes.  This
+-- hyperlink should point to the type constructor by default: 'T'.
+data T = T
+
diff --git a/utils/haddock/html-test/src/Bug1004.hs b/utils/haddock/html-test/src/Bug1004.hs
new file mode 100644
index 0000000000000000000000000000000000000000..f2ee5f61b18c51f1758a781ac7bdfc0a7f4e7faf
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1004.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug1004 (Product(..)) where
+
+import Data.Functor.Product
diff --git a/utils/haddock/html-test/src/Bug1033.hs b/utils/haddock/html-test/src/Bug1033.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4c80e672bf43b6494182d5447912555df18b5e4b
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1033.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE StandaloneDeriving #-}
+
+module Bug1033 where
+
+import GHC.Generics
+
+data Foo = Foo
+
+-- | This does some generic foos.
+deriving instance Generic Foo
diff --git a/utils/haddock/html-test/src/Bug1035.hs b/utils/haddock/html-test/src/Bug1035.hs
new file mode 100644
index 0000000000000000000000000000000000000000..46a6dd1f4380a9e75a6771cc701153045bbf4832
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1035.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug1035 where
+
+data Foo = Bar
+
+data Bar = Foo
+
+-- | A link to 'Bar'
+foo :: ()
+foo = ()
diff --git a/utils/haddock/html-test/src/Bug1050.hs b/utils/haddock/html-test/src/Bug1050.hs
new file mode 100644
index 0000000000000000000000000000000000000000..1fe49ab7beb5de32ea6bd83b309bd8f7bd716214
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1050.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE RankNTypes #-}
+module Bug1050 where
+
+import Data.Kind
+
+newtype T :: (forall k. k -> Type) -> (forall k. k -> Type) where
+  MkT :: forall (f :: forall k. k -> Type) k (a :: k). f a -> T f a
+
+mkT = MkT
diff --git a/utils/haddock/html-test/src/Bug1054.hs b/utils/haddock/html-test/src/Bug1054.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b05d79c0bac4e5914e8353b197c68998ac290fee
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1054.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug1054 where
+
+-- * Header with 'foo' link
+
+foo = ()
diff --git a/utils/haddock/html-test/src/Bug1063.hs b/utils/haddock/html-test/src/Bug1063.hs
new file mode 100644
index 0000000000000000000000000000000000000000..d5b1c69f0686d1f0b15b55586fc2d3777eac7d68
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1063.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE ConstraintKinds #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE QuantifiedConstraints #-}
+{-# LANGUAGE UndecidableInstances #-}
+module Bug1063 where
+
+class    (c => d) => Implies c d
+instance (c => d) => Implies c d
diff --git a/utils/haddock/html-test/src/Bug1067A.hs b/utils/haddock/html-test/src/Bug1067A.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4523d838eeb7a4ac8b870342a22655aabb74a6cd
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1067A.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# language PatternSynonyms #-}
+module Bug1067A ( Foo(P) ) where
+
+-- | A foo
+data Foo = Foo
+
+-- | A pattern
+pattern P :: Foo
+pattern P = Foo
diff --git a/utils/haddock/html-test/src/Bug1067B.hs b/utils/haddock/html-test/src/Bug1067B.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b5ce67f6ec56e9d4fa23c6434d5cd363ae06aeb8
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1067B.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# language PatternSynonyms #-}
+module Bug1067B ( pattern P ) where
+
+import Bug1067A
diff --git a/utils/haddock/html-test/src/Bug1103.hs b/utils/haddock/html-test/src/Bug1103.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c790e8c1550ed0e2592541a4026579069729f181
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug1103.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE TypeFamilies #-}
+module Bug1103 where
+
+import Data.Kind
+
+data family   Foo1 :: Type -> Type
+data instance Foo1 Bool = Foo1Bool
+data instance Foo1 (Maybe a)
+
+data family   Foo2 :: k -> Type
+data instance Foo2 Bool = Foo2Bool
+data instance Foo2 (Maybe a)
+data instance Foo2 :: Char -> Type
+data instance Foo2 :: (Char -> Char) -> Type where
+
+data family   Foo3 :: k
+data instance Foo3
+data instance Foo3 Bool = Foo3Bool
+data instance Foo3 (Maybe a)
+data instance Foo3 :: Char -> Type
+data instance Foo3 :: (Char -> Char) -> Type where
diff --git a/utils/haddock/html-test/src/Bug195.hs b/utils/haddock/html-test/src/Bug195.hs
new file mode 100644
index 0000000000000000000000000000000000000000..304e0c2ebd98120ff97c004959b81ea1be0e8415
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug195.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug195 where
+
+data T = A { someField :: () -- ^ Doc for someField of A
+           , someOtherField :: () -- ^ Doc for someOtherField of A
+           }
+       | B { someField :: () -- ^ Doc for someField of B
+           , someOtherField :: () -- ^ Doc for someOtherField of B
+           }
+       | C { someField :: () -- ^ Doc for someField of C
+           , someOtherField :: () -- ^ Doc for someOtherField of C
+           }
diff --git a/utils/haddock/html-test/src/Bug2.hs b/utils/haddock/html-test/src/Bug2.hs
new file mode 100644
index 0000000000000000000000000000000000000000..6dc79f46128c6af29b1cdbc5e51d7c8d075df9b0
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug2.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug2 ( x ) where
+import B
+x :: A
+x = A
diff --git a/utils/haddock/html-test/src/Bug201.hs b/utils/haddock/html-test/src/Bug201.hs
new file mode 100644
index 0000000000000000000000000000000000000000..caa92d958309df5b868f580d7018491aa4473046
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug201.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE Haskell2010 #-}
+-- 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/utils/haddock/html-test/src/Bug253.hs b/utils/haddock/html-test/src/Bug253.hs
new file mode 100644
index 0000000000000000000000000000000000000000..29a3adc6288fe047823ef5570f66f7263a0b9314
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug253.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | This module tests that if we're trying to link to a /qualified/
+-- identifier that's not in scope, we get an anchor as if it was a
+-- variable. Previous behaviour was to treat it as a type constructor
+-- so issue like #253 arose. Also see @rename@ function comments in
+-- source.
+module Bug253 where
+
+-- | This link should generate @#v@ anchor: 'DoesNotExist.fakeFakeFake'
+foo :: ()
+foo = ()
diff --git a/utils/haddock/html-test/src/Bug26.hs b/utils/haddock/html-test/src/Bug26.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8b9c4162c11739a514b74cf1c3164348f0ae35ae
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug26.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | This module tests the ‘@since …’ annotation.
+--
+-- @since 1.2.3
+module Bug26 where
+
+-- | Foo
+--
+-- @since 2.10.7
+--
+-- @since 2.10.8
+f :: ()
+f = ()
+
+-- | Bar
+g :: ()
+g = ()
+
+-- | Class
+--
+-- @since 1.0
+class C a where
+  -- | @since 1.2.3
+  c_f :: a
+
+-- | instance for ()
+--
+-- @since 0.7.8
+instance C () where
+  c_f = ()
diff --git a/utils/haddock/html-test/src/Bug280.hs b/utils/haddock/html-test/src/Bug280.hs
new file mode 100644
index 0000000000000000000000000000000000000000..d53def96b910cde9805de3b13e32163a1dc07ea1
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug280.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Haskell2010 #-}
+{-|
+Copyright: Foo,
+           Bar,
+           Baz
+
+The module description
+-}
+-- The module header can start with newlines. They are not taken into account for the indentation level
+module Bug280 where
+
+x = ""
diff --git a/utils/haddock/html-test/src/Bug294.hs b/utils/haddock/html-test/src/Bug294.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4bd0bbe30e14f519a72dd1b50a4b88297129f3ec
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug294.hs
@@ -0,0 +1,40 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# 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
+
+import Data.Kind (Type)
+
+data A
+
+class T t where
+  data TO t :: Type
+  data TP t :: Type
+
+  t :: t
+
+instance T A where
+  data TO A = TA { problemField :: A }
+  data TP A = ProblemCtor A
+
+data family DO t :: Type
+data family DP t :: Type
+
+data instance DO A = DA { problemField' :: A }
+data instance DP A = ProblemCtor' A
+
+data GADT :: Type -> Type where
+  Ctor :: { gadtField :: A } -> GADT A
+
+class T' t where
+  data TO' t :: Type
+
+instance T' a where
+  data TO' a = PolyCtor
diff --git a/utils/haddock/html-test/src/Bug298.hs b/utils/haddock/html-test/src/Bug298.hs
new file mode 100644
index 0000000000000000000000000000000000000000..7ab9d21b56cfb27d5af2995ba8967aba1295a18d
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug298.hs
@@ -0,0 +1,23 @@
+{-# LANGUAGE Haskell2010 #-}
+-- We introduced a regression in 2.14.x where we don't consider
+-- identifiers with ^ as valid. We test that the regression goes away
+-- here. It's a silly typo in the parser, really. Same with ★ which is a valid
+-- symbol according to the 2010 report.
+module Bug298 where
+
+
+(<^>) :: (a -> a) -> a -> a
+x <^> y = x y
+
+(<^) :: a -> a -> a
+x <^ y = x
+
+(^>) :: a -> a -> a
+x ^> y = y
+
+(⋆^) :: a -> a -> a
+x ⋆^ y = y
+
+-- | Links to '<^>' and '^>', '<^' and '⋆^'.
+f :: ()
+f = ()
diff --git a/utils/haddock/html-test/src/Bug3.hs b/utils/haddock/html-test/src/Bug3.hs
new file mode 100644
index 0000000000000000000000000000000000000000..1b7e5277efb717ffefa97bf85ee9ba334fc32039
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug3.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug3 where
+
+-- | /multi-line
+-- emphasis/
+foo :: Int
+foo = undefined
diff --git a/utils/haddock/html-test/src/Bug308.hs b/utils/haddock/html-test/src/Bug308.hs
new file mode 100644
index 0000000000000000000000000000000000000000..250a06227e03d5d94a4fa916e963512472b58e2a
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug308.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE Haskell2010 #-}
+-- From 2.14.x onwards we were forgetting to swallow ‘#’ as a special
+-- character resulting in broken anchors if they occurred
+-- mid-paragraph. Here we check that anchors get generated as
+-- expected.
+module Bug308 where
+
+-- | start#startAnchor# followed by middle#middleAnchor# and end#endAnchor#
+f :: ()
+f = ()
+
+{-|
+start "Bug308#startAnchor"
+
+startOldStyle "Bug308\#startAnchor"
+
+middle "Bug308#middleAnchor"
+
+end "Bug308#middleAnchor"
+-}
+g :: ()
+g = ()
diff --git a/utils/haddock/html-test/src/Bug308CrossModule.hs b/utils/haddock/html-test/src/Bug308CrossModule.hs
new file mode 100644
index 0000000000000000000000000000000000000000..45c89040da69beb728d94e2e9f01cf48b081e98b
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug308CrossModule.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE Haskell2010 #-}
+-- Just like Bug308 module but here we test that referring to anchors
+-- from other modules works.
+module Bug308CrossModule where
+
+import Bug308
+
+{-|
+start "Bug308#startAnchor"
+
+startOldStyle "Bug308\#startAnchor"
+
+middle "Bug308#middleAnchor"
+
+end "Bug308#middleAnchor"
+-}
+h :: ()
+h = ()
diff --git a/utils/haddock/html-test/src/Bug310.hs b/utils/haddock/html-test/src/Bug310.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c54eab817be9fff5062dcc2d3481168430c996b0
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug310.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE ExplicitNamespaces #-}
+module Bug310 ( type (+) ) where
+
+import GHC.TypeLits
diff --git a/utils/haddock/html-test/src/Bug313.hs b/utils/haddock/html-test/src/Bug313.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c076c5b88e5dcf636a2d10c8bcf77caf32219db5
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug313.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | The first list is incorrectly numbered as 1. 2. 1.; the second example
+-- renders fine (1. 2. 3.).
+--
+-- See https://github.com/haskell/haddock/issues/313
+module Bug313 where
+
+{- |
+Some text.
+
+1. Item 1
+
+2. Item 2
+
+    > Some code
+
+3. Item 3
+
+Some more text.
+-}
+a :: a
+a = undefined
+
+{- |
+Some text.
+
+1. Item 1
+
+2. Item 2
+
+    > Some code
+
+3. Item 3
+
+-}
+-- | Some more text.
+b :: a
+b = undefined
diff --git a/utils/haddock/html-test/src/Bug335.hs b/utils/haddock/html-test/src/Bug335.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4566830791166f9afe8585dc171e35b21634e1bf
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug335.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE Haskell2010 #-}
+-- Tests for collapsable headers
+module Bug335 where
+
+{-|
+=== __ExF:__
+abc
+-}
+f :: ()
+f = ()
+
+{-|
+=== __ExG:__
+>>> a
+b
+
+>>> c
+d
+
+==== Under ex
+foo
+
+== Out of Ex
+foo
+-}
+g :: ()
+g = ()
diff --git a/utils/haddock/html-test/src/Bug4.hs b/utils/haddock/html-test/src/Bug4.hs
new file mode 100644
index 0000000000000000000000000000000000000000..3343e1b9364321240d9b309ff907d71d23a1c33d
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug4.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug4 where
+-- | don't use apostrophe's in the wrong place's
+foo :: Int
+foo = undefined
+
diff --git a/utils/haddock/html-test/src/Bug458.hs b/utils/haddock/html-test/src/Bug458.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b0fefecf099afa12d47202ca1e01047e29dac381
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug458.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug458 where
+
+-- | See the defn of @'⊆'@.
+(⊆) :: () -> () -> ()
+_ ⊆ _ = ()
+
diff --git a/utils/haddock/html-test/src/Bug466.hs b/utils/haddock/html-test/src/Bug466.hs
new file mode 100644
index 0000000000000000000000000000000000000000..3f0d3acf91d0a45ed179c0f4641df9df7805bcd9
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug466.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE DataKinds, TypeFamilies, StarIsType #-}
+module Bug466 where
+
+import Data.Kind (Type)
+
+class Cl a where
+  type Fam a :: [Type]
+
+data X = X
+instance Cl X where
+  type Fam X = '[Char]
diff --git a/utils/haddock/html-test/src/Bug546.hs b/utils/haddock/html-test/src/Bug546.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e1df6aca7fadbbc5e60ad76d7ccb8639cf3db828
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug546.hs
@@ -0,0 +1,56 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug546 where
+
+-- |Test:
+--
+-- [@[code with square \\ brackets\]@] lorem ipsum
+x = 1
+
+-- |
+--
+-- [@[..\]@]  Matches any of the enclosed characters. Ranges of characters can
+--            be specified by separating the endpoints with a @\'-'@. @\'-'@ or
+--            @']'@ can be matched by including them as the first character(s)
+--            in the list. Never matches path separators: @[\/]@ matches
+--            nothing at all. Named character classes can also be matched:
+--            @[:x:]@ within @[]@ specifies the class named @x@, which matches
+--            certain predefined characters. See below for a full list.
+--
+-- [@[^..\]@ or @[!..\]@] Like @[..]@, but matches any character /not/ listed.
+--                        Note that @[^-x]@ is not the inverse of @[-x]@, but
+--                        the range @[^-x]@.
+--
+-- [@\<m-n>@] Matches any integer in the range m to n, inclusive. The range may
+--            be open-ended by leaving out either number: @\"\<->\"@, for
+--            instance, matches any integer.
+--
+-- [@**/@]    Matches any number of characters, including path separators,
+--            excluding the empty string.
+--
+-- Supported character classes:
+--
+-- [@[:alnum:\]@]  Equivalent to @\"0-9A-Za-z\"@.
+--
+-- [@[:alpha:\]@]  Equivalent to @\"A-Za-z\"@.
+--
+-- [@[:blank:\]@]  Equivalent to @\"\\t \"@.
+--
+-- [@[:cntrl:\]@]  Equivalent to @\"\\0-\\x1f\\x7f\"@.
+--
+-- [@[:digit:\]@]  Equivalent to @\"0-9\"@.
+--
+-- [@[:graph:\]@]  Equivalent to @\"!-~\"@.
+--
+-- [@[:lower:\]@]  Equivalent to @\"a-z\"@.
+--
+-- [@[:print:\]@]  Equivalent to @\" -~\"@.
+--
+-- [@[:punct:\]@]  Equivalent to @\"!-\/:-\@[-`{-~\"@.
+--
+-- [@[:space:\]@]  Equivalent to @\"\\t-\\r \"@.
+--
+-- [@[:upper:\]@]  Equivalent to @\"A-Z\"@.
+--
+-- [@[:xdigit:\]@] Equivalent to @\"0-9A-Fa-f\"@.
+compile :: String -> String
+compile = id
\ No newline at end of file
diff --git a/utils/haddock/html-test/src/Bug548.hs b/utils/haddock/html-test/src/Bug548.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c890a20769fdc753b06e2fe23bc476b509905aec
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug548.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug548 (WrappedArrow(..)) where
+
+import Control.Applicative
diff --git a/utils/haddock/html-test/src/Bug574.hs b/utils/haddock/html-test/src/Bug574.hs
new file mode 100644
index 0000000000000000000000000000000000000000..01602bb3ba0ad96e45b88c332947954ed823b30a
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug574.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
+
+module Bug574 where
+-- See https://github.com/haskell/haddock/issues/574
+
+-- | Something with a spliced type
+foo :: Int -> $(let i = [t| Int |] in [t| $i -> $i |])
+foo x y = x + y
diff --git a/utils/haddock/html-test/src/Bug6.hs b/utils/haddock/html-test/src/Bug6.hs
new file mode 100644
index 0000000000000000000000000000000000000000..de2874aac722021afa523b5d965d741e384920eb
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug6.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | Exporting records.
+module Bug6( A(A), B(B), b, C(C,c1,c2), D(D,d1), E(E) ) where
+
+-- |
+-- This record is exported without its field
+data A = A { a :: Int }
+
+-- |
+-- .. with its field, but the field is named separately in the export list
+-- (the field isn't documented separately since it is already documented here)
+data B = B { b :: Int }
+
+-- |
+-- .. with fields names as subordinate names in the export
+data C = C { c1 :: Int, c2 :: Int }
+
+-- |
+-- .. with only some of the fields exported (we can't handle this one -
+-- how do we render the declaration?)
+data D = D { d1 :: Int, d2 :: Int }
+
+-- | a newtype with a field
+newtype E = E { e :: Int }
diff --git a/utils/haddock/html-test/src/Bug613.hs b/utils/haddock/html-test/src/Bug613.hs
new file mode 100644
index 0000000000000000000000000000000000000000..3bdd0ac2889f3a628fd3668ab04788967c06e5b2
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug613.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug613  where
+
+import Prelude (Either(Left, Right))
+
+class Functor f where
+  fmap :: (a -> b) -> f a -> f b
+
+instance Functor (Either a) where
+  fmap _ (Left x) = Left x
+  fmap f (Right y) = Right (f y)
+
+-- | Phantom type a0 is added to block the first renaming from a to a0. This ensures that the renamer doesn't create a new conflict
+data ThreeVars a0 a b = ThreeVars a b
+
+instance Functor (ThreeVars a0 a) where
+  fmap f (ThreeVars a b) = ThreeVars a (f b)
diff --git a/utils/haddock/html-test/src/Bug647.hs b/utils/haddock/html-test/src/Bug647.hs
new file mode 100644
index 0000000000000000000000000000000000000000..35330abc6cbd9485f601312f7524931583422152
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug647.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug647 where
+
+class Bug647 a where
+  f :: a -- ^ doc for arg1
+    -> a -- ^ doc for arg2
+    -> a -- ^ doc for arg3
\ No newline at end of file
diff --git a/utils/haddock/html-test/src/Bug679.hs b/utils/haddock/html-test/src/Bug679.hs
new file mode 100644
index 0000000000000000000000000000000000000000..1e64943dc5faba43b11587a067cdd9c2e1421960
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug679.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+module Bug679 where
+
+import Language.Haskell.TH
+
+data Bar a = Bar
+
+$(do
+   a <- newName "a"
+   
+   let classN = mkName "Foo"
+   let methodN = mkName "foo"
+
+   methodTy <- [t| $(varT a) -> $(varT a) |]
+   let cla = ClassD [] classN [PlainTV a BndrReq] [] [SigD methodN methodTy]
+ 
+   -- Note that we are /reusing/ the same type variable 'a' as in the class
+   instanceHead <- [t| $(conT classN) (Bar $(varT a)) |]
+   idCall <- [e| id |]
+   let ins = InstanceD Nothing [] instanceHead [FunD methodN [Clause [] (NormalB idCall) []]]
+    
+   pure [cla,ins])
+
diff --git a/utils/haddock/html-test/src/Bug7.hs b/utils/haddock/html-test/src/Bug7.hs
new file mode 100644
index 0000000000000000000000000000000000000000..aeb7d96e022432f27bfca9d3b23d6e8e1e938eda
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug7.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+-- | This module caused a duplicate instance in the documentation for the Foo
+-- type.
+module Bug7  where
+
+-- | The Foo datatype
+data Foo = Foo
+
+-- | The Bar class
+class Bar x y
+
+-- | Just one instance
+instance Bar Foo Foo
diff --git a/utils/haddock/html-test/src/Bug8.hs b/utils/haddock/html-test/src/Bug8.hs
new file mode 100644
index 0000000000000000000000000000000000000000..1b50ce9c39e02431de17ed79909c100220336dc0
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug8.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug8 where
+
+infix -->
+infix --->
+
+data Typ = Type (Typ,[Typ])
+         | TFree (Typ, [Typ])
+
+x --> y = Type(s,[s,t])
+(--->) :: (Foldable t0) => t0 t -> Typ -> Typ
+(--->) = flip $ foldr (-->)
+
+s = undefined
+t = undefined
+main = undefined
diff --git a/utils/haddock/html-test/src/Bug85.hs b/utils/haddock/html-test/src/Bug85.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e226c69d84c0b5eb80b15865fa8c20f639c848c3
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug85.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE GADTs, KindSignatures #-}
+module Bug85 where
+
+import Data.Kind (Type)
+
+-- explicitly stated non-trivial kind
+data Foo :: (Type -> Type) -> Type -> Type where
+  Bar :: f x -> Foo f (f x)
+
+-- Just kind * but explicitly written
+data Baz :: Type where
+  Baz' :: Baz
+
+-- No kind signature written down at all
+data Qux where
+  Quux :: Qux
diff --git a/utils/haddock/html-test/src/Bug865.hs b/utils/haddock/html-test/src/Bug865.hs
new file mode 100644
index 0000000000000000000000000000000000000000..86627f8efce4af877093ba5bd9a7e2611b671e32
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug865.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug865 where
+
+-- | An emphasized link [yes /this/ is emphasized while this is
+-- @monospaced@](https://www.haskell.org/). And here is an image:
+--
+-- ![/emphasis/ stripped](https://www.haskell.org/static/img/haskell-logo.svg)
+--
+link :: ()
+link = ()
diff --git a/utils/haddock/html-test/src/Bug923.hs b/utils/haddock/html-test/src/Bug923.hs
new file mode 100644
index 0000000000000000000000000000000000000000..68e1b1536362a0468da601401e91265b48597f52
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug923.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE KindSignatures, FlexibleInstances, GADTs, DataKinds #-}
+module Bug923 where
+
+import Data.Kind (Type)
+
+-- | A promoted tuple type
+data T :: (Type -> (Type,Type)) -> Type where
+  T :: a -> T ('(,) a)
+
+-- | A promoted tuple type in an instance
+instance Eq a => Eq (T ('(,) a)) where
+  T x == T y = x == y
+
diff --git a/utils/haddock/html-test/src/Bug952.hs b/utils/haddock/html-test/src/Bug952.hs
new file mode 100644
index 0000000000000000000000000000000000000000..0840e46c295b8507a28697b2c9fb86b21ffd5290
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug952.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug952 where
+
+-- | See 'case', 'of', '--' compared to 'Q.case', 'Q.of', 'Q.--'
+foo :: ()
+foo = ()
diff --git a/utils/haddock/html-test/src/Bug953.hs b/utils/haddock/html-test/src/Bug953.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4ff3e8ae33a9cf41de9bb25f6bd53e33a0373c64
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug953.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bug953 where
+
+{- | A foo
+
+==== __Examples__
+
+Foo example body
+-}
+data Foo = Foo'
+
+{- | A bar
+
+==== __Examples__
+
+Bar example body
+-}
+data Bar = Bar'
diff --git a/utils/haddock/html-test/src/Bug973.hs b/utils/haddock/html-test/src/Bug973.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e55385c542a56a5734c999f4c0b80faae313a523
--- /dev/null
+++ b/utils/haddock/html-test/src/Bug973.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE ExplicitForAll #-}
+module Bug973 where
+
+showRead
+  :: forall a b. (Show a, Read b)
+  => a -- ^ this gets turned into a string...
+  -> b -- ^ ...from which this is read
+showRead = read . show
+
+-- | Same as 'showRead', but with type variable order flipped
+showRead'
+  :: forall b a. (Show a, Read b)
+  => a -- ^ this gets turned into a string...
+  -> b -- ^ ...from which this is read
+showRead' = read . show
diff --git a/utils/haddock/html-test/src/BugDeprecated.hs b/utils/haddock/html-test/src/BugDeprecated.hs
new file mode 100644
index 0000000000000000000000000000000000000000..9dfef1768344253f68b8470df8cc2fa8b7cc8336
--- /dev/null
+++ b/utils/haddock/html-test/src/BugDeprecated.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE Haskell2010 #-}
+module BugDeprecated where
+
+foo :: Int
+foo = 23
+
+bar :: Int
+bar = 23
+
+baz :: Int
+baz = 23
+{-# DEPRECATED foo "for foo" #-}
+{-# DEPRECATED bar "for bar" #-}
+{-# DEPRECATED baz "for baz" #-}
+
+-- | some documentation for one
+one :: Int
+one = 23
+
+two :: Int
+two = 23
+
+three :: Int
+three = 23
+{-# DEPRECATED one "for one" #-}
+{-# DEPRECATED two "for two" #-}
+{-# DEPRECATED three "for three" #-}
diff --git a/utils/haddock/html-test/src/BugExportHeadings.hs b/utils/haddock/html-test/src/BugExportHeadings.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b664a4482980a65b0583b72f77a569c29f63ae12
--- /dev/null
+++ b/utils/haddock/html-test/src/BugExportHeadings.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE Haskell2010 #-}
+-- test for #192
+module BugExportHeadings (
+-- * Foo
+  foo
+-- * Bar
+, bar
+-- * Baz
+, baz
+
+-- * One
+, one
+-- * Two
+, two
+-- * Three
+, three
+) where
+
+foo, bar, baz :: Int
+foo = 23
+bar = 23
+baz = 23
+
+one, two, three :: Int
+one = 23
+two = 23
+three = 23
+{-# DEPRECATED one "for one" #-}
+{-# DEPRECATED two "for two" #-}
+{-# DEPRECATED three "for three" #-}
diff --git a/utils/haddock/html-test/src/Bugs.hs b/utils/haddock/html-test/src/Bugs.hs
new file mode 100644
index 0000000000000000000000000000000000000000..aed716a427b9444a2775caafb80f0d0e151a7939
--- /dev/null
+++ b/utils/haddock/html-test/src/Bugs.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module Bugs where
+
+data A a = A a (a -> Int)
diff --git a/utils/haddock/html-test/src/BundledPatterns.hs b/utils/haddock/html-test/src/BundledPatterns.hs
new file mode 100644
index 0000000000000000000000000000000000000000..6270e2cbda3484a4812ddb34cf66ac8aee10029c
--- /dev/null
+++ b/utils/haddock/html-test/src/BundledPatterns.hs
@@ -0,0 +1,113 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE DataKinds, GADTs, KindSignatures, PatternSynonyms, TypeOperators,
+             ViewPatterns #-}
+module BundledPatterns (Vec(Nil,(:>)), RTree (LR,BR)) where
+
+import Data.Kind (Type)
+
+import GHC.TypeLits
+import Prelude hiding (head, tail)
+import Unsafe.Coerce
+
+-- | Fixed size vectors.
+--
+-- * Lists with their length encoded in their type
+-- * 'Vec'tor elements have an __ASCENDING__ subscript starting from 0 and
+--   ending at @'length' - 1@.
+data Vec :: Nat -> Type -> Type where
+  Nil  :: Vec 0 a
+  Cons :: a -> Vec n a -> Vec (n + 1) a
+
+infixr 5 `Cons`
+
+-- | Add an element to the head of a vector.
+--
+-- >>> 3:>4:>5:>Nil
+-- <3,4,5>
+-- >>> let x = 3:>4:>5:>Nil
+-- >>> :t x
+-- x :: Num a => Vec 3 a
+--
+-- Can be used as a pattern:
+--
+-- >>> let f (x :> y :> _) = x + y
+-- >>> :t f
+-- f :: Num a => Vec ((n + 1) + 1) a -> a
+-- >>> f (3:>4:>5:>6:>7:>Nil)
+-- 7
+--
+-- Also in conjunctions with (':<'):
+--
+-- >>> let g (a :> b :> (_ :< y :< x)) = a + b +  x + y
+-- >>> :t g
+-- g :: Num a => Vec ((((n + 1) + 1) + 1) + 1) a -> a
+-- >>> g (1:>2:>3:>4:>5:>Nil)
+-- 12
+pattern (:>) :: a -> Vec n a -> Vec (n + 1) a
+pattern (:>) x xs <- ((\ys -> (head ys,tail ys)) -> (x,xs))
+  where
+    (:>) x xs = Cons x xs
+
+infixr 5 :>
+
+head :: Vec (n + 1) a -> a
+head (x `Cons` _) = x
+
+tail :: Vec (n + 1) a -> Vec n a
+tail (_ `Cons` xs) = unsafeCoerce xs
+
+-- | Perfect depth binary tree.
+--
+-- * Only has elements at the leaf of the tree
+-- * A tree of depth /d/ has /2^d/ elements.
+data RTree :: Nat -> Type -> Type where
+  LR_ :: a -> RTree 0 a
+  BR_ :: RTree d a -> RTree d a -> RTree (d+1) a
+
+textract :: RTree 0 a -> a
+textract (LR_ x) = x
+{-# NOINLINE textract #-}
+
+tsplit :: RTree (d+1) a -> (RTree d a,RTree d a)
+tsplit (BR_ l r) = (unsafeCoerce l, unsafeCoerce r)
+{-# NOINLINE tsplit #-}
+
+-- | Leaf of a perfect depth tree
+--
+-- >>> LR 1
+-- 1
+-- >>> let x = LR 1
+-- >>> :t x
+-- x :: Num a => RTree 0 a
+--
+-- Can be used as a pattern:
+--
+-- >>> let f (LR a) (LR b) = a + b
+-- >>> :t f
+-- f :: Num a => RTree 0 a -> RTree 0 a -> a
+-- >>> f (LR 1) (LR 2)
+-- 3
+pattern LR :: a -> RTree 0 a
+pattern LR x <- (textract -> x)
+  where
+    LR x = LR_ x
+
+-- | Branch of a perfect depth tree
+--
+-- >>> BR (LR 1) (LR 2)
+-- <1,2>
+-- >>> let x = BR (LR 1) (LR 2)
+-- >>> :t x
+-- x :: Num a => RTree 1 a
+--
+-- Case be used a pattern:
+--
+-- >>> let f (BR (LR a) (LR b)) = LR (a + b)
+-- >>> :t f
+-- f :: Num a => RTree 1 a -> RTree 0 a
+-- >>> f (BR (LR 1) (LR 2))
+-- 3
+pattern BR :: RTree d a -> RTree d a -> RTree (d+1) a
+pattern BR l r <- ((\t -> (tsplit t)) -> (l,r))
+  where
+    BR l r = BR_ l r
diff --git a/utils/haddock/html-test/src/BundledPatterns2.hs b/utils/haddock/html-test/src/BundledPatterns2.hs
new file mode 100644
index 0000000000000000000000000000000000000000..6f1b61f52578e1e998cf48229bca3528c77e4ee4
--- /dev/null
+++ b/utils/haddock/html-test/src/BundledPatterns2.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE DataKinds, GADTs, KindSignatures, PatternSynonyms #-}
+module BundledPatterns2 (Vec((:>), Empty), RTree(..)) where
+
+import GHC.TypeLits
+
+import BundledPatterns
+
+pattern Empty :: Vec 0 a
+pattern Empty <- Nil
diff --git a/utils/haddock/html-test/src/ConstructorArgs.hs b/utils/haddock/html-test/src/ConstructorArgs.hs
new file mode 100644
index 0000000000000000000000000000000000000000..40697d132a5f5a863d406fbe63e391efaa2e6e91
--- /dev/null
+++ b/utils/haddock/html-test/src/ConstructorArgs.hs
@@ -0,0 +1,57 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE GADTs, PatternSynonyms #-}
+
+module ConstructorArgs (Foo(..), Boo(Foo, Foa, Fo, Fo'), pattern Bo, pattern Bo') where
+
+data Foo
+  = Rec             -- ^ doc on a record
+     { x :: String  -- ^ doc on the `String` field of `Rec`
+     , y :: String  -- ^ doc on the `String` field of `Rec`
+     }
+   | Baz Int String  -- ^ old prefix doc style
+   | Boa             -- ^ doc on the `Boa` constrictor
+       !Int          -- ^ doc on the `Int` field of `Boa`
+       !String       -- ^ doc on the `String` field of `Boa`
+   | Int :| String   -- ^ old infix doc style
+   | Int             -- ^ doc on the `Int` field of the `:*` constructor
+       :*            -- ^ doc on the `:*` constructor
+     String          -- ^ doc on the `String` field of the `:*` constructor
+
+infixr 1 `Foo`
+infixr 2 `Boa`
+infixr 3 :*
+
+data Boo where
+  -- | Info about a 'Foo'
+  Foo :: Int    -- ^ `Int` field of `Foo`
+      -> String -- ^ `String` field of `Foo`
+      -> Boo    -- ^ Make a `Boo`
+
+  -- | no argument docs GADT
+  Foa :: Int -> Boo
+
+infixr 4 `Boo`
+
+-- | Info about bundled 'Fo'
+pattern Fo :: Int    -- ^ an 'Int'
+           -> String -- ^ a 'String'
+           -> Boo    -- ^ a 'Boo'
+pattern Fo x y = Foo x y
+
+-- | Bundled and no argument docs
+pattern Fo' :: Boo
+pattern Fo' = Foo 1 "hi"
+
+infixr 5 `Fo`
+
+-- | Info about not-bundled 'Bo'
+pattern Bo :: Int    -- ^ an 'Int'
+           -> String -- ^ a 'String'
+           -> Boo -- ^ a 'Boo' pattern
+pattern Bo x y = Foo x y
+
+-- | Not bundled and no argument docs
+pattern Bo' :: Int -> String -> Boo
+pattern Bo' x y = Foo x y
+
+infixr 6 `Bo`
diff --git a/utils/haddock/html-test/src/ConstructorPatternExport.hs b/utils/haddock/html-test/src/ConstructorPatternExport.hs
new file mode 100644
index 0000000000000000000000000000000000000000..eb04b29c2f50650d0de296b621e5c973db4bb040
--- /dev/null
+++ b/utils/haddock/html-test/src/ConstructorPatternExport.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE PatternSynonyms #-}
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE KindSignatures #-}
+
+module ConstructorPatternExport (
+    pattern FooCons
+  , pattern MyRecCons
+  , pattern (:+)
+  , pattern BlubCons
+  , pattern MyGADTCons
+  ) where
+
+import Data.Kind (Type)
+
+data Foo a = FooCons String a
+
+data MyRec = MyRecCons { one :: Bool, two :: Int }
+
+data MyInfix a = String :+ a
+
+data Blub = forall b. Show b => BlubCons b
+
+data MyGADT :: Type -> Type where
+  MyGADTCons :: forall a. Eq a => a -> Int -> MyGADT (Maybe String)
+
+pattern MyGADTCons' :: () => forall a. Eq a => a -> Int -> MyGADT (Maybe String)
+pattern MyGADTCons' x y = MyGADTCons x y
\ No newline at end of file
diff --git a/utils/haddock/html-test/src/CrossPackageDocs.hs_hidden b/utils/haddock/html-test/src/CrossPackageDocs.hs_hidden
new file mode 100644
index 0000000000000000000000000000000000000000..4d529f79e3ae12f7b60fa5863895ae705a03cf2c
--- /dev/null
+++ b/utils/haddock/html-test/src/CrossPackageDocs.hs_hidden
@@ -0,0 +1,4 @@
+module CrossPackageDocs (map, IsString(..), runInteractiveProcess) where
+
+import System.Process
+import Data.String
diff --git a/utils/haddock/html-test/src/DefaultAssociatedTypes.hs b/utils/haddock/html-test/src/DefaultAssociatedTypes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..aeaefc88c0e0f3b4a6ffbd639eccf02f4a81afec
--- /dev/null
+++ b/utils/haddock/html-test/src/DefaultAssociatedTypes.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies #-}
+
+module DefaultAssociatedTypes where
+
+import Data.Kind (Type)
+
+-- | Documentation for Foo.
+class Foo a where
+  -- | Documentation for bar and baz.
+  bar, baz :: a -> String
+
+  -- | Doc for Qux
+  type Qux a :: Type
+
+  -- | Doc for default Qux
+  type Qux a = [a]
diff --git a/utils/haddock/html-test/src/DefaultSignatures.hs b/utils/haddock/html-test/src/DefaultSignatures.hs
new file mode 100644
index 0000000000000000000000000000000000000000..1b1b8257011606b8e08b20be84d9f931bf7c7108
--- /dev/null
+++ b/utils/haddock/html-test/src/DefaultSignatures.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE DefaultSignatures #-}
+
+module DefaultSignatures where
+
+-- | Documentation for Foo.
+class Foo a where
+  -- | Documentation for bar and baz.
+  bar, baz :: a -> String
+
+  -- | Documentation for the default signature of bar.
+  default bar :: Show a => a -> String
+  bar = show
+
+  -- | Documentation for baz'.
+  baz' :: String -> a
+
+  -- | Documentation for the default signature of baz'.
+  default baz' :: Read a => String -> a
+  baz' = read
diff --git a/utils/haddock/html-test/src/DeprecatedClass.hs b/utils/haddock/html-test/src/DeprecatedClass.hs
new file mode 100644
index 0000000000000000000000000000000000000000..357f64e495a6494c6c8b7b2129b17e480b9a297f
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedClass.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE Haskell2010 #-}
+module DeprecatedClass where
+
+-- | some class
+class SomeClass a where
+  -- | documentation for foo
+  foo :: a -> a
+
+{-# DEPRECATED SomeClass "SomeClass" #-}
+{-# DEPRECATED foo "foo" #-}
+
+class SomeOtherClass a where
+  bar :: a -> a
+
+{-# DEPRECATED SomeOtherClass "SomeOtherClass" #-}
+{-# DEPRECATED bar "bar" #-}
diff --git a/utils/haddock/html-test/src/DeprecatedData.hs b/utils/haddock/html-test/src/DeprecatedData.hs
new file mode 100644
index 0000000000000000000000000000000000000000..f23241623ade1682fe607177a6cc917bb6132b55
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedData.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies #-}
+module DeprecatedData where
+
+-- | type Foo
+data Foo = Foo -- ^ constructor Foo
+         | Bar -- ^ constructor Bar
+
+{-# DEPRECATED Foo "Foo" #-}
+{-# DEPRECATED Bar "Bar" #-}
+
+data One = One
+         | Two
+
+{-# DEPRECATED One "One" #-}
+{-# DEPRECATED Two "Two" #-}
diff --git a/utils/haddock/html-test/src/DeprecatedFunction.hs b/utils/haddock/html-test/src/DeprecatedFunction.hs
new file mode 100644
index 0000000000000000000000000000000000000000..2c6418d396baeb2b591e9247e4fdaa9cb267f4c5
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedFunction.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE Haskell2010 #-}
+module DeprecatedFunction where
+
+-- | some documentation for foo
+foo :: Int
+foo = 23
+{-# DEPRECATED foo "use `bar` instead" #-}
+
+-- | some documentation for bar
+bar :: Int
+bar = 42
diff --git a/utils/haddock/html-test/src/DeprecatedFunction2.hs b/utils/haddock/html-test/src/DeprecatedFunction2.hs
new file mode 100644
index 0000000000000000000000000000000000000000..fb4193f2bc7b2804a10bf9814ec5da0e666ffc97
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedFunction2.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Haskell2010 #-}
+module DeprecatedFunction2 where
+
+
+foo :: Int
+foo = 23
+{-# DEPRECATED foo "use bar instead" #-}
diff --git a/utils/haddock/html-test/src/DeprecatedFunction3.hs b/utils/haddock/html-test/src/DeprecatedFunction3.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4a286e0ad83e0df4dc3513e98a9dc3eb003ac34e
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedFunction3.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Haskell2010 #-}
+module DeprecatedFunction3 where
+
+
+
+foo = 23
+{-# DEPRECATED foo "use bar instead" #-}
diff --git a/utils/haddock/html-test/src/DeprecatedModule.hs b/utils/haddock/html-test/src/DeprecatedModule.hs
new file mode 100644
index 0000000000000000000000000000000000000000..179b589945be63e9fcc24cce387ff00ef8381079
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedModule.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | Documentation for "DeprecatedModule".
+module DeprecatedModule {-# DEPRECATED "Use \"Foo\" instead" #-} where
+
+foo :: Int
+foo = 23
diff --git a/utils/haddock/html-test/src/DeprecatedModule2.hs b/utils/haddock/html-test/src/DeprecatedModule2.hs
new file mode 100644
index 0000000000000000000000000000000000000000..ccec1be7c626db5f03c495f1df5e4e479a5becb8
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedModule2.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE Haskell2010 #-}
+module DeprecatedModule2 {-# DEPRECATED "Use Foo instead" #-} where
+
+foo :: Int
+foo = 23
diff --git a/utils/haddock/html-test/src/DeprecatedNewtype.hs b/utils/haddock/html-test/src/DeprecatedNewtype.hs
new file mode 100644
index 0000000000000000000000000000000000000000..6aeead44172496dddad9090245195bb079f24f57
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedNewtype.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE Haskell2010 #-}
+module DeprecatedNewtype where
+
+-- | some documentation
+newtype SomeNewType = SomeNewTypeConst String {- ^ constructor docu -}
+{-# DEPRECATED SomeNewType "SomeNewType" #-}
+{-# DEPRECATED SomeNewTypeConst "SomeNewTypeConst" #-}
+
+newtype SomeOtherNewType = SomeOtherNewTypeConst String
+{-# DEPRECATED SomeOtherNewType "SomeOtherNewType" #-}
+{-# DEPRECATED SomeOtherNewTypeConst "SomeOtherNewTypeConst" #-}
diff --git a/utils/haddock/html-test/src/DeprecatedReExport.hs b/utils/haddock/html-test/src/DeprecatedReExport.hs
new file mode 100644
index 0000000000000000000000000000000000000000..061c9c2736835a49887892baa8a91530a9a427f1
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedReExport.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE Haskell2010 #-}
+-- |
+-- What is tested here:
+--
+-- * Deprecation messages are shown for re-exported items.
+--
+module DeprecatedReExport (
+-- * Re-exported from an other module
+  foo
+-- * Re-exported from an other package
+-- | Not yet working, see <http://trac.haskell.org/haddock/ticket/223>
+-- , isEmptyChan
+,
+) where
+
+import DeprecatedFunction
+import Control.Concurrent.Chan
diff --git a/utils/haddock/html-test/src/DeprecatedRecord.hs b/utils/haddock/html-test/src/DeprecatedRecord.hs
new file mode 100644
index 0000000000000000000000000000000000000000..9fe0240d57ce63e3a93e941860d5f877d8af38de
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedRecord.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+module DeprecatedRecord where
+
+-- | type Foo
+data Foo = Foo {
+  fooName  :: String -- ^ some name
+, fooValue :: Int    -- ^ some value
+}
+
+{-# DEPRECATED fooValue "do not use this" #-}
diff --git a/utils/haddock/html-test/src/DeprecatedTypeFamily.hs b/utils/haddock/html-test/src/DeprecatedTypeFamily.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e161e101a44bbae17a57d1dfd855af6054a84e9b
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedTypeFamily.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies #-}
+module DeprecatedTypeFamily where
+
+import Data.Kind (Type)
+
+-- | some documentation
+data family SomeTypeFamily k :: Type -> Type
+{-# DEPRECATED SomeTypeFamily "SomeTypeFamily" #-}
+
+data family SomeOtherTypeFamily k :: Type -> Type
+{-# DEPRECATED SomeOtherTypeFamily "SomeOtherTypeFamily" #-}
diff --git a/utils/haddock/html-test/src/DeprecatedTypeSynonym.hs b/utils/haddock/html-test/src/DeprecatedTypeSynonym.hs
new file mode 100644
index 0000000000000000000000000000000000000000..05fb9bdc713209b32af9355554c87c3f5a860506
--- /dev/null
+++ b/utils/haddock/html-test/src/DeprecatedTypeSynonym.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+
+module DeprecatedTypeSynonym where
+
+-- | some documentation
+type TypeSyn = String
+{-# DEPRECATED TypeSyn "TypeSyn" #-}
+
+type OtherTypeSyn = String
+{-# DEPRECATED OtherTypeSyn "OtherTypeSyn" #-}
diff --git a/utils/haddock/html-test/src/DuplicateRecordFields.hs b/utils/haddock/html-test/src/DuplicateRecordFields.hs
new file mode 100644
index 0000000000000000000000000000000000000000..594417508093fe0b4749dd99673d2ef34203ccfb
--- /dev/null
+++ b/utils/haddock/html-test/src/DuplicateRecordFields.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE DuplicateRecordFields #-}
+module DuplicateRecordFields (RawReplay(..)) where
+
+import Prelude hiding (Int)
+
+data Int = Int
+
+data RawReplay = RawReplay
+    { headerSize :: Int
+    -- ^ The byte size of the first section.
+    , headerCRC :: Int
+    -- ^ The CRC of the first section.
+    , header :: Int
+    -- ^ The first section.
+    , contentSize :: Int
+    -- ^ The byte size of the second section.
+    , contentCRC :: Int
+    -- ^ The CRC of the second section.
+    , content :: Int
+    -- ^ The second section.
+    , footer :: Int
+    -- ^ Arbitrary data after the second section. In replays generated by
+    -- Rocket League, this is always empty. However it is not technically
+    -- invalid to put something here.
+    }
\ No newline at end of file
diff --git a/utils/haddock/html-test/src/Examples.hs b/utils/haddock/html-test/src/Examples.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b518ea7011a5245ebc6cbb44cc5e7e0415178f8e
--- /dev/null
+++ b/utils/haddock/html-test/src/Examples.hs
@@ -0,0 +1,40 @@
+{-# LANGUAGE Haskell2010 #-}
+module Examples where
+
+-- | Fibonacci number of given 'Integer'.
+--
+-- Examples:
+--
+-- >>> fib 5
+-- 5
+-- >>> fib 10
+-- 55
+--
+-- >>> fib 10
+-- 55
+--
+-- One more Example:
+--
+-- >>> fib 5
+-- 5
+--
+-- One more Example:
+--
+-- >>> fib 5
+-- 5
+--
+-- Example with an import:
+--
+-- >>> import Data.Char
+-- >>> isSpace 'a'
+-- False
+--
+-- >>> putStrLn "foo\n\nbar"
+-- foo
+-- <BLANKLINE>
+-- bar
+--
+fib :: Integer -> Integer
+fib 0 = 0
+fib 1 = 1
+fib n = fib (n - 1) + fib (n - 2)
diff --git a/utils/haddock/html-test/src/ExportSince1.hs b/utils/haddock/html-test/src/ExportSince1.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b5425fa5b31fb18045ba49d57e68fc7c65457257
--- /dev/null
+++ b/utils/haddock/html-test/src/ExportSince1.hs
@@ -0,0 +1,21 @@
+module ExportSince1
+  ( hello1
+  , hello2
+  , HelloTy(..)
+  , HelloClass(..)
+  ) where
+
+-- | @since 1.0
+hello1 :: String
+hello1 = "Hello"
+
+-- | @since 1.0
+hello2 :: String
+hello2 = "Hello"
+
+-- | @since 1.0
+data HelloTy = HelloTy { field1 :: String }
+
+-- | @since 1.0
+class HelloClass a where
+  method1 :: a -> String
diff --git a/utils/haddock/html-test/src/ExportSince2.hs b/utils/haddock/html-test/src/ExportSince2.hs
new file mode 100644
index 0000000000000000000000000000000000000000..eca14fea591d990a7845912e035b7cb4d7f188eb
--- /dev/null
+++ b/utils/haddock/html-test/src/ExportSince2.hs
@@ -0,0 +1,8 @@
+module ExportSince2
+  ( hello1, -- ^ @since 2.0
+    hello2, -- ^ @since 2.0
+    HelloTy,  -- ^ @since 2.0
+    HelloClass,  -- ^ @since 2.0
+  ) where
+
+import ExportSince1
diff --git a/utils/haddock/html-test/src/Extensions.hs b/utils/haddock/html-test/src/Extensions.hs
new file mode 100644
index 0000000000000000000000000000000000000000..bbaa6395906f90bbcd297dd6ff3789afde8272fb
--- /dev/null
+++ b/utils/haddock/html-test/src/Extensions.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE Haskell2010, ExplicitForAll, MonomorphismRestriction #-}
+{-# OPTIONS_HADDOCK show-extensions #-}
+module Extensions where
+
+-- | Bar
+foobar :: t
+foobar = undefined
diff --git a/utils/haddock/html-test/src/FunArgs.hs b/utils/haddock/html-test/src/FunArgs.hs
new file mode 100644
index 0000000000000000000000000000000000000000..6c6a74e67878f99281bbb375cf43f6b05316d25a
--- /dev/null
+++ b/utils/haddock/html-test/src/FunArgs.hs
@@ -0,0 +1,39 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE RankNTypes, DataKinds, TypeFamilies, TypeOperators #-}
+module FunArgs where
+
+f :: forall a. Ord a
+  => Int          -- ^ First argument
+  -> a            -- ^ Second argument
+  -> Bool         -- ^ Third argument
+  -> (a -> a)     -- ^ Fourth argument
+  -> ()           -- ^ Result
+f = undefined
+
+
+g :: a -- ^ First argument
+  -> b -- ^ Second argument
+  -> c -- ^ Third argument
+  -> d -- ^ Result
+g = undefined
+
+
+h :: forall a b c
+  .  a -- ^ First argument
+  -> b -- ^ Second argument
+  -> c -- ^ Third argument
+  -> forall d. d -- ^ Result
+h _ _ _ = undefined
+
+
+i :: forall a (b :: ()) d. (d ~ '())
+  => forall c
+  .  a b c d -- ^ abcd
+  -> ()      -- ^ Result
+i = undefined
+
+
+j :: forall proxy (a :: ()) b
+  .  proxy a -- ^ First argument
+  -> b       -- ^ Result
+j = undefined
diff --git a/utils/haddock/html-test/src/GADTRecords.hs b/utils/haddock/html-test/src/GADTRecords.hs
new file mode 100644
index 0000000000000000000000000000000000000000..015027d2bb7ccf87046db070486324046ae75d8a
--- /dev/null
+++ b/utils/haddock/html-test/src/GADTRecords.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE GADTs #-}
+module GADTRecords (H1(..)) where
+
+-- | h1
+data H1 a b where
+  C1 :: H1 a b
+  C2 :: Ord a => [a] -> H1 a a
+  C3 :: { field :: Int -- ^ hello docs
+        } -> H1 Int Int
+  C4 :: { field2 :: a -- ^ hello2 docs
+        } -> H1 Int a
diff --git a/utils/haddock/html-test/src/GadtConstructorArgs.hs b/utils/haddock/html-test/src/GadtConstructorArgs.hs
new file mode 100644
index 0000000000000000000000000000000000000000..50ff93cc22939816b449412a2eacb8bab27c4f19
--- /dev/null
+++ b/utils/haddock/html-test/src/GadtConstructorArgs.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE GADTs #-}
+
+module GadtConstructorArgs (Boo(..)) where
+
+data Boo where
+  Fot :: { x :: Int  -- ^ an 'x'
+         , y :: Int  -- ^ a 'y'
+         } -> Boo
+
+  -- | Record GADT with docs
+  Fob :: { w :: Int  -- ^ a 'w'
+         , z :: Int  -- ^ a 'z'
+         } -> Boo    -- ^ a 'Boo'
diff --git a/utils/haddock/html-test/src/Hash.hs b/utils/haddock/html-test/src/Hash.hs
new file mode 100644
index 0000000000000000000000000000000000000000..ce40fdd3fb44cf34547b25671ab27a86437a09c9
--- /dev/null
+++ b/utils/haddock/html-test/src/Hash.hs
@@ -0,0 +1,52 @@
+{-# LANGUAGE Haskell2010 #-}
+{- |
+  Implementation of fixed-size hash tables, with a type
+  class for constructing hash values for structured types.
+-}
+module Hash (
+  -- * The @HashTable@ type
+  HashTable,
+
+  -- ** Operations on @HashTable@s
+  new, insert, lookup,
+
+  -- * The @Hash@ class
+  Hash(..),
+ ) where
+
+import Data.Array
+import Prelude hiding (lookup)
+
+-- | A hash table with keys of type @key@ and values of type @val@.
+-- The type @key@ should be an instance of 'Eq'.
+data HashTable key val = HashTable Int (Array Int [(key,val)])
+
+-- | Builds a new hash table with a given size
+new :: (Eq key, Hash key) => Int -> IO (HashTable key val)
+new = undefined
+
+-- | Inserts a new element into the hash table
+insert :: (Eq key, Hash key) => key -> val -> IO ()
+insert = undefined
+
+-- | Looks up a key in the hash table, returns @'Just' val@ if the key
+-- was found, or 'Nothing' otherwise.
+lookup :: Hash key => key -> IO (Maybe val)
+lookup = undefined
+
+-- | A class of types which can be hashed.
+class Hash a where
+   -- | hashes the value of type @a@ into an 'Int'
+   hash :: a -> Int
+
+instance Hash Int where
+   hash = id
+
+instance Hash Float where
+   hash = trunc
+
+instance (Hash a, Hash b) => Hash (a,b) where
+   hash (a,b) = hash a `xor` hash b
+
+trunc = undefined
+xor = undefined
diff --git a/utils/haddock/html-test/src/Hidden.hs b/utils/haddock/html-test/src/Hidden.hs
new file mode 100644
index 0000000000000000000000000000000000000000..2b694e863ab496a3442fb0b1ed0cd759d7a108f7
--- /dev/null
+++ b/utils/haddock/html-test/src/Hidden.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# OPTIONS_HADDOCK hide #-}
+
+module Hidden where
+
+hidden :: Int -> Int
+hidden a = a
diff --git a/utils/haddock/html-test/src/HiddenInstances.hs b/utils/haddock/html-test/src/HiddenInstances.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a912409813be9d28f7cb61a2145ecccef93f5751
--- /dev/null
+++ b/utils/haddock/html-test/src/HiddenInstances.hs
@@ -0,0 +1,36 @@
+{-# LANGUAGE Haskell2010 #-}
+-- http://trac.haskell.org/haddock/ticket/37
+module HiddenInstances (VisibleClass, VisibleData) where
+
+-- | Should be visible
+class VisibleClass a
+
+-- | Should *not* be visible
+class HiddenClass a
+
+-- | Should *not* be visible
+data HiddenData = HiddenData
+
+-- | Should be visible
+data VisibleData = VisibleData
+
+-- | Should be visible
+instance VisibleClass Int
+
+-- | Should be visible
+instance VisibleClass VisibleData
+
+-- | Should be visible
+instance Num VisibleData
+
+-- | Should *not* be visible
+instance VisibleClass HiddenData
+
+-- | Should *not* be visible
+instance HiddenClass Int
+
+-- | Should *not* be visible
+instance HiddenClass VisibleData
+
+-- | Should *not* be visible
+instance HiddenClass HiddenData
diff --git a/utils/haddock/html-test/src/HiddenInstancesA.hs b/utils/haddock/html-test/src/HiddenInstancesA.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8879868c1801d7b8dfd5581f5045cbdf659f6380
--- /dev/null
+++ b/utils/haddock/html-test/src/HiddenInstancesA.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# OPTIONS_HADDOCK hide #-}
+module HiddenInstancesA where
+
+-- | Should be visible
+class Foo a
+
+-- | Should be visible
+data Bar
+
+-- | Should be visible
+instance Foo Bar
+
+-- | Should *not* be visible
+data Baz
+
+-- | Should *not* be visible
+instance Foo Baz
diff --git a/utils/haddock/html-test/src/HiddenInstancesB.hs b/utils/haddock/html-test/src/HiddenInstancesB.hs
new file mode 100644
index 0000000000000000000000000000000000000000..0def0ecce1b64cd1bd09b794c84676e223dc7e0b
--- /dev/null
+++ b/utils/haddock/html-test/src/HiddenInstancesB.hs
@@ -0,0 +1,3 @@
+{-# LANGUAGE Haskell2010 #-}
+module HiddenInstancesB (Foo, Bar) where
+import HiddenInstancesA
diff --git a/utils/haddock/html-test/src/Hyperlinks.hs b/utils/haddock/html-test/src/Hyperlinks.hs
new file mode 100644
index 0000000000000000000000000000000000000000..f64a5bb1efda09ed2fee409f81eeff4669f7a884
--- /dev/null
+++ b/utils/haddock/html-test/src/Hyperlinks.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE Haskell2010 #-}
+module Hyperlinks where
+
+-- |
+-- A plain URL: <http://example.com/>
+--
+-- A URL with a label: <http://example.com/ some link>
+foo :: Int
+foo = 23
diff --git a/utils/haddock/html-test/src/Identifiers.hs b/utils/haddock/html-test/src/Identifiers.hs
new file mode 100644
index 0000000000000000000000000000000000000000..13ee3b82b4ab6e05c44266830da222caf602c419
--- /dev/null
+++ b/utils/haddock/html-test/src/Identifiers.hs
@@ -0,0 +1,36 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeOperators #-}
+module Identifiers where
+
+import Data.List (elem, (++))
+
+data Id = Id
+data a :* b = a :* b
+
+{-|
+
+  * Unadorned:
+
+        - Unqualified: '++', 'elem'
+        - Qualified: 'Data.List.++', 'Data.Lis.elem'
+        - Namespaced: v'++', t'++', v'elem', t'elem', v'Id', t'Id', v':*', t':*'
+
+  * Parenthesized:
+
+        - Unqualified: @'(++)' [1,2,3] [4,5,6]@
+        - Qualified: @'(Data.List.++)' [1,2,3] [4,5,6]@
+        - Namespaced: v'(++)', t'++', v'(:*)', t'(:*)'
+
+  * Backticked:
+
+        - Unqualified: @1 '`elem`' [-3..3]@
+        - Qualified: @1 '`Data.List.elem`' [-3..3]@
+        - Namespaced: v'`elem`', t'`elem`', v'`Id`', t'`Id`'
+
+  * Edge cases:
+
+        - Tuples: '()', '(,,,)'
+
+-}
+foo :: ()
+foo = ()
diff --git a/utils/haddock/html-test/src/IgnoreExports.hs b/utils/haddock/html-test/src/IgnoreExports.hs
new file mode 100644
index 0000000000000000000000000000000000000000..2016d3d5b59aa91bcc7a982072dfe0d66f94afff
--- /dev/null
+++ b/utils/haddock/html-test/src/IgnoreExports.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# OPTIONS_HADDOCK ignore-exports #-}
+module IgnoreExports (Foo, foo) where
+
+-- | documentation for Foo
+data Foo = Bar -- ^ Documentation for Bar
+
+-- | documentation for foo
+foo :: Int
+foo = 23
+
+-- | documentation for bar
+bar :: Int
+bar = 23
diff --git a/utils/haddock/html-test/src/ImplicitParams.hs b/utils/haddock/html-test/src/ImplicitParams.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8635b2a4e892f470418194ad6262df5c71e1649d
--- /dev/null
+++ b/utils/haddock/html-test/src/ImplicitParams.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE ImplicitParams, RankNTypes #-}
+module ImplicitParams where
+
+data X = X
+
+c :: (?x :: X) => X
+c = ?x
+
+d :: (?x :: X, ?y :: X) => (X, X)
+d = (?x, ?y)
+
+f :: ((?x :: X) => a) -> a
+f a = let ?x = X in a
diff --git a/utils/haddock/html-test/src/Instances.hs b/utils/haddock/html-test/src/Instances.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e9537a920050bb0e3f39467a511667600108ab3f
--- /dev/null
+++ b/utils/haddock/html-test/src/Instances.hs
@@ -0,0 +1,100 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE ImpredicativeTypes #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeOperators #-}
+
+
+module Instances where
+
+
+newtype (<~~) a b = Xyzzy (b -> (a, a))
+
+
+class Foo f where
+
+    foo :: f Int -> a -> f a
+    foo' :: f (f a) -> Int -> f (f Int)
+
+    foo = undefined
+    foo' = undefined
+
+instance Foo Maybe
+instance Foo []
+instance (Eq a, Foo f) => Foo ((,) (f a))
+instance Foo (Either a)
+instance Foo ((,,) a a)
+instance Foo ((->) a)
+instance Foo ((<~~) a)
+
+
+class Foo f => Bar f a where
+
+    bar :: f a -> f Bool -> a
+    bar' :: f (f a) -> f (f (f b))
+    bar0, bar1 :: (f a, f a) -> (f b, f c)
+
+    bar = undefined
+    bar' = undefined
+    bar0 = undefined
+    bar1 = undefined
+
+
+instance Bar Maybe Bool
+instance Bar Maybe [a]
+instance Bar [] (a, a)
+instance Foo f => Bar (Either a) (f a)
+instance Foo ((,,) a b) => Bar ((,,) a b) (a, b, a)
+
+
+class Baz a where
+
+    baz :: a -> (forall a. a -> a) -> (b, forall c. c -> a) -> (b, c)
+    baz' :: b -> (forall b. b -> a) -> (forall b. b -> a) -> [(b, a)]
+    baz'' :: b -> (forall b. (forall b. b -> a) -> c) -> (forall c. c -> b)
+
+    baz = undefined
+    baz' = undefined
+    baz'' = undefined
+
+
+instance Baz (a -> b)
+instance Baz [c]
+instance Baz (a, b, c)
+instance Baz (a, [b], b, a)
+
+
+data Quux a b c = Qx a | Qux a b | Quux a b c
+
+instance Foo (Quux a b)
+instance Bar (Quux a c) (Quux a b c)
+instance Baz (Quux a b c)
+
+
+class Norf a b where
+
+    type Plugh a c b
+    data Thud a c
+
+    norf :: Plugh a c b -> a -> (a -> c) -> b
+
+    norf = undefined
+
+
+instance Norf Int Bool where
+
+    type Plugh Int [a] Bool = a
+    type Plugh Int (a, b) Bool = (a, [b])
+
+    data Thud Int (Quux a [a] c) = Thuud a | Thuuud Int Int
+    data Thud Int [a] = Thuuuud Bool
+
+
+instance Norf [a] [b] where
+
+    type Plugh [a] (Maybe a) [b] = a
+    type Plugh [a] [b] [b] = Quux a b (a, b)
+
+    data Thud [a] (a, a, a) = Thd a
diff --git a/utils/haddock/html-test/src/LinearTypes.hs b/utils/haddock/html-test/src/LinearTypes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c4f9c84fd6347e48de3eff12588ce2886166d5cb
--- /dev/null
+++ b/utils/haddock/html-test/src/LinearTypes.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE LinearTypes #-}
+module LinearTypes where
+
+-- | Does something unrestricted.
+unrestricted :: a -> b
+unrestricted = undefined
+
+-- | Does something linear.
+linear :: a %1 -> b
+linear = linear
+
+-- | Does something polymorphic.
+poly :: a %m -> b
+poly = poly
diff --git a/utils/haddock/html-test/src/Math.hs b/utils/haddock/html-test/src/Math.hs
new file mode 100644
index 0000000000000000000000000000000000000000..375dbc2da09ebe5a9bc7ab42c65e57bc4bff069c
--- /dev/null
+++ b/utils/haddock/html-test/src/Math.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | Math (display) for 'normalDensity'
+--
+-- \[
+-- \int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}
+-- \]
+--
+-- \(\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\)
+
+module Math where
+
+-- | Math (inline) for 'normalDensity'
+-- \(\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\)
+-- \[\int_{-\infty}^{\infty} e^{-x^2/2} = \sqrt{2\pi}\]
+f = 5
diff --git a/utils/haddock/html-test/src/Minimal.hs b/utils/haddock/html-test/src/Minimal.hs
new file mode 100644
index 0000000000000000000000000000000000000000..ec275aeca1cc6611ceb3f2b90575271df226305d
--- /dev/null
+++ b/utils/haddock/html-test/src/Minimal.hs
@@ -0,0 +1,54 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | 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 :: a
+  bar :: a
+  bat :: a
+
+  -- | .. or just this
+  fooBarBat :: (a,a,a)
+
+  {-# MINIMAL (foo, bar) | (bar, bat) | (foo, bat) | fooBarBat #-}
+
+class Weird a where
+  a :: a
+  b :: a
+  c :: a
+  d :: a
+  e :: a
+  f :: a
+  g :: a
+
+  {-# MINIMAL ((a, b), c | (d | (e, (f | g)))) #-}
+
+class NoMins a where
+  x :: a
+  y :: a
+  z :: a
+
+  -- | Has a default implementation!
+  z = x
+
+class FullMin a where
+  aaa :: a
+  bbb :: a
+
+class PartialMin a where
+  ccc :: a
+  ddd :: a
+
+class EmptyMin a where
+  eee :: a
+  fff :: a
+  eee = fff
+  fff = undefined
diff --git a/utils/haddock/html-test/src/ModuleWithWarning.hs b/utils/haddock/html-test/src/ModuleWithWarning.hs
new file mode 100644
index 0000000000000000000000000000000000000000..710589bfcabcb2b1821a3520948cc062aa3636e2
--- /dev/null
+++ b/utils/haddock/html-test/src/ModuleWithWarning.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | Documentation for "ModuleWithWarning".
+module ModuleWithWarning {-# WARNING "This is an unstable interface.  Prefer functions from \"Prelude\" instead!" #-} where
+
+foo :: Int
+foo = 23
diff --git a/utils/haddock/html-test/src/NamedDoc.hs b/utils/haddock/html-test/src/NamedDoc.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8ac40921dca3c6715863a9b7264ce4f30e3f6034
--- /dev/null
+++ b/utils/haddock/html-test/src/NamedDoc.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE Haskell2010 #-}
+module NamedDoc where
+
+-- $foo bar
+
diff --git a/utils/haddock/html-test/src/NamespacedIdentifiers.hs b/utils/haddock/html-test/src/NamespacedIdentifiers.hs
new file mode 100644
index 0000000000000000000000000000000000000000..38fb710138044bbfb03788a91e844d5a90715f1c
--- /dev/null
+++ b/utils/haddock/html-test/src/NamespacedIdentifiers.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+module NamespacedIdentifiers where
+
+-- | A link to:
+--
+--   * the type t'Bar'
+--   * the constructor v'Bar'
+--   * the unimported but qualified type t'A.A'
+--   * the unimported but qualified value v'A.A'
+--
+data Foo = Bar
+
+-- | A link to the value v'Foo' (which shouldn't exist).
+data Bar
diff --git a/utils/haddock/html-test/src/Nesting.hs b/utils/haddock/html-test/src/Nesting.hs
new file mode 100644
index 0000000000000000000000000000000000000000..fa45e11b5f8cdcf2103b478b842d38283f8ff224
--- /dev/null
+++ b/utils/haddock/html-test/src/Nesting.hs
@@ -0,0 +1,137 @@
+{-# LANGUAGE Haskell2010 #-}
+module Nesting where
+
+{-|
+* We can
+
+    * easily go back
+
+        1. some indentation
+
+    * levels
+
+1. @back at the top@
+
+-}
+d :: t
+d = undefined
+
+
+{-|
+* Beginning of list
+
+    * second list
+
+        * Some indented list but
+the presence of this text pushes it out of nesting back to the top.
+-}
+e :: t
+e = undefined
+
+
+{-|
+* Beginning of list
+
+    @
+    nested code
+        we preserve the space correctly
+    @
+-}
+f :: t
+f = undefined
+
+
+{-|
+* Beginning of list
+
+    * Nested list
+-}
+g :: t
+g = undefined
+
+{-|
+* Beginning of list
+
+    > nested
+    > bird
+    > tracks
+-}
+h :: t
+h = undefined
+
+{-|
+* Beginning of list
+This belongs to the list above!
+
+    > nested
+    > bird
+    > tracks
+    >
+    > another line
+    >   with indentation
+
+    >nested bird tracks
+    >  without leading space
+
+    * Next list
+    More of the indented list.
+
+        * Deeper
+
+            * Deeper
+
+                    * Even deeper!
+                    * No newline separation even in indented lists.
+-}
+i :: t
+i = undefined
+
+
+
+{-|
+[All this] Works for
+definition lists too.
+
+    > nested
+    > bird
+    > tracks
+
+    * Next list
+    with more of the indented list content.
+
+        Even more content on a new line.
+
+        1. Different type of list
+
+            (2) Deeper
+
+            >>> Here's an example in a list
+            example result
+
+                    [b] Even deeper!
+                    [c] No newline separation even in indented lists.
+                    We can have any paragraph level element that we normally
+                    can, like headers
+
+                    === Level 3 header
+                    with some content…
+
+                    * and even more lists inside
+-}
+j :: t
+j = undefined
+
+{-|
+      - list may start at arbitrary depth
+
+      - and consecutive items at that depth
+      belong to the same list
+
+      - of course we can still
+
+          * nest items like we are used to
+
+      - and then get back to initial list
+-}
+k :: t
+k = undefined
diff --git a/utils/haddock/html-test/src/NoLayout.hs b/utils/haddock/html-test/src/NoLayout.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e07470a3228f16afd8808efb6606fa5d300836a9
--- /dev/null
+++ b/utils/haddock/html-test/src/NoLayout.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE Haskell2010 #-}
+
+-- Haddock comments are parsed as separate declarations so we
+-- need to insert a ';' when using them with explicit layout.
+-- This should probably be changed.
+
+module NoLayout where {
+  -- | the function 'g'
+  ;
+  g :: Int;
+  g = undefined
+ }
+
diff --git a/utils/haddock/html-test/src/NonGreedy.hs b/utils/haddock/html-test/src/NonGreedy.hs
new file mode 100644
index 0000000000000000000000000000000000000000..b89b0723d6de916ea53bc34744ce3905d5d1fe9d
--- /dev/null
+++ b/utils/haddock/html-test/src/NonGreedy.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE Haskell2010 #-}
+module NonGreedy where
+
+-- | <url1> <url2>
+f :: a
+f = undefined
diff --git a/utils/haddock/html-test/src/Operators.hs b/utils/haddock/html-test/src/Operators.hs
new file mode 100644
index 0000000000000000000000000000000000000000..49682bfc8042887905195b8592c6d40a302cc536
--- /dev/null
+++ b/utils/haddock/html-test/src/Operators.hs
@@ -0,0 +1,71 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE PatternSynonyms, TypeOperators, TypeFamilies, GADTs #-}
+{-# LANGUAGE FunctionalDependencies #-}
+
+-- | Test operators with or without fixity declarations
+module Operators where
+
+import Data.Kind (Type)
+
+-- | Operator with no fixity
+(+-) :: a -> a -> a
+a +- _ = a
+
+-- | Operator with infixr 7
+(*/) :: a -> a -> a
+_ */ b = b
+infixr 7 */
+
+-- | Named function with infixl 3
+foo :: a -> a -> a
+foo a _ = a
+infixl 3 `foo`
+
+-- | Data type with operator constructors
+data Foo
+  = Foo `Bar` Foo -- ^ Has infixl 3
+  | Foo :- Foo  -- ^ Has infixr 5
+infixr 5 :-
+infixl 3 `Bar`
+
+-- | Pattern synonym, infixr 3
+pattern (:+) a b <- [a,b]
+infixr 3 :+
+
+-- | Type name, infixl 6 and GADT constructor
+data (a <-> b) where
+  (:<->) :: a -> b -> a <-> b
+infixl 6 <->
+infixr 6 :<->
+
+-- | Type family with fixity
+type family a ++ b
+infix 3 ++
+
+-- | Data family with fixity
+data family a ** b
+infix 9 **
+
+-- | Class with fixity, including associated types
+class a ><> b | a -> b where
+  -- Dec 2015: Added @a -> b@ functional dependency to clean up ambiguity
+  -- See GHC #11264
+  type a <>< b :: Type
+  data a ><< b
+  (>><), (<<>) :: a -> b -> ()
+
+  -- | Multiple fixities
+  (**>), (**<), (>**), (<**) :: a -> a -> ()
+
+infixr 1 ><>
+infixl 2 <><
+infixl 3 ><<
+infixr 4 >><
+infixl 5 <<>
+
+infixr 8 **>, >**
+infixl 8 **<, <**
+
+-- | Type synonym with fixity
+type (a >-< b) = a <-> b
+infixl 6 >-<
diff --git a/utils/haddock/html-test/src/OrphanInstances.hs b/utils/haddock/html-test/src/OrphanInstances.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e7a24c45a9b6bb11fca57ceab3ffdc98248c88df
--- /dev/null
+++ b/utils/haddock/html-test/src/OrphanInstances.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE Haskell2010 #-}
+module OrphanInstances where
+
+import OrphanInstancesType
+import OrphanInstancesClass
+
+-- | This is an orphan instance.
+instance AClass AType where
+  aClass (AType n) = n
diff --git a/utils/haddock/html-test/src/OrphanInstancesClass.hs b/utils/haddock/html-test/src/OrphanInstancesClass.hs
new file mode 100644
index 0000000000000000000000000000000000000000..d5cbf708e4d4a2222c63d933ecfd39225b8aa0f9
--- /dev/null
+++ b/utils/haddock/html-test/src/OrphanInstancesClass.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE Haskell2010 #-}
+module OrphanInstancesClass (AClass(..)) where
+
+class AClass a where
+  aClass :: a -> Int
diff --git a/utils/haddock/html-test/src/OrphanInstancesType.hs b/utils/haddock/html-test/src/OrphanInstancesType.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8a48b93ea945c00c9adca79baaf0ac8595499aec
--- /dev/null
+++ b/utils/haddock/html-test/src/OrphanInstancesType.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module OrphanInstancesType (AType(..)) where
+
+data AType = AType Int
diff --git a/utils/haddock/html-test/src/PR643.hs b/utils/haddock/html-test/src/PR643.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a6ad81eed8b0dc56710e4e4391d7e4a8bf13e20c
--- /dev/null
+++ b/utils/haddock/html-test/src/PR643.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module PR643 (test) where
+
+import PR643_1
diff --git a/utils/haddock/html-test/src/PR643_1.hs b/utils/haddock/html-test/src/PR643_1.hs
new file mode 100644
index 0000000000000000000000000000000000000000..67dabee3c4a8aa948e5af95e97a39a661dce65d2
--- /dev/null
+++ b/utils/haddock/html-test/src/PR643_1.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Haskell2010 #-}
+module PR643_1 where
+
+infixr 5 `test`
+
+-- | Some big documentation
+test :: ()
+test = ()
diff --git a/utils/haddock/html-test/src/PatternSyns.hs b/utils/haddock/html-test/src/PatternSyns.hs
new file mode 100644
index 0000000000000000000000000000000000000000..5569e1ce8a828549d18abe769278b603225f3238
--- /dev/null
+++ b/utils/haddock/html-test/src/PatternSyns.hs
@@ -0,0 +1,36 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE ExistentialQuantification, PatternSynonyms, PolyKinds, TypeOperators #-}
+
+-- | Testing some pattern synonyms
+module PatternSyns where
+
+import Data.Kind (Type)
+
+-- | FooType doc
+data FooType x = FooCtor x
+
+-- | Pattern synonym for 'Foo' x
+pattern Foo x = FooCtor x
+
+-- | Pattern synonym for 'Bar' x
+pattern Bar x = FooCtor (Foo x)
+
+-- | Pattern synonym for (':<->')
+pattern x :<-> y = (Foo x, Bar y)
+
+-- | BlubType is existentially quantified
+data BlubType = forall x. Show x => BlubCtor x
+
+-- | Pattern synonym for 'Blub' x
+pattern Blub x = BlubCtor x
+
+-- | Doc for ('><')
+data (a :: Type) >< b = Empty
+
+-- | Pattern for 'Empty'
+pattern E = Empty
+
+-- | Earlier ghc versions didn't allow explicit signatures
+-- on pattern synonyms.
+pattern PatWithExplicitSig :: Eq somex => somex -> FooType somex
+pattern PatWithExplicitSig x = FooCtor x
diff --git a/utils/haddock/html-test/src/PromotedTypes.hs b/utils/haddock/html-test/src/PromotedTypes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..9b66a523d9077ca2eb9c5ee254e9d4e23325b263
--- /dev/null
+++ b/utils/haddock/html-test/src/PromotedTypes.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE KindSignatures #-}
+{-# LANGUAGE TypeOperators #-}
+
+
+module PromotedTypes where
+
+import Data.Kind (Type)
+
+
+data RevList a = RNil | RevList a :> a
+
+
+data Pattern :: [Type] -> Type where
+  Nil :: Pattern '[]
+  Cons :: Maybe h -> Pattern t -> Pattern (h ': t)
+
+
+-- Unlike (:), (:>) does not have to be quoted on type level.
+data RevPattern :: RevList Type -> Type where
+    RevNil :: RevPattern RNil
+    RevCons :: Maybe h -> RevPattern t -> RevPattern (t :> h)
+
+
+data Tuple :: (Type, Type) -> Type where
+    Tuple :: a -> b -> Tuple '(a, b)
diff --git a/utils/haddock/html-test/src/Properties.hs b/utils/haddock/html-test/src/Properties.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8b1409f3a7e309203d782f0b31612f561a55a0b9
--- /dev/null
+++ b/utils/haddock/html-test/src/Properties.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+module Properties where
+
+-- | Fibonacci number of given 'Integer'.
+--
+-- prop> fib n <= fib (n + 1)
+fib :: Integer -> Integer
+fib 0 = 0
+fib 1 = 1
+fib n = fib (n - 1) + fib (n - 2)
diff --git a/utils/haddock/html-test/src/PruneWithWarning.hs b/utils/haddock/html-test/src/PruneWithWarning.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c2f746f00acdc243145b07dbe426a08d7978f63a
--- /dev/null
+++ b/utils/haddock/html-test/src/PruneWithWarning.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# OPTIONS_HADDOCK prune #-}
+-- |
+-- What is tested here:
+--
+-- * If a binding has a deprecation message but no documentation, it is pruned
+--   when @OPTIONS_HADDOCK prune@ is used.
+--
+module PruneWithWarning (foo, bar) where
+
+foo :: Int
+foo = 23
+{-# DEPRECATED foo "use bar instead" #-}
+
+bar :: Int
+bar = 42
diff --git a/utils/haddock/html-test/src/QuantifiedConstraints.hs b/utils/haddock/html-test/src/QuantifiedConstraints.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4f96b322a6ee8751529f97a5a8223cb70d2c6e90
--- /dev/null
+++ b/utils/haddock/html-test/src/QuantifiedConstraints.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE QuantifiedConstraints #-}
+module QuantifiedConstraints where
+
+class Foo a where
+  fooed :: a
+
+needsParensAroundContext :: (forall x. Foo (f x)) => f Int
+needsParensAroundContext = fooed
+
+needsNoParensAroundContext :: Foo (f Int) => f Int
+needsNoParensAroundContext = fooed
diff --git a/utils/haddock/html-test/src/QuasiExpr.hs b/utils/haddock/html-test/src/QuasiExpr.hs
new file mode 100644
index 0000000000000000000000000000000000000000..d81fcf8b05585076b2cfc6bf266f976bf522b579
--- /dev/null
+++ b/utils/haddock/html-test/src/QuasiExpr.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+-- Used by QuasiQuote. Example taken from the GHC documentation.
+module QuasiExpr where
+
+import Language.Haskell.TH
+import Language.Haskell.TH.Quote
+
+data Expr  =  IntExpr Integer
+           |  AntiIntExpr String
+           |  BinopExpr BinOp Expr Expr
+           |  AntiExpr String
+    deriving Show
+
+data BinOp  =  AddOp
+            |  SubOp
+            |  MulOp
+            |  DivOp
+    deriving Show
+
+eval :: Expr -> Integer
+eval (IntExpr n)        = n
+eval (BinopExpr op x y) = (opToFun op) (eval x) (eval y)
+  where
+    opToFun AddOp = (+)
+    opToFun SubOp = (-)
+    opToFun MulOp = (*)
+    opToFun DivOp = div
+
+expr = QuasiQuoter parseExprExp undefined undefined undefined
+
+-- cheating...
+parseExprExp :: String -> Q Exp
+parseExprExp _ = [| BinopExpr AddOp (IntExpr 1) (IntExpr 2) |]
diff --git a/utils/haddock/html-test/src/QuasiQuote.hs b/utils/haddock/html-test/src/QuasiQuote.hs
new file mode 100644
index 0000000000000000000000000000000000000000..6cc928cd01f7dff01f09395be691c71b0e4b80e9
--- /dev/null
+++ b/utils/haddock/html-test/src/QuasiQuote.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE QuasiQuotes #-}
+
+-- example taken from the GHC documentation
+module QuasiQuote where
+
+import QuasiExpr
+
+val :: Integer
+val = eval [expr|1 + 2|]
diff --git a/utils/haddock/html-test/src/SectionLabels.hs b/utils/haddock/html-test/src/SectionLabels.hs
new file mode 100644
index 0000000000000000000000000000000000000000..0017bd72353ef367b98e06b0cf840fc80a11caa6
--- /dev/null
+++ b/utils/haddock/html-test/src/SectionLabels.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE Haskell2010 #-}
+module SectionLabels
+  (
+    -- * Section heading#custom#
+    n
+  ) where
+
+n :: Int
+n = 3
diff --git a/utils/haddock/html-test/src/SpuriousSuperclassConstraints.hs b/utils/haddock/html-test/src/SpuriousSuperclassConstraints.hs
new file mode 100644
index 0000000000000000000000000000000000000000..968f07945405d770714c9eb550c79943fa87517b
--- /dev/null
+++ b/utils/haddock/html-test/src/SpuriousSuperclassConstraints.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE EmptyDataDecls, KindSignatures #-}
+-- |
+-- What is tested here:
+--
+-- Due to a change in GHC 7.6.1 we had a bug that superclass contraints were
+-- included in the instances list.  Edward K. repported it here:
+--
+--   <http://www.haskell.org/pipermail/haskell-cafe/2012-September/103600.html>
+--
+-- And here is the corresponding thread on glasgow-haskell-users:
+--
+--   <http://www.haskell.org/pipermail/glasgow-haskell-users/2012-September/022914.html>
+--
+-- It has been fixed in:
+--
+-- > 6ccf78e15a525282fef61bc4f58a279aa9c21771
+-- > Fix spurious superclass constraints bug.
+--
+module SpuriousSuperclassConstraints where
+
+import Control.Applicative
+import Data.Kind (Type)
+
+data SomeType (f :: Type -> Type) a
+
+instance Functor (SomeType f) where
+  fmap = undefined
+
+instance Applicative f => Applicative (SomeType f) where
+  pure   = undefined
+  (<*>)  = undefined
diff --git a/utils/haddock/html-test/src/T23616.hs b/utils/haddock/html-test/src/T23616.hs
new file mode 100644
index 0000000000000000000000000000000000000000..3f0396f4969eeb6313ab726e9f420d1f9c41e223
--- /dev/null
+++ b/utils/haddock/html-test/src/T23616.hs
@@ -0,0 +1,3 @@
+module T23616 (null) where
+
+import Data.Foldable
diff --git a/utils/haddock/html-test/src/T24294.hs b/utils/haddock/html-test/src/T24294.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c529601900a8ba2cee3534530abcb3eed78b41fe
--- /dev/null
+++ b/utils/haddock/html-test/src/T24294.hs
@@ -0,0 +1,6 @@
+module T24294 where
+
+import qualified Data.List
+
+-- | 'unfoldr' needs to link to local definition and not to 'Data.List.unfoldr'
+unfoldr = undefined
diff --git a/utils/haddock/html-test/src/TH.hs b/utils/haddock/html-test/src/TH.hs
new file mode 100644
index 0000000000000000000000000000000000000000..2692ae427606fa5338c27792fc972958057a2816
--- /dev/null
+++ b/utils/haddock/html-test/src/TH.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+module TH where
+
+import Language.Haskell.TH
+
+decl :: Q [Dec]
+decl = [d| f x = x|]
diff --git a/utils/haddock/html-test/src/TH2.hs b/utils/haddock/html-test/src/TH2.hs
new file mode 100644
index 0000000000000000000000000000000000000000..f878b1e0162f29f7b03e961835a7c607fbbc508c
--- /dev/null
+++ b/utils/haddock/html-test/src/TH2.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+module TH2 where
+
+import TH
+
+$( decl )
diff --git a/utils/haddock/html-test/src/Table.hs b/utils/haddock/html-test/src/Table.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4ffbc9b350d5feef38f8da4b6437e0cc039a10b7
--- /dev/null
+++ b/utils/haddock/html-test/src/Table.hs
@@ -0,0 +1,48 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | This tests the table markup
+module Table
+  ( tableWithHeader
+  , tableWithoutHeader
+  , fancyTable
+  ) where
+
+-- | Table with header.
+--
+-- +------+--------------+------------------------------------------+
+-- | code | message      | description                              |
+-- +======+==============+==========================================+
+-- | 200  |   @OK@       | operation successful                     |
+-- +------+--------------+------------------------------------------+
+-- | 204  | @No Content@ | operation successful, no body returned   |
+-- +------+--------------+------------------------------------------+
+tableWithHeader :: a -> a
+tableWithHeader a = a
+
+-- | Table without header.
+--
+-- +------+--------------+------------------------------------------+
+-- | 200  |   @OK@       | operation successful                     |
+-- +------+--------------+------------------------------------------+
+-- | 204  | @No Content@ | operation successful, no body returned   |
+-- +------+--------------+------------------------------------------+
+-- | 404  | @Not Found@  | resource not found                       |
+-- +------+--------------+------------------------------------------+
+tableWithoutHeader :: a -> a
+tableWithoutHeader a = a
+
+-- | Fancy table.
+--
+-- +------------------------+------------+----------+----------+
+-- | Header row, column 1   | Header 2   | Header 3 | Header 4 |
+-- | (header rows optional) |            |          |          |
+-- +========================+============+==========+==========+
+-- | body row 1, column 1   | column 2   | column 3 | column 4 |
+-- +------------------------+------------+----------+----------+
+-- | 'tableWithHeader'      | Cells may span columns.          |
+-- +------------------------+------------+---------------------+
+-- | body row 3             | Cells may  | \[                  |
+-- +------------------------+ span rows. | f(n) = \sum_{i=1}   |
+-- | body row 4             |            | \]                  |
+-- +------------------------+------------+---------------------+
+fancyTable :: a -> a
+fancyTable x = x
diff --git a/utils/haddock/html-test/src/Test.hs b/utils/haddock/html-test/src/Test.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a809f337af3f4e9f293b0859f2ac8c2f0119d657
--- /dev/null
+++ b/utils/haddock/html-test/src/Test.hs
@@ -0,0 +1,424 @@
+{-# LANGUAGE Haskell2010 #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Test
+-- Copyright   :  (c) Simon Marlow 2002
+-- License     :  BSD-style
+--
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-- This module illustrates & tests most of the features of Haddock.
+-- Testing references from the description: 'T', 'f', 'g', 'Visible.visible'.
+--
+-----------------------------------------------------------------------------
+
+-- This is plain comment, ignored by Haddock.
+{-# LANGUAGE Rank2Types, GADTs #-}
+module Test (
+
+	-- Section headings are introduced with '-- *':
+	-- * Type declarations
+
+	-- Subsection headings are introduced with '-- **' and so on.
+	-- ** Data types
+	T(..), T2, T3(..), T4(..), T5(..), T6(..),
+	N1(..), N2(..), N3(..), N4, N5(..), N6(..), N7(..),
+
+	-- ** Records
+	R(..), R1(..),
+
+	-- | test that we can export record selectors on their own:
+	p, q, u,
+
+	-- * Class declarations
+	C(a,b), D(..), E, F(..),
+
+	-- | Test that we can export a class method on its own:
+	a,
+
+	-- * Function types
+	f, g,
+
+	-- * Auxiliary stuff
+
+	-- $aux1
+
+	-- $aux2
+
+	-- $aux3
+
+	-- $aux4
+
+	-- $aux5
+
+	-- $aux6
+
+	-- $aux7
+
+	-- $aux8
+
+	-- $aux9
+
+	-- $aux10
+
+	-- $aux11
+
+	-- $aux12
+
+	-- | This is some inline documentation in the export list
+	--
+	-- > a code block using bird-tracks
+	-- > each line must begin with > (which isn't significant unless it
+	-- > is at the beginning of the line).
+
+	-- * A hidden module
+	module Hidden,
+
+	-- * A visible module
+	module Visible,
+
+	{-| nested-style doc comments -}
+
+	-- * Existential \/ Universal types
+	Ex(..),
+
+	-- * Type signatures with argument docs
+	k, l, m, o,
+
+	-- * A section
+	-- and without an intervening comma:
+	-- ** A subsection
+
+{-|
+ > a literal line
+
+ $ a non /literal/ line $
+-}
+
+	f',
+
+  withType, withoutType
+   ) where
+
+import Hidden
+import Visible
+import Data.Maybe
+
+bla = Nothing
+
+-- | This comment applies to the /following/ declaration
+-- and it continues until the next non-comment line
+data T a b
+ = A Int (Maybe Float) -- ^ This comment describes the 'A' constructor
+ | -- | This comment describes the 'B' constructor
+   B (T a b, T Int Float) -- ^
+
+-- | An abstract data declaration
+data T2 a b = T2 a b
+
+-- | A data declaration with no documentation annotations on the constructors
+data T3 a b = A1 a | B1 b
+
+-- A data declaration with no documentation annotations at all
+data T4 a b = A2 a | B2 b
+
+-- A data declaration documentation on the constructors only
+data T5 a b
+  = A3 a -- ^ documents 'A3'
+  | B3 b -- ^ documents 'B3'
+
+-- | Testing alternative comment styles
+data T6
+  -- | This is the doc for 'A4'
+  = A4
+  | B4
+  | -- ^ This is the doc for 'B4'
+
+    -- | This is the doc for 'C4'
+    C4
+
+-- | A newtype
+newtype N1 a = N1 a
+
+-- | A newtype with a fieldname
+newtype N2 a b = N2 {n :: a b}
+
+-- | A newtype with a fieldname, documentation on the field
+newtype N3 a b = N3 {n3 :: a b -- ^ this is the 'n3' field
+		    }
+
+-- | An abstract newtype - we show this one as data rather than newtype because
+-- the difference isn\'t visible to the programmer for an abstract type.
+newtype N4 a b = N4 a
+
+newtype N5 a b = N5 {n5 :: a b -- ^ no docs on the datatype or the constructor
+		    }
+
+newtype N6 a b = N6 {n6 :: a b
+		    }
+		 -- ^ docs on the constructor only
+
+-- | docs on the newtype and the constructor
+newtype N7 a b = N7 {n7 :: a b
+		    }
+		-- ^ The 'N7' constructor
+
+
+class (D a) => C a  where
+   -- |this is a description of the 'a' method
+   a :: IO a
+   b :: [a]
+   -- ^ this is a description of the 'b' method
+   c :: a -- c is hidden in the export list
+   c = undefined
+
+-- ^ This comment applies to the /previous/ declaration (the 'C' class)
+
+class D a where
+   d :: T a b
+   e :: (a,a)
+-- ^ This is a class declaration with no separate docs for the methods
+
+instance D Int where
+  d = undefined
+  e = undefined
+
+-- instance with a qualified class name
+instance Test.D Float where
+  d = undefined
+  e = undefined
+
+class E a where
+  ee :: a
+-- ^ This is a class declaration with no methods (or no methods exported)
+
+-- This is a class declaration with no documentation at all
+class F a where
+  ff :: a
+
+-- | This is the documentation for the 'R' record, which has four fields,
+-- 'p', 'q', 'r', and 's'.
+data R =
+  -- | This is the 'C1' record constructor, with the following fields:
+  C1 { p :: Int -- ^ This comment applies to the 'p' field
+     , q :: forall a . a->a  -- ^ This comment applies to the 'q' field
+     , -- | This comment applies to both 'r' and 's'
+       r,s :: Int
+     }
+  | C2 { t :: T1 -> (T2 Int Int)-> (T3 Bool Bool) -> (T4 Float Float) -> T5 () (),
+       u,v :: Int
+     }
+  -- ^ This is the 'C2' record constructor, also with some fields:
+
+-- | Testing different record commenting styles
+data R1
+  -- | This is the 'C3' record constructor
+  = C3 {
+	-- | The 's1' record selector
+	  s1 :: Int
+	-- | The 's2' record selector
+	, s2 :: Int
+	, s3 :: Int  -- NOTE: In the original examples/Test.hs in Haddock, there is an extra "," here.
+                     -- Since GHC doesn't allow that, I have removed it in this file.
+	-- ^ The 's3' record selector
+     }
+
+-- These section headers are only used when there is no export list to
+-- give the structure of the documentation:
+
+-- * This is a section header (level 1)
+-- ** This is a section header (level 2)
+-- *** This is a section header (level 3)
+
+{-|
+In a comment string we can refer to identifiers in scope with
+single quotes like this: 'T', and we can refer to modules by
+using double quotes: "Foo".  We can add emphasis /like this/.
+
+   * This is a bulleted list
+
+   - This is the next item (different kind of bullet)
+
+   (1) This is an ordered list
+
+   2. This is the next item (different kind of bullet)
+
+   [cat] a small, furry, domesticated mammal
+
+   [pineapple] a fruit grown in the tropics
+
+@
+     This is a block of code, which can include other markup: 'R'
+     formatting
+               is
+                 significant
+@
+
+> this is another block of code
+
+We can also include URLs in documentation: <http://www.haskell.org/>.
+-}
+
+f :: C a => a -> Int
+
+-- | we can export foreign declarations too
+foreign import ccall g :: Int -> IO CInt
+
+-- | this doc string has a parse error in it: \'
+h :: Int
+h = 42
+
+
+-- $aux1 This is some documentation that is attached to a name ($aux1)
+-- rather than a source declaration.  The documentation may be
+-- referred to in the export list using its name.
+--
+-- @ code block in named doc @
+
+-- $aux2 This is some documentation that is attached to a name ($aux2)
+
+-- $aux3
+-- @ code block on its own in named doc @
+
+-- $aux4
+--
+-- @ code block on its own in named doc (after newline) @
+
+{- $aux5 a nested, named doc comment
+
+   with a paragraph,
+
+   @ and a code block @
+-}
+
+-- some tests for various arrangements of code blocks:
+
+{- $aux6
+>test
+>test1
+
+@ test2
+  test3
+@
+-}
+
+{- $aux7
+@
+test1
+test2
+@
+-}
+
+{- $aux8
+>test3
+>test4
+-}
+
+{- $aux9
+@
+test1
+test2
+@
+
+>test3
+>test4
+-}
+
+{- $aux10
+>test3
+>test4
+
+@
+test1
+test2
+@
+-}
+
+-- This one is currently wrong (Haddock 0.4).  The @...@ part is
+-- interpreted as part of the bird-tracked code block.
+{- $aux11
+aux11:
+
+>test3
+>test4
+
+@
+test1
+test2
+@
+-}
+
+-- $aux12
+-- > foo
+--
+-- > bar
+--
+
+-- | A data-type using existential\/universal types
+data Ex a
+  = forall b . C b => Ex1 b
+  | forall b . Ex2 b
+  | forall b . C a => Ex3 b -- NOTE: I have added "forall b" here make GHC accept this file
+  | Ex4 (forall a . a -> a)
+
+-- | This is a function with documentation for each argument
+k :: T () () 	  -- ^ This argument has type 'T'
+  -> (T2 Int Int) -- ^ This argument has type 'T2 Int Int'
+  -> (T3 Bool Bool -> T4 Float Float) -- ^ This argument has type @T3 Bool Bool -> T4 Float Float@
+  -> T5 () ()	  -- ^ This argument has a very long description that should
+		  -- hopefully cause some wrapping to happen when it is finally
+		  -- rendered by Haddock in the generated HTML page.
+  -> IO ()	  -- ^ This is the result type
+
+-- This function has arg docs but no docs for the function itself
+l :: (Int, Int, Float) -- ^ takes a triple
+  -> Int -- ^ returns an 'Int'
+
+-- | This function has some arg docs
+m :: R
+  -> N1 ()	-- ^ one of the arguments
+  -> IO Int	-- ^ and the return value
+
+-- | This function has some arg docs but not a return value doc
+
+-- can't use the original name ('n') with GHC
+newn :: R		-- ^ one of the arguments, an 'R'
+     -> N1 ()		-- ^ one of the arguments
+     -> IO Int
+newn = undefined
+
+
+-- | A foreign import with argument docs
+foreign import ccall unsafe
+ o :: Float  -- ^ The input float
+   -> IO Float  -- ^ The output float
+
+-- | We should be able to escape this: \#\#\#
+
+-- p :: Int
+-- can't use the above original definition with GHC
+newp :: Int
+newp = undefined
+
+-- | a function with a prime can be referred to as 'f''
+-- but f' doesn't get link'd 'f\''
+f' :: Int
+
+-- | Comment on a definition without type signature
+withoutType = undefined
+
+-- | Comment on a definition with type signature
+withType :: Int
+withType = 1
+
+-- Add some definitions here so that this file can be compiled with GHC
+
+data T1
+f = undefined
+f' = undefined
+type CInt = Int
+k = undefined
+l = undefined
+m = undefined
diff --git a/utils/haddock/html-test/src/Threaded.hs b/utils/haddock/html-test/src/Threaded.hs
new file mode 100644
index 0000000000000000000000000000000000000000..afe38c27431bb20a35552813d8d1a47c04a96c06
--- /dev/null
+++ b/utils/haddock/html-test/src/Threaded.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+-- | Ensures haddock built with @-threaded@.
+module Threaded where
+
+import Threaded_TH
+
+-- | @$(forkTH)@ fails at compile time if haddock isn't using the
+-- threaded RTS.
+f = $(forkTH)
diff --git a/utils/haddock/html-test/src/Threaded_TH.hs b/utils/haddock/html-test/src/Threaded_TH.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8179f09050bb1f992f67eafd8c99baafb1941261
--- /dev/null
+++ b/utils/haddock/html-test/src/Threaded_TH.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+-- | Imported by 'Threaded', since a TH splice can't be used in the
+-- module where it is defined.
+module Threaded_TH where
+
+import Control.Concurrent (forkOS)
+import Language.Haskell.TH.Syntax (Exp (LitE), Lit (IntegerL), Q, runIO)
+
+-- | forkOS requires the threaded RTS, so this TH fails if haddock was
+-- built without @-threaded@.
+forkTH :: Q Exp
+forkTH = do
+  _ <- runIO (forkOS (return ()))
+  return (LitE (IntegerL 0))
diff --git a/utils/haddock/html-test/src/Ticket112.hs b/utils/haddock/html-test/src/Ticket112.hs
new file mode 100644
index 0000000000000000000000000000000000000000..db7f3ed06e3c42a56488d49603d3ec24c91dbca2
--- /dev/null
+++ b/utils/haddock/html-test/src/Ticket112.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE MagicHash #-}
+
+module Ticket112 where
+
+import GHC.Prim
+
+-- | ...given a raw 'Addr#' to the string, and the length of the string.
+f :: a
+f = undefined
diff --git a/utils/haddock/html-test/src/Ticket61.hs b/utils/haddock/html-test/src/Ticket61.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c80e1c75597350f362ae3b027d71d130d4f18b6a
--- /dev/null
+++ b/utils/haddock/html-test/src/Ticket61.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module Ticket61 (module Ticket61_Hidden) where
+
+import Ticket61_Hidden
diff --git a/utils/haddock/html-test/src/Ticket61_Hidden.hs b/utils/haddock/html-test/src/Ticket61_Hidden.hs
new file mode 100644
index 0000000000000000000000000000000000000000..f3654cfcffeb4127b7ec17ef0b0825b28cb8cb93
--- /dev/null
+++ b/utils/haddock/html-test/src/Ticket61_Hidden.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# OPTIONS_HADDOCK hide #-}
+
+module Ticket61_Hidden where
+
+class C a where
+  -- | A comment about f
+  f :: a
diff --git a/utils/haddock/html-test/src/Ticket75.hs b/utils/haddock/html-test/src/Ticket75.hs
new file mode 100644
index 0000000000000000000000000000000000000000..743ffd607f4a15217601bb675630ee23cea19c52
--- /dev/null
+++ b/utils/haddock/html-test/src/Ticket75.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeOperators #-}
+module Ticket75 where
+
+data a :- b = Q
+
+-- | A reference to ':-'
+f :: Int
+f = undefined
diff --git a/utils/haddock/html-test/src/TitledPicture.hs b/utils/haddock/html-test/src/TitledPicture.hs
new file mode 100644
index 0000000000000000000000000000000000000000..69d44397c9338e529d592ff387adb1754298adea
--- /dev/null
+++ b/utils/haddock/html-test/src/TitledPicture.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Haskell2010 #-}
+module TitledPicture where
+
+-- | Picture for 'foo' without a title <<bar>>
+foo = 5
+
+-- | Picture for 'bar' with title <<un∣∁∘ δ∈>>
+bar = 6
diff --git a/utils/haddock/html-test/src/TypeFamilies.hs b/utils/haddock/html-test/src/TypeFamilies.hs
new file mode 100644
index 0000000000000000000000000000000000000000..18f161e325b4c4b6ba6969b0fb32b1207f34c4e3
--- /dev/null
+++ b/utils/haddock/html-test/src/TypeFamilies.hs
@@ -0,0 +1,95 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies, UndecidableInstances, PolyKinds, TypeOperators, DataKinds, MultiParamTypeClasses, GADTs #-}
+
+-- | Doc for: module TypeFamilies
+module TypeFamilies where
+
+import Data.Kind (Type)
+
+import qualified TypeFamilies2 as TF
+
+-- | Doc for: data X
+data X
+  = X   -- ^ Doc for: X
+  | XX  -- ^ Doc for: XX
+  | XXX -- ^ Doc for: XXX
+
+-- | Doc for: data Y
+data Y
+
+-- | Doc for: data Z
+data Z = ZA | ZB
+
+-- | Doc for: class Test a
+class Test a
+
+-- | Doc for: instance Test X
+instance Test X
+-- | Doc for: instance Test Y
+instance Test Y
+
+-- | Doc for: type family Foo a
+type family Foo a :: k
+
+-- | Doc for: type instance Foo X = Y
+type instance Foo X = Y
+-- | Doc for: type instance Foo Y = X
+type instance Foo Y = X
+
+-- | Doc for: data family Bat a
+data family Bat (a :: k) :: Type
+
+-- | Doc for: data instance Bat X
+data instance Bat X
+  = BatX X -- ^ Doc for: BatX X
+  | BatXX { aaa :: X , bbb :: Y } -- ^ Doc for: BatXX { ... }
+
+-- | Doc for: data instance Bat Y
+data instance Bat Y = BatY Y -- ^ Doc for: BatY Y
+
+-- | Doc for: data instance Bat Z
+data instance Bat (z :: Z) where
+  BatZ1 :: Z -> Bat ZA
+  BatZ2 :: { batx :: X, baty :: Y } -> Bat ZB
+
+-- | Doc for: class Assoc a
+class Assoc a where
+  -- | Doc for: data AssocD a
+  data AssocD a :: Type
+  -- | Doc for: type AssocT a
+  type AssocT a :: Type
+
+-- | Doc for: instance Assoc X
+instance Assoc X where
+  -- | Doc for: data AssocD X = AssocX
+  data AssocD X = AssocX -- ^ Doc for: AssocX
+  -- | Doc for: type AssocT X = Foo X
+  type AssocT X = Foo X
+
+-- | Doc for: instance Assoc Y
+instance Assoc Y where
+  -- | Doc for: data AssocD Y = AssocY
+  data AssocD Y = AssocY -- ^ Doc for: AssocY
+  -- | Doc for: type AssocT Y = Bat Y
+  type AssocT Y = Bat Y
+
+-- | Doc for: type family Bar b
+type family Bar b where
+  Bar X = X
+  Bar y = Y
+
+type family (<>) (a :: k) (b :: k) :: k
+
+type instance X <> a = X
+type instance Y <> a = a
+
+type instance XXX <> XX = 'X
+
+class (><) (a :: k) (b :: k)
+instance XX >< XXX
+
+-- | External instance
+
+type instance TF.Foo X = Y
+
+data instance TF.Bar Y
diff --git a/utils/haddock/html-test/src/TypeFamilies2.hs b/utils/haddock/html-test/src/TypeFamilies2.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c12113194915d948561046640023c57cc2ee3854
--- /dev/null
+++ b/utils/haddock/html-test/src/TypeFamilies2.hs
@@ -0,0 +1,40 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies #-}
+-- This tests what happens if we have unexported types
+-- in type instances. The expected behaviour is
+-- that we get the instance, Y is not linked and
+-- Haddock shows a linking warning.
+--
+-- The other families and instances that are not exported should not
+-- show up at all
+module TypeFamilies2 (W, Foo, Bar) where
+
+-- | Exported type
+data W
+
+-- | Hidden type
+data Z
+
+-- | Exported type family
+type family Foo a
+
+-- | Should be visible, but with a hidden right hand side
+type instance Foo W = Z
+
+-- | Should be hidden
+type instance Foo Z = W
+
+-- | Exported data family
+data family Bar a
+
+-- | Shown because BarX is still exported despite Z being hidden
+data instance Bar W = BarX Z
+
+-- | Should be completely invisible, including instances
+type family Invisible a
+type instance Invisible W = Z
+type instance Invisible Z = W
+
+data family Invisible2 a
+data instance Invisible2 W = Invis  Z
+data instance Invisible2 Z = Invis' W
diff --git a/utils/haddock/html-test/src/TypeFamilies3.hs b/utils/haddock/html-test/src/TypeFamilies3.hs
new file mode 100644
index 0000000000000000000000000000000000000000..80279e365876fc649e66aac34954e80a142fd17c
--- /dev/null
+++ b/utils/haddock/html-test/src/TypeFamilies3.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies #-}
+
+module TypeFamilies3 where
+
+-- | A closed type family
+type family Foo a where
+  Foo () = Int
+  Foo _ = ()
+
+-- | An open family
+type family Bar a
+
+type instance Bar Int = ()
+type instance Bar () = Int
+
+-- | A data family
+data family Baz a
+
+data instance Baz () = Baz1
+data instance Baz Int = Baz2 Bool
+newtype instance Baz Double = Baz3 Float
diff --git a/utils/haddock/html-test/src/TypeOperators.hs b/utils/haddock/html-test/src/TypeOperators.hs
new file mode 100644
index 0000000000000000000000000000000000000000..e82d065d9a82d6184409c16550661c12dd5764f3
--- /dev/null
+++ b/utils/haddock/html-test/src/TypeOperators.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeOperators, GADTs, MultiParamTypeClasses, FlexibleContexts #-}
+module TypeOperators where
+
+data a :-: b
+
+data (a :+: b) c
+
+data a `Op` b
+
+newtype (g `O` f) a = O { unO :: g (f a) }
+
+class a <=> b
+
+biO :: (g `O` f) a
+biO = undefined
+
+f :: (a ~ b) => a -> b
+f = id
+
+g :: (a ~ b, b ~ c) => a -> c
+g = id
+
+x :: ((a :-: a) <=> (a `Op` a)) => a
+x = undefined
+
+y :: (a <=> a, (a `Op` a) <=> a) => a
+y = undefined
diff --git a/utils/haddock/html-test/src/UnboxedStuff.hs b/utils/haddock/html-test/src/UnboxedStuff.hs
new file mode 100644
index 0000000000000000000000000000000000000000..dfeb7429b6ff00b92dd5e37bfaab92bc11119e19
--- /dev/null
+++ b/utils/haddock/html-test/src/UnboxedStuff.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE UnboxedSums, UnboxedTuples #-}
+module UnboxedStuff where
+
+data X
+data Y
+data Z
+
+-- * Unboxed type constructors
+
+unboxedUnit :: (# #) -> (# #)
+unboxedUnit  = undefined
+
+unboxedTuple :: (# X, Y #) -> (# X, Y, Z #)
+unboxedTuple = undefined 
+
+unboxedSum :: (# X | Y #) -> (# X | Y | Z #)
+unboxedSum = undefined 
+
diff --git a/utils/haddock/html-test/src/Unicode.hs b/utils/haddock/html-test/src/Unicode.hs
new file mode 100644
index 0000000000000000000000000000000000000000..ecd195cfa060b83c72e36cadfae8e16f5a771b37
--- /dev/null
+++ b/utils/haddock/html-test/src/Unicode.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Haskell2010 #-}
+module Unicode where
+
+-- | γλώσσα
+x :: Int
+x = 1
+
diff --git a/utils/haddock/html-test/src/Unicode2.hs b/utils/haddock/html-test/src/Unicode2.hs
new file mode 100644
index 0000000000000000000000000000000000000000..19925a4f2f93c16b4ec0ab6201c66b3f52e4a934
--- /dev/null
+++ b/utils/haddock/html-test/src/Unicode2.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE Haskell2010 #-}
+module Unicode2 where
+
+-- | All of the following work with a unicode character ü:
+--
+--   * an italicized /ü/
+--   
+--   * inline code @ü@
+--
+--   * a code block:
+--
+--   > ü
+--
+--   * a url <https://www.google.com/search?q=ü>
+-- 
+--   * a link to 'ü'
+--
+ü :: ()
+ü = ()
diff --git a/utils/haddock/html-test/src/Visible.hs b/utils/haddock/html-test/src/Visible.hs
new file mode 100644
index 0000000000000000000000000000000000000000..9440aeef09b7559eee4ef422cb377e03fd35ec68
--- /dev/null
+++ b/utils/haddock/html-test/src/Visible.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module Visible where
+visible :: Int -> Int
+visible a = a
diff --git a/utils/haddock/hypsrc-test/Main.hs b/utils/haddock/hypsrc-test/Main.hs
new file mode 100644
index 0000000000000000000000000000000000000000..bea421c73c3eb933bdb9f69304f920c2cd907b72
--- /dev/null
+++ b/utils/haddock/hypsrc-test/Main.hs
@@ -0,0 +1,59 @@
+{-# LANGUAGE CPP #-}
+
+
+import Data.Char
+import Data.List (isPrefixOf)
+import Data.Function (on)
+
+import System.Environment
+import System.FilePath
+
+import Test.Haddock
+import Test.Haddock.Xhtml
+
+
+checkConfig :: CheckConfig Xml
+checkConfig = CheckConfig
+    { ccfgRead = parseXml
+    , ccfgClean = strip
+    , ccfgDump = dumpXml
+    , ccfgEqual = (==) `on` dumpXml
+    }
+  where
+    strip _ = stripAnchors' . stripLinks' . stripIds' . stripFooter
+    
+    stripLinks' = stripLinksWhen $ \href -> "#local-" `isPrefixOf` href
+    stripAnchors' = stripAnchorsWhen $ \name -> "local-" `isPrefixOf` name
+    stripIds' = stripIdsWhen $ \name -> "local-" `isPrefixOf` name
+
+
+dirConfig :: DirConfig
+dirConfig = (defaultDirConfig $ takeDirectory __FILE__)
+    { dcfgCheckIgnore = checkIgnore
+    }
+
+
+main :: IO ()
+main = do
+    cfg <- parseArgs checkConfig dirConfig =<< getArgs
+    runAndCheck $ cfg
+        { cfgHaddockArgs = cfgHaddockArgs cfg ++
+            [ "--pretty-html"
+            , "--hyperlinked-source"
+            ]
+        }
+
+
+checkIgnore :: FilePath -> Bool
+checkIgnore file
+    | and . map ($ file) $ [isHtmlFile, isSourceFile, isModuleFile] = False
+  where
+    isHtmlFile = (== ".html") . takeExtension
+    isSourceFile = (== "src") . takeDirectory
+    isModuleFile f
+      | c : _ <- takeBaseName f
+      , isUpper c
+      = True
+      | otherwise
+      = False
+checkIgnore _ = True
diff --git a/utils/haddock/hypsrc-test/ref/src/Bug1091.html b/utils/haddock/hypsrc-test/ref/src/Bug1091.html
new file mode 100644
index 0000000000000000000000000000000000000000..3aad9cc83d0ca358f4f83a79487b01fcb8455ed3
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Bug1091.html
@@ -0,0 +1,41 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE CPP #-}</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="hs-identifier"
+      >Bug1091</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span class="hs-cpp"
+      >
+
+#include &quot;Include1For1091.h&quot;
+</span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/CPP.html b/utils/haddock/hypsrc-test/ref/src/CPP.html
new file mode 100644
index 0000000000000000000000000000000000000000..94337dce543cbd717384e25b73e22a093419c89b
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/CPP.html
@@ -0,0 +1,247 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE CPP #-}</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="CPP.html"
+	><span class="hs-identifier"
+	  >CPP</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span class="hs-cpp"
+      >
+
+#define SOMETHING1
+</span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span class="annot"
+      ><a href="CPP.html#foo"
+	><span class="hs-identifier hs-type"
+	  >foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>String</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span id="foo"
+      ><span class="annot"
+	><span class="annottext"
+	  >foo :: String
+</span
+	  ><a href="CPP.html#foo"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-comment"
+      >{-  &quot; single quotes are fine in block comments
+          {- nested block comments are fine -}
+       -}</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String
+</span
+	><span class="hs-string"
+	>&quot;foo&quot;</span
+	></span
+      ><span class="hs-cpp"
+      >
+
+#define SOMETHING2
+</span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span class="annot"
+      ><a href="CPP.html#bar"
+	><span class="hs-identifier hs-type"
+	  >bar</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>String</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span id="bar"
+      ><span class="annot"
+	><span class="annottext"
+	  >bar :: String
+</span
+	  ><a href="CPP.html#bar"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String
+</span
+	><span class="hs-string"
+	>&quot;block comment in a string is not a comment {- &quot;</span
+	></span
+      ><span class="hs-cpp"
+      >
+
+#define SOMETHING3
+</span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ><span class="hs-comment"
+      >-- &quot; single quotes are fine in line comments</span
+      ><span
+      >
+</span
+      ><span id="line-20"
+      ></span
+      ><span class="hs-comment"
+      >-- {- unclosed block comments are fine in line comments</span
+      ><span
+      >
+</span
+      ><span id="line-21"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-22"
+      ></span
+      ><span class="hs-comment"
+      >-- Multiline CPP is also fine</span
+      ><span class="hs-cpp"
+      >
+#define FOO\
+  1
+</span
+      ><span
+      >
+</span
+      ><span id="line-26"
+      ></span
+      ><span class="annot"
+      ><a href="CPP.html#baz"
+	><span class="hs-identifier hs-type"
+	  >baz</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>String</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-27"
+      ></span
+      ><span id="baz"
+      ><span class="annot"
+	><span class="annottext"
+	  >baz :: String
+</span
+	  ><a href="CPP.html#baz"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String
+</span
+	><span class="hs-string"
+	>&quot;line comment in a string is not a comment --&quot;</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-28"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/CallingQuotes.html b/utils/haddock/hypsrc-test/ref/src/CallingQuotes.html
new file mode 100644
index 0000000000000000000000000000000000000000..9b2e3209322519b8aecf1fc7ff7d557f2654ec45
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/CallingQuotes.html
@@ -0,0 +1,104 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE QuasiQuotes #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="hs-identifier"
+      >CallingQuotes</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span class="hs-keyword"
+      >import</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Quasiquoter.html"
+	><span class="hs-identifier"
+	  >Quasiquoter</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span id="baz"
+      ><span class="annot"
+	><span class="annottext"
+	  >baz :: [Char]
+</span
+	  ><a href="CallingQuotes.html#baz"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >  </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class=""
+	>[string| foo bar |]</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Char] -&gt; [Char] -&gt; [Char]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><span class="hs-operator hs-var"
+	>++</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class=""
+	>[string| some
+  mulitline
+  quasiquote
+|]</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
\ No newline at end of file
diff --git a/utils/haddock/hypsrc-test/ref/src/Classes.html b/utils/haddock/hypsrc-test/ref/src/Classes.html
new file mode 100644
index 0000000000000000000000000000000000000000..4ae9e94ab42f46fd91426527dd72109a15a9e33f
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Classes.html
@@ -0,0 +1,1493 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Classes.html"
+	><span class="hs-identifier"
+	  >Classes</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span class="hs-keyword"
+      >class</span
+      ><span
+      > </span
+      ><span id="Foo"
+      ><span class="annot"
+	><a href="Classes.html#Foo"
+	  ><span class="hs-identifier hs-var"
+	    >Foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span
+      >    </span
+      ><span id="bar"
+      ><span class="annot"
+	><a href="Classes.html#bar"
+	  ><span class="hs-identifier hs-type"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span
+      >    </span
+      ><span id="baz"
+      ><span class="annot"
+	><a href="Classes.html#baz"
+	  ><span class="hs-identifier hs-type"
+	    >baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span class="hs-keyword"
+      >instance</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Classes.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >bar :: Int -&gt; Int
+</span
+	  ><a href="Classes.html#bar"
+	  ><span class="hs-identifier hs-var hs-var hs-var"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int
+forall a. a -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>id</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >baz :: Int -&gt; (Int, Int)
+</span
+	  ><a href="Classes.html#baz"
+	  ><span class="hs-identifier hs-var hs-var hs-var"
+	    >baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span class="hs-keyword"
+      >instance</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="Classes.html#Foo"
+	  ><span class="hs-identifier hs-type"
+	    >Foo</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >bar :: [a] -&gt; Int
+</span
+	  ><a href="Classes.html#bar"
+	  ><span class="hs-identifier hs-var hs-var hs-var"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; Int
+forall a. [a] -&gt; Int
+forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
+</span
+	><span class="hs-identifier hs-var"
+	>length</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >baz :: Int -&gt; ([a], [a])
+</span
+	  ><a href="Classes.html#baz"
+	  ><span class="hs-identifier hs-var hs-var hs-var"
+	    >baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >]</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >]</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ><span class="hs-keyword"
+      >class</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Classes.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=&gt;</span
+      ><span
+      > </span
+      ><span id="Foo%27"
+      ><span class="annot"
+	><a href="Classes.html#Foo%27"
+	  ><span class="hs-identifier hs-var"
+	    >Foo'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ><span
+      >    </span
+      ><span id="quux"
+      ><span class="annot"
+	><a href="Classes.html#quux"
+	  ><span class="hs-identifier hs-type"
+	    >quux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-20"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><a href="Classes.html#quux"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >quux</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-special"
+	>(</span
+	><span id=""
+	><span class="annot"
+	  ><span class="annottext"
+	    >a
+</span
+	    ><a href="#"
+	    ><span class="hs-identifier hs-var"
+	      >x</span
+	      ></a
+	    ></span
+	  ></span
+	><span class="hs-special"
+	>,</span
+	><span
+	> </span
+	><span id=""
+	><span class="annot"
+	  ><span class="annottext"
+	    >a
+</span
+	    ><a href="#"
+	    ><span class="hs-identifier hs-var"
+	      >y</span
+	      ></a
+	    ></span
+	  ></span
+	><span class="hs-special"
+	>)</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>=</span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >[a] -&gt; a
+forall a. Foo' a =&gt; [a] -&gt; a
+</span
+	  ><a href="Classes.html#norf"
+	  ><span class="hs-identifier hs-var"
+	    >norf</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>,</span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-21"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-22"
+      ></span
+      ><span
+      >    </span
+      ><span id="norf"
+      ><span class="annot"
+	><a href="Classes.html#norf"
+	  ><span class="hs-identifier hs-type"
+	    >norf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-23"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><a href="Classes.html#norf"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >norf</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>=</span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >(a, a) -&gt; a
+forall a. Foo' a =&gt; (a, a) -&gt; a
+</span
+	  ><a href="Classes.html#quux"
+	  ><span class="hs-identifier hs-var"
+	    >quux</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >((a, a) -&gt; a) -&gt; ([a] -&gt; (a, a)) -&gt; [a] -&gt; a
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	  ><span class="hs-operator hs-var"
+	  >.</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >Int -&gt; (a, a)
+forall a. Foo a =&gt; Int -&gt; (a, a)
+</span
+	  ><a href="Classes.html#baz"
+	  ><span class="hs-identifier hs-var"
+	    >baz</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >(Int -&gt; (a, a)) -&gt; ([a] -&gt; Int) -&gt; [a] -&gt; (a, a)
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	  ><span class="hs-operator hs-var"
+	  >.</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >[Int] -&gt; Int
+forall a. Num a =&gt; [a] -&gt; a
+forall (t :: * -&gt; *) a. (Foldable t, Num a) =&gt; t a -&gt; a
+</span
+	  ><span class="hs-identifier hs-var"
+	  >sum</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >([Int] -&gt; Int) -&gt; ([a] -&gt; [Int]) -&gt; [a] -&gt; Int
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	  ><span class="hs-operator hs-var"
+	  >.</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >(a -&gt; Int) -&gt; [a] -&gt; [Int]
+forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
+</span
+	  ><span class="hs-identifier hs-var"
+	  >map</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><span class="annottext"
+	  >a -&gt; Int
+forall a. Foo a =&gt; a -&gt; Int
+</span
+	  ><a href="Classes.html#bar"
+	  ><span class="hs-identifier hs-var"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-24"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-25"
+      ></span
+      ><span class="hs-keyword"
+      >instance</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="Classes.html#Foo%27"
+	  ><span class="hs-identifier hs-type"
+	    >Foo'</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><span class="hs-identifier hs-type"
+	  >Int</span
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-26"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >norf :: [Int] -&gt; Int
+</span
+	  ><a href="Classes.html#norf"
+	  ><span class="hs-identifier hs-var hs-var hs-var"
+	    >norf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Int] -&gt; Int
+forall a. Num a =&gt; [a] -&gt; a
+forall (t :: * -&gt; *) a. (Foldable t, Num a) =&gt; t a -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>sum</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-27"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-28"
+      ></span
+      ><span class="hs-keyword"
+      >instance</span
+      ><span
+      > </span
+      ><span id=""
+      ><span id=""
+	><span class="annot"
+	  ><a href="Classes.html#Foo%27"
+	    ><span class="hs-identifier hs-type"
+	      >Foo'</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >[</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >]</span
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-29"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >quux :: ([a], [a]) -&gt; [a]
+</span
+	  ><a href="Classes.html#quux"
+	  ><span class="hs-identifier hs-var hs-var hs-var"
+	    >quux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>([a] -&gt; [a] -&gt; [a]) -&gt; ([a], [a]) -&gt; [a]
+forall a b c. (a -&gt; b -&gt; c) -&gt; (a, b) -&gt; c
+</span
+	><span class="hs-identifier hs-var"
+	>uncurry</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; [a] -&gt; [a]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><span class="hs-operator hs-var"
+	>(++)</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-30"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-31"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-32"
+      ></span
+      ><span class="hs-keyword"
+      >class</span
+      ><span
+      > </span
+      ><span id="Plugh"
+      ><span class="annot"
+	><a href="Classes.html#Plugh"
+	  ><span class="hs-identifier hs-var"
+	    >Plugh</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >p</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-33"
+      ></span
+      ><span
+      >    </span
+      ><span id="plugh"
+      ><span class="annot"
+	><a href="Classes.html#plugh"
+	  ><span class="hs-identifier hs-type"
+	    >plugh</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span id=""
+      ><span id=""
+	><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >p</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >p</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >p</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >(</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >)</span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >(</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >)</span
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-34"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-35"
+      ></span
+      ><span class="hs-keyword"
+      >instance</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Classes.html#Plugh"
+	><span class="hs-identifier hs-type"
+	  >Plugh</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Either</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-36"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >plugh :: forall a b. Either a a -&gt; Either b b -&gt; Either (a -&gt; b) (b -&gt; a)
+</span
+	  ><a href="Classes.html#plugh"
+	  ><span class="hs-identifier hs-var hs-var hs-var"
+	    >plugh</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Left</span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Either b b
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(b -&gt; a) -&gt; Either (a -&gt; b) (b -&gt; a)
+forall a b. b -&gt; Either a b
+</span
+	><span class="hs-identifier hs-var"
+	>Right</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>((b -&gt; a) -&gt; Either (a -&gt; b) (b -&gt; a))
+-&gt; (b -&gt; a) -&gt; Either (a -&gt; b) (b -&gt; a)
+forall a b. (a -&gt; b) -&gt; a -&gt; b
+</span
+	><span class="hs-operator hs-var"
+	>$</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; b -&gt; a
+forall a b. a -&gt; b -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>const</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-37"
+      ></span
+      ><span
+      >    </span
+      ><span class="annot"
+      ><a href="Classes.html#plugh"
+	><span class="hs-identifier hs-var"
+	  >plugh</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Right</span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Either b b
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(b -&gt; a) -&gt; Either (a -&gt; b) (b -&gt; a)
+forall a b. b -&gt; Either a b
+</span
+	><span class="hs-identifier hs-var"
+	>Right</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>((b -&gt; a) -&gt; Either (a -&gt; b) (b -&gt; a))
+-&gt; (b -&gt; a) -&gt; Either (a -&gt; b) (b -&gt; a)
+forall a b. (a -&gt; b) -&gt; a -&gt; b
+</span
+	><span class="hs-operator hs-var"
+	>$</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; b -&gt; a
+forall a b. a -&gt; b -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>const</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-38"
+      ></span
+      ><span
+      >    </span
+      ><span class="annot"
+      ><a href="Classes.html#plugh"
+	><span class="hs-identifier hs-var"
+	  >plugh</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Either a a
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Left</span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >b
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(a -&gt; b) -&gt; Either (a -&gt; b) (b -&gt; a)
+forall a b. a -&gt; Either a b
+</span
+	><span class="hs-identifier hs-var"
+	>Left</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>((a -&gt; b) -&gt; Either (a -&gt; b) (b -&gt; a))
+-&gt; (a -&gt; b) -&gt; Either (a -&gt; b) (b -&gt; a)
+forall a b. (a -&gt; b) -&gt; a -&gt; b
+</span
+	><span class="hs-operator hs-var"
+	>$</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>b -&gt; a -&gt; b
+forall a b. a -&gt; b -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>const</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>b
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >b</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-39"
+      ></span
+      ><span
+      >    </span
+      ><span class="annot"
+      ><a href="Classes.html#plugh"
+	><span class="hs-identifier hs-var"
+	  >plugh</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Either a a
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Right</span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >b
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(a -&gt; b) -&gt; Either (a -&gt; b) (b -&gt; a)
+forall a b. a -&gt; Either a b
+</span
+	><span class="hs-identifier hs-var"
+	>Left</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>((a -&gt; b) -&gt; Either (a -&gt; b) (b -&gt; a))
+-&gt; (a -&gt; b) -&gt; Either (a -&gt; b) (b -&gt; a)
+forall a b. (a -&gt; b) -&gt; a -&gt; b
+</span
+	><span class="hs-operator hs-var"
+	>$</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>b -&gt; a -&gt; b
+forall a b. a -&gt; b -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>const</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>b
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >b</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-40"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/Constructors.html b/utils/haddock/hypsrc-test/ref/src/Constructors.html
new file mode 100644
index 0000000000000000000000000000000000000000..d352cb8ef16c51ae2440dec0783d7cb052997fd8
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Constructors.html
@@ -0,0 +1,1403 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Constructors.html"
+	><span class="hs-identifier"
+	  >Constructors</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span class="hs-keyword"
+      >data</span
+      ><span
+      > </span
+      ><span id="Foo"
+      ><span class="annot"
+	><a href="Constructors.html#Foo"
+	  ><span class="hs-identifier hs-var"
+	    >Foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span id="Bar"
+      ><span class="annot"
+	><a href="Constructors.html#Bar"
+	  ><span class="hs-identifier hs-var"
+	    >Bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-glyph"
+      >|</span
+      ><span
+      > </span
+      ><span id="Baz"
+      ><span class="annot"
+	><a href="Constructors.html#Baz"
+	  ><span class="hs-identifier hs-var"
+	    >Baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-glyph"
+      >|</span
+      ><span
+      > </span
+      ><span id="Quux"
+      ><span class="annot"
+	><a href="Constructors.html#Quux"
+	  ><span class="hs-identifier hs-var"
+	    >Quux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Constructors.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span class="hs-keyword"
+      >newtype</span
+      ><span
+      > </span
+      ><span id="Norf"
+      ><span class="annot"
+	><a href="Constructors.html#Norf"
+	  ><span class="hs-identifier hs-var"
+	    >Norf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span id="Norf"
+      ><span class="annot"
+	><a href="Constructors.html#Norf"
+	  ><span class="hs-identifier hs-var"
+	    >Norf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Constructors.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="annot"
+      ><a href="Constructors.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >]</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Constructors.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span class="annot"
+      ><a href="Constructors.html#bar"
+	><span class="hs-identifier hs-type"
+	  >bar</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Constructors.html#baz"
+	><span class="hs-identifier hs-type"
+	  >baz</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Constructors.html#quux"
+	><span class="hs-identifier hs-type"
+	  >quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Constructors.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span id="bar"
+      ><span class="annot"
+	><span class="annottext"
+	  >bar :: Foo
+</span
+	  ><a href="Constructors.html#bar"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="Constructors.html#Bar"
+	><span class="hs-identifier hs-var"
+	  >Bar</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span id="baz"
+      ><span class="annot"
+	><span class="annottext"
+	  >baz :: Foo
+</span
+	  ><a href="Constructors.html#baz"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="Constructors.html#Baz"
+	><span class="hs-identifier hs-var"
+	  >Baz</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span id="quux"
+      ><span class="annot"
+	><span class="annottext"
+	  >quux :: Foo
+</span
+	  ><a href="Constructors.html#quux"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >quux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo -&gt; Int -&gt; Foo
+</span
+	><a href="Constructors.html#Quux"
+	><span class="hs-identifier hs-var"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="Constructors.html#quux"
+	><span class="hs-identifier hs-var"
+	  >quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ><span class="annot"
+      ><a href="Constructors.html#unfoo"
+	><span class="hs-identifier hs-type"
+	  >unfoo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Constructors.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-20"
+      ></span
+      ><span id="unfoo"
+      ><span class="annot"
+	><span class="annottext"
+	  >unfoo :: Foo -&gt; Int
+</span
+	  ><a href="Constructors.html#unfoo"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >unfoo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="Constructors.html#Bar"
+	><span class="hs-identifier hs-var"
+	  >Bar</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-21"
+      ></span
+      ><span class="annot"
+      ><a href="Constructors.html#unfoo"
+	><span class="hs-identifier hs-var"
+	  >unfoo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="Constructors.html#Baz"
+	><span class="hs-identifier hs-var"
+	  >Baz</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-22"
+      ></span
+      ><span class="annot"
+      ><a href="Constructors.html#unfoo"
+	><span class="hs-identifier hs-var"
+	  >unfoo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Constructors.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Foo
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >n</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>42</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >n</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo -&gt; Int
+</span
+	><a href="Constructors.html#unfoo"
+	><span class="hs-identifier hs-var"
+	  >unfoo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >foo</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-23"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-24"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-25"
+      ></span
+      ><span class="annot"
+      ><a href="Constructors.html#unnorf"
+	><span class="hs-identifier hs-type"
+	  >unnorf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Constructors.html#Norf"
+	><span class="hs-identifier hs-type"
+	  >Norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="annot"
+      ><a href="Constructors.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      >
+</span
+      ><span id="line-26"
+      ></span
+      ><span id="unnorf"
+      ><span class="annot"
+	><span class="annottext"
+	  >unnorf :: Norf -&gt; [Foo]
+</span
+	  ><a href="Constructors.html#unnorf"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >unnorf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Constructors.html#Norf"
+	><span class="hs-identifier hs-type"
+	  >Norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="Constructors.html#Bar"
+	><span class="hs-identifier hs-var"
+	  >Bar</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[Foo]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >xs</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="Constructors.html#Bar"
+	><span class="hs-identifier hs-var"
+	  >Bar</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Foo]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >xs</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-27"
+      ></span
+      ><span class="annot"
+      ><a href="Constructors.html#unnorf"
+	><span class="hs-identifier hs-var"
+	  >unnorf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Constructors.html#Norf"
+	><span class="hs-identifier hs-type"
+	  >Norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="Constructors.html#Baz"
+	><span class="hs-identifier hs-var"
+	  >Baz</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[Foo]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >xs</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="Constructors.html#Baz"
+	><span class="hs-identifier hs-var"
+	  >Baz</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Foo] -&gt; [Foo]
+forall a. [a] -&gt; [a]
+</span
+	><span class="hs-identifier hs-var"
+	>reverse</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Foo]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >xs</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-28"
+      ></span
+      ><span class="annot"
+      ><a href="Constructors.html#unnorf"
+	><span class="hs-identifier hs-var"
+	  >unnorf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Norf
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Foo]
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-29"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-30"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-31"
+      ></span
+      ><span class="annot"
+      ><a href="Constructors.html#unnorf%27"
+	><span class="hs-identifier hs-type"
+	  >unnorf'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Constructors.html#Norf"
+	><span class="hs-identifier hs-type"
+	  >Norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-32"
+      ></span
+      ><span id="unnorf%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >unnorf' :: Norf -&gt; Int
+</span
+	  ><a href="Constructors.html#unnorf%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >unnorf'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >x :: Norf
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-glyph"
+      >@</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Constructors.html#Norf"
+	><span class="hs-identifier hs-type"
+	  >Norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >f1 :: Foo
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >f1</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-glyph"
+      >@</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Constructors.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >n</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Foo]
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >f2 :: Foo
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >f2</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-glyph"
+      >@</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Constructors.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Foo
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >f3</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      >
+</span
+      ><span id="line-33"
+      ></span
+      ><span
+      >    </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >n</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo -&gt; Int
+</span
+	><a href="Constructors.html#unfoo"
+	><span class="hs-identifier hs-var"
+	  >unfoo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >f1</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo -&gt; Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >aux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >f3</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-34"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-35"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >aux :: Foo -&gt; Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >aux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Foo
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >fx</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo -&gt; Int
+</span
+	><a href="Constructors.html#unfoo"
+	><span class="hs-identifier hs-var"
+	  >unfoo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >f2</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo -&gt; Int
+</span
+	><a href="Constructors.html#unfoo"
+	><span class="hs-identifier hs-var"
+	  >unfoo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >fx</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo -&gt; Int
+</span
+	><a href="Constructors.html#unfoo"
+	><span class="hs-identifier hs-var"
+	  >unfoo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >f3</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-36"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >x' :: Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >x'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Int] -&gt; Int
+forall a. Num a =&gt; [a] -&gt; a
+forall (t :: * -&gt; *) a. (Foldable t, Num a) =&gt; t a -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>sum</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>([Int] -&gt; Int) -&gt; (Norf -&gt; [Int]) -&gt; Norf -&gt; Int
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	><span class="hs-operator hs-var"
+	>.</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(Foo -&gt; Int) -&gt; [Foo] -&gt; [Int]
+forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
+</span
+	><span class="hs-identifier hs-var"
+	>map</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Foo -&gt; Int
+</span
+	><a href="Constructors.html#unfoo"
+	><span class="hs-identifier hs-var"
+	  >unfoo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>([Foo] -&gt; [Int]) -&gt; (Norf -&gt; [Foo]) -&gt; Norf -&gt; [Int]
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	><span class="hs-operator hs-var"
+	>.</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Norf -&gt; [Foo]
+</span
+	><a href="Constructors.html#unnorf"
+	><span class="hs-identifier hs-var"
+	  >unnorf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(Norf -&gt; Int) -&gt; Norf -&gt; Int
+forall a b. (a -&gt; b) -&gt; a -&gt; b
+</span
+	><span class="hs-operator hs-var"
+	>$</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Norf
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-37"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/Identifiers.html b/utils/haddock/hypsrc-test/ref/src/Identifiers.html
new file mode 100644
index 0000000000000000000000000000000000000000..d71610378d917c7b0dc3859c3a706c6defcefe5f
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Identifiers.html
@@ -0,0 +1,1514 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Identifiers.html"
+	><span class="hs-identifier"
+	  >Identifiers</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span class="annot"
+      ><a href="Identifiers.html#foo"
+	><span class="hs-identifier hs-type"
+	  >foo</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Identifiers.html#bar"
+	><span class="hs-identifier hs-type"
+	  >bar</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Identifiers.html#baz"
+	><span class="hs-identifier hs-type"
+	  >baz</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span id="foo"
+      ><span class="annot"
+	><span class="annottext"
+	  >foo :: Int -&gt; Int -&gt; Int
+</span
+	  ><a href="Identifiers.html#foo"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="Identifiers.html#bar"
+	><span class="hs-identifier hs-var"
+	  >bar</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span id="bar"
+      ><span class="annot"
+	><span class="annottext"
+	  >bar :: Int -&gt; Int -&gt; Int
+</span
+	  ><a href="Identifiers.html#bar"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-glyph hs-var"
+	>-</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="Identifiers.html#baz"
+	><span class="hs-identifier hs-var"
+	  >baz</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-glyph hs-var"
+	>-</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span id="baz"
+      ><span class="annot"
+	><span class="annottext"
+	  >baz :: Int -&gt; Int -&gt; Int
+</span
+	  ><a href="Identifiers.html#baz"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span class="annot"
+      ><a href="Identifiers.html#quux"
+	><span class="hs-identifier hs-type"
+	  >quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span id="quux"
+      ><span class="annot"
+	><span class="annottext"
+	  >quux :: Int -&gt; Int
+</span
+	  ><a href="Identifiers.html#quux"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >quux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="Identifiers.html#foo"
+	><span class="hs-identifier hs-var"
+	  >foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="Identifiers.html#bar"
+	><span class="hs-identifier hs-var"
+	  >bar</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="Identifiers.html#bar"
+	><span class="hs-identifier hs-var"
+	  >bar</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span class="annot"
+      ><a href="Identifiers.html#norf"
+	><span class="hs-identifier hs-type"
+	  >norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span id="norf"
+      ><span class="annot"
+	><span class="annottext"
+	  >norf :: Int -&gt; Int -&gt; Int -&gt; Int
+</span
+	  ><a href="Identifiers.html#norf"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >norf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >z</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-glyph"
+      >|</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Bool
+forall a. Ord a =&gt; a -&gt; a -&gt; Bool
+</span
+	><span class="hs-operator hs-var"
+	>&lt;</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int
+</span
+	><a href="Identifiers.html#quux"
+	><span class="hs-identifier hs-var"
+	  >quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-glyph"
+      >|</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Bool
+forall a. Ord a =&gt; a -&gt; a -&gt; Bool
+</span
+	><span class="hs-operator hs-var"
+	>&lt;</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int
+</span
+	><a href="Identifiers.html#quux"
+	><span class="hs-identifier hs-var"
+	  >quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-glyph"
+      >|</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >z</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Bool
+forall a. Ord a =&gt; a -&gt; a -&gt; Bool
+</span
+	><span class="hs-operator hs-var"
+	>&lt;</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int
+</span
+	><a href="Identifiers.html#quux"
+	><span class="hs-identifier hs-var"
+	  >quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >z</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-glyph"
+      >|</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Bool
+</span
+	><span class="hs-identifier hs-var"
+	>otherwise</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int -&gt; Int
+</span
+	><a href="Identifiers.html#norf"
+	><span class="hs-identifier hs-var"
+	  >norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-glyph"
+      >-</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-glyph"
+      >-</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-glyph"
+      >-</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >z</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-20"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-21"
+      ></span
+      ><span class="annot"
+      ><a href="Identifiers.html#main"
+	><span class="hs-identifier hs-type"
+	  >main</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>IO</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-22"
+      ></span
+      ><span id="main"
+      ><span class="annot"
+	><span class="annottext"
+	  >main :: IO ()
+</span
+	  ><a href="Identifiers.html#main"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >main</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >do</span
+      ><span
+      >
+</span
+      ><span id="line-23"
+      ></span
+      ><span
+      >    </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String -&gt; IO ()
+</span
+	><span class="hs-identifier hs-var"
+	>putStrLn</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(String -&gt; IO ()) -&gt; (Int -&gt; String) -&gt; Int -&gt; IO ()
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	><span class="hs-operator hs-var"
+	>.</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; String
+forall a. Show a =&gt; a -&gt; String
+</span
+	><span class="hs-identifier hs-var"
+	>show</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(Int -&gt; IO ()) -&gt; Int -&gt; IO ()
+forall a b. (a -&gt; b) -&gt; a -&gt; b
+</span
+	><span class="hs-operator hs-var"
+	>$</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="Identifiers.html#foo"
+	><span class="hs-identifier hs-var"
+	  >foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-24"
+      ></span
+      ><span
+      >    </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String -&gt; IO ()
+</span
+	><span class="hs-identifier hs-var"
+	>putStrLn</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(String -&gt; IO ()) -&gt; (Int -&gt; String) -&gt; Int -&gt; IO ()
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	><span class="hs-operator hs-var"
+	>.</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; String
+forall a. Show a =&gt; a -&gt; String
+</span
+	><span class="hs-identifier hs-var"
+	>show</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(Int -&gt; IO ()) -&gt; Int -&gt; IO ()
+forall a b. (a -&gt; b) -&gt; a -&gt; b
+</span
+	><span class="hs-operator hs-var"
+	>$</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int
+</span
+	><a href="Identifiers.html#quux"
+	><span class="hs-identifier hs-var"
+	  >quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >z</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-25"
+      ></span
+      ><span
+      >    </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String -&gt; IO ()
+</span
+	><span class="hs-identifier hs-var"
+	>putStrLn</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(String -&gt; IO ()) -&gt; (Int -&gt; String) -&gt; Int -&gt; IO ()
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	><span class="hs-operator hs-var"
+	>.</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; String
+forall a. Show a =&gt; a -&gt; String
+</span
+	><span class="hs-identifier hs-var"
+	>show</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(Int -&gt; IO ()) -&gt; Int -&gt; IO ()
+forall a b. (a -&gt; b) -&gt; a -&gt; b
+</span
+	><span class="hs-operator hs-var"
+	>$</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int -&gt; Int
+</span
+	><a href="Identifiers.html#norf"
+	><span class="hs-identifier hs-var"
+	  >Identifiers.norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >z</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-26"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-27"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >x :: Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>10</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-28"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >y :: Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>20</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-29"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >z :: Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >z</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>30</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-30"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/LinkingIdentifiers.html b/utils/haddock/hypsrc-test/ref/src/LinkingIdentifiers.html
new file mode 100644
index 0000000000000000000000000000000000000000..bc588f8044ebaf4065376f761bb1afaa1854dbc7
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/LinkingIdentifiers.html
@@ -0,0 +1,627 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-comment"
+      >-- Tests that the identifiers/operators are properly linked even when:</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span class="hs-comment"
+      >--</span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span class="hs-comment"
+      >--   * backquoted, parenthesized, vanilla</span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span class="hs-comment"
+      >--   * qualified, not-qualified</span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span class="hs-comment"
+      >--</span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="LinkingIdentifiers.html"
+	><span class="hs-identifier"
+	  >LinkingIdentifiers</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span class="annot"
+      ><a href="LinkingIdentifiers.html#ident"
+	><span class="hs-identifier hs-type"
+	  >ident</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id="ident"
+      ><span class="annot"
+	><span class="annottext"
+	  >ident :: Int -&gt; Int -&gt; Int
+</span
+	  ><a href="LinkingIdentifiers.html#ident"
+	  ><span class="hs-operator hs-var hs-var"
+	    >`ident`</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="LinkingIdentifiers.html#ident"
+	><span class="hs-operator hs-var"
+	  >`ident`</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="LinkingIdentifiers.html#ident"
+	><span class="hs-operator hs-var"
+	  >`LinkingIdentifiers.ident`</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span class="annot"
+      ><a href="LinkingIdentifiers.html#ident"
+	><span class="hs-identifier hs-var"
+	  >ident</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="LinkingIdentifiers.html#ident"
+	><span class="hs-identifier hs-var"
+	  >ident</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="LinkingIdentifiers.html#ident"
+	><span class="hs-identifier hs-var"
+	  >LinkingIdentifiers.ident</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span class="annot"
+      ><a href="LinkingIdentifiers.html#%2B%2B%3A%2B%2B"
+	><span class="hs-operator hs-type"
+	  >(++:++)</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id="%2B%2B%3A%2B%2B"
+      ><span class="annot"
+	><span class="annottext"
+	  >++:++ :: Int -&gt; Int -&gt; Int
+</span
+	  ><a href="LinkingIdentifiers.html#%2B%2B%3A%2B%2B"
+	  ><span class="hs-operator hs-var hs-var"
+	    >++:++</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="LinkingIdentifiers.html#%2B%2B%3A%2B%2B"
+	><span class="hs-operator hs-var"
+	  >++:++</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="LinkingIdentifiers.html#%2B%2B%3A%2B%2B"
+	><span class="hs-operator hs-var"
+	  >LinkingIdentifiers.++:++</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span class="annot"
+      ><a href="LinkingIdentifiers.html#%2B%2B%3A%2B%2B"
+	><span class="hs-operator hs-var"
+	  >(++:++)</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="LinkingIdentifiers.html#%2B%2B%3A%2B%2B"
+	><span class="hs-operator hs-var"
+	  >(++:++)</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+</span
+	><a href="LinkingIdentifiers.html#%2B%2B%3A%2B%2B"
+	><span class="hs-operator hs-var"
+	  >(LinkingIdentifiers.++:++)</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>2</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/Literals.html b/utils/haddock/hypsrc-test/ref/src/Literals.html
new file mode 100644
index 0000000000000000000000000000000000000000..f201c8fddc769d0c80974aca230e9f0f14574cef
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Literals.html
@@ -0,0 +1,564 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Literals.html"
+	><span class="hs-identifier"
+	  >Literals</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span class="annot"
+      ><a href="Literals.html#str"
+	><span class="hs-identifier hs-type"
+	  >str</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>String</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span id="str"
+      ><span class="annot"
+	><span class="annottext"
+	  >str :: String
+</span
+	  ><a href="Literals.html#str"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >str</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String
+</span
+	><span class="hs-string"
+	>&quot;str literal&quot;</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Literals.html#num"
+	  ><span class="hs-identifier hs-type"
+	    >num</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="annot"
+	><span class="hs-identifier hs-type"
+	  >Num</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>=&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span id="num"
+      ><span class="annot"
+	><span class="annottext"
+	  >num :: forall a. Num a =&gt; a
+</span
+	  ><a href="Literals.html#num"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >num</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a -&gt; a
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><span class="hs-number"
+	>1</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a -&gt; a
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><span class="hs-number"
+	>1010011</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a -&gt; a
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><span class="hs-number"
+	>41231</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a -&gt; a
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><span class="hs-number"
+	>12131</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Literals.html#frac"
+	  ><span class="hs-identifier hs-type"
+	    >frac</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="annot"
+	><span class="hs-identifier hs-type"
+	  >Fractional</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>=&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span id="frac"
+      ><span class="annot"
+	><span class="annottext"
+	  >frac :: forall a. Fractional a =&gt; a
+</span
+	  ><a href="Literals.html#frac"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >frac</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><span class="hs-number"
+	>42.0000001</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Literals.html#list"
+	  ><span class="hs-identifier hs-type"
+	    >list</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="hs-special"
+	>[</span
+	><span class="hs-special"
+	>[</span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span class="hs-special"
+	>]</span
+	><span class="hs-special"
+	>]</span
+	><span class="hs-special"
+	>]</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span id="list"
+      ><span class="annot"
+	><span class="annottext"
+	  >list :: forall a. [[[[a]]]]
+</span
+	  ><a href="Literals.html#list"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >list</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >]</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >]</span
+      ><span class="hs-special"
+      >]</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >]</span
+      ><span class="hs-special"
+      >]</span
+      ><span class="hs-special"
+      >]</span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span class="annot"
+      ><a href="Literals.html#pair"
+	><span class="hs-identifier hs-type"
+	  >pair</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ><span id="pair"
+      ><span class="annot"
+	><span class="annottext"
+	  >pair :: ((), ((), (), ()), ())
+</span
+	  ><a href="Literals.html#pair"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >pair</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/Operators.html b/utils/haddock/hypsrc-test/ref/src/Operators.html
new file mode 100644
index 0000000000000000000000000000000000000000..1d14699ddebde2c0421399676382300ab62c1915
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Operators.html
@@ -0,0 +1,1140 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Operators.html"
+	><span class="hs-identifier"
+	  >Operators</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Operators.html#%2B%2B%2B"
+	  ><span class="hs-operator hs-type"
+	    >(+++)</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[a]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id="%2B%2B%2B"
+      ><span class="annot"
+	><span class="annottext"
+	  >+++ :: forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	  ><a href="Operators.html#%2B%2B%2B"
+	  ><span class="hs-operator hs-var hs-var"
+	    >+++</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[a]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; [a] -&gt; [a]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><span class="hs-operator hs-var"
+	>++</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >b</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; [a] -&gt; [a]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><span class="hs-operator hs-var"
+	>++</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Operators.html#%24%24%24"
+	  ><span class="hs-operator hs-type"
+	    >($$$)</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[a]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id="%24%24%24"
+      ><span class="annot"
+	><span class="annottext"
+	  >$$$ :: forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	  ><a href="Operators.html#%24%24%24"
+	  ><span class="hs-operator hs-var hs-var"
+	    >$$$</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[a]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >b</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; [a] -&gt; [a]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><a href="Operators.html#%2B%2B%2B"
+	><span class="hs-operator hs-var"
+	  >+++</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Operators.html#%2A%2A%2A"
+	  ><span class="hs-operator hs-type"
+	    >(***)</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span id="%2A%2A%2A"
+      ><span class="annot"
+	><span class="annottext"
+	  >*** :: forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	  ><a href="Operators.html#%2A%2A%2A"
+	  ><span class="hs-operator hs-var hs-var"
+	    >(***)</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[a]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span class="annot"
+      ><a href="Operators.html#%2A%2A%2A"
+	><span class="hs-operator hs-var"
+	  >(***)</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[a]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span class="annot"
+      ><span class="hs-glyph hs-type"
+	>:</span
+	></span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[a]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; [a] -&gt; [a]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><a href="Operators.html#%2B%2B%2B"
+	><span class="hs-operator hs-var"
+	  >+++</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; [a] -&gt; [a]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><a href="Operators.html#%2A%2A%2A"
+	><span class="hs-operator hs-var"
+	  >***</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Operators.html#%2A%2F%5C%2A"
+	  ><span class="hs-operator hs-type"
+	    >(*/\*)</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[[a]]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id="%2A%2F%5C%2A"
+      ><span class="annot"
+	><span class="annottext"
+	  >*/\* :: forall a. [[a]] -&gt; [a] -&gt; [a]
+</span
+	  ><a href="Operators.html#%2A%2F%5C%2A"
+	  ><span class="hs-operator hs-var hs-var"
+	    >*/\*</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[a]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>([a] -&gt; [a]) -&gt; [[a]] -&gt; [a]
+forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
+</span
+	><span class="hs-identifier hs-var"
+	>concatMap</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; [a] -&gt; [a]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><a href="Operators.html#%2A%2A%2A"
+	><span class="hs-operator hs-var"
+	  >***</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[[a]]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Operators.html#%2A%2A%2F%5C%2A%2A"
+	  ><span class="hs-operator hs-type"
+	    >(**/\**)</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span class="hs-special"
+	>]</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>[</span
+	><span class="hs-special"
+	>[</span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>]</span
+	><span class="hs-special"
+	>]</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[[a]]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id="%2A%2A%2F%5C%2A%2A"
+      ><span class="annot"
+	><span class="annottext"
+	  >**/\** :: forall a. [[a]] -&gt; [[a]] -&gt; [[a]]
+</span
+	  ><a href="Operators.html#%2A%2A%2F%5C%2A%2A"
+	  ><span class="hs-operator hs-var hs-var"
+	    >**/\**</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >[[a]]
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>([[a]] -&gt; [a] -&gt; [a]) -&gt; [[[a]]] -&gt; [[a]] -&gt; [[a]]
+forall a b c. (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c]
+</span
+	><span class="hs-identifier hs-var"
+	>zipWith</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[[a]] -&gt; [a] -&gt; [a]
+forall a. [[a]] -&gt; [a] -&gt; [a]
+</span
+	><a href="Operators.html#%2A%2F%5C%2A"
+	><span class="hs-operator hs-var"
+	  >(*/\*)</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="annot"
+      ><span class="annottext"
+	>[[a]]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[[a]] -&gt; [[a]] -&gt; [[a]]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><a href="Operators.html#%2B%2B%2B"
+	><span class="hs-operator hs-var"
+	  >+++</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[[a]]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>[[a]]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[[a]] -&gt; [[a]] -&gt; [[a]]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><a href="Operators.html#%24%24%24"
+	><span class="hs-operator hs-var"
+	  >$$$</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[[a]]
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-20"
+      ></span
+      ><span id=""
+      ><span id=""
+	><span id=""
+	  ><span class="annot"
+	    ><a href="Operators.html#%23.%23"
+	      ><span class="hs-operator hs-type"
+		>(#.#)</span
+		></a
+	      ></span
+	    ><span
+	    > </span
+	    ><span class="hs-glyph"
+	    >::</span
+	    ><span
+	    > </span
+	    ><span class="annot"
+	    ><a href="#"
+	      ><span class="hs-identifier hs-type"
+		>a</span
+		></a
+	      ></span
+	    ><span
+	    > </span
+	    ><span class="hs-glyph"
+	    >-&gt;</span
+	    ><span
+	    > </span
+	    ><span class="annot"
+	    ><a href="#"
+	      ><span class="hs-identifier hs-type"
+		>b</span
+		></a
+	      ></span
+	    ><span
+	    > </span
+	    ><span class="hs-glyph"
+	    >-&gt;</span
+	    ><span
+	    > </span
+	    ><span class="hs-special"
+	    >(</span
+	    ><span class="annot"
+	    ><a href="#"
+	      ><span class="hs-identifier hs-type"
+		>c</span
+		></a
+	      ></span
+	    ><span
+	    > </span
+	    ><span class="hs-glyph"
+	    >-&gt;</span
+	    ><span
+	    > </span
+	    ><span class="hs-special"
+	    >(</span
+	    ><span class="annot"
+	    ><a href="#"
+	      ><span class="hs-identifier hs-type"
+		>a</span
+		></a
+	      ></span
+	    ><span class="hs-special"
+	    >,</span
+	    ><span
+	    > </span
+	    ><span class="annot"
+	    ><a href="#"
+	      ><span class="hs-identifier hs-type"
+		>b</span
+		></a
+	      ></span
+	    ><span class="hs-special"
+	    >)</span
+	    ><span class="hs-special"
+	    >)</span
+	    ></span
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-21"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id="%23.%23"
+      ><span class="annot"
+	><span class="annottext"
+	  >#.# :: forall a b c. a -&gt; b -&gt; c -&gt; (a, b)
+</span
+	  ><a href="Operators.html#%23.%23"
+	  ><span class="hs-operator hs-var hs-var"
+	    >#.#</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >b
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(a, b) -&gt; c -&gt; (a, b)
+forall a b. a -&gt; b -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>const</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>b
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-22"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/Polymorphism.html b/utils/haddock/hypsrc-test/ref/src/Polymorphism.html
new file mode 100644
index 0000000000000000000000000000000000000000..3eff3e5f5265c0e64fa5c6f738a9db8336644fee
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Polymorphism.html
@@ -0,0 +1,2660 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE RankNTypes #-}</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE ScopedTypeVariables #-}</span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Polymorphism.html"
+	><span class="hs-identifier"
+	  >Polymorphism</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Polymorphism.html#foo"
+	  ><span class="hs-identifier hs-type"
+	    >foo</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span id="foo"
+      ><span class="annot"
+	><span class="annottext"
+	  >foo :: forall a. a -&gt; a -&gt; a
+</span
+	  ><a href="Polymorphism.html#foo"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a -&gt; a
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#foo%27"
+	><span class="hs-identifier hs-type"
+	  >foo'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span id="foo%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >foo' :: forall a. a -&gt; a -&gt; a
+</span
+	  ><a href="Polymorphism.html#foo%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >foo'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a -&gt; a
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span id=""
+      ><span id=""
+	><span class="annot"
+	  ><a href="Polymorphism.html#bar"
+	    ><span class="hs-identifier hs-type"
+	      >bar</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >::</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >(</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >,</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >)</span
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span id="bar"
+      ><span class="annot"
+	><span class="annottext"
+	  >bar :: forall a b. a -&gt; b -&gt; (a, b)
+</span
+	  ><a href="Polymorphism.html#bar"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; b -&gt; (a, b)
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#bar%27"
+	><span class="hs-identifier hs-type"
+	  >bar'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ><span id="bar%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >bar' :: forall a b. a -&gt; b -&gt; (a, b)
+</span
+	  ><a href="Polymorphism.html#bar%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >bar'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; b -&gt; (a, b)
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-20"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-21"
+      ></span
+      ><span id=""
+      ><span id=""
+	><span class="annot"
+	  ><a href="Polymorphism.html#baz"
+	    ><span class="hs-identifier hs-type"
+	      >baz</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >::</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >(</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >[</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >]</span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >)</span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-22"
+      ></span
+      ><span id="baz"
+      ><span class="annot"
+	><span class="annottext"
+	  >baz :: forall a b. a -&gt; (a -&gt; [a -&gt; a] -&gt; b) -&gt; b
+</span
+	  ><a href="Polymorphism.html#baz"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; (a -&gt; [a -&gt; a] -&gt; b) -&gt; b
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-23"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-24"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#baz%27"
+	><span class="hs-identifier hs-type"
+	  >baz'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-25"
+      ></span
+      ><span id="baz%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >baz' :: forall a b. a -&gt; (a -&gt; [a -&gt; a] -&gt; b) -&gt; b
+</span
+	  ><a href="Polymorphism.html#baz%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >baz'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; (a -&gt; [a -&gt; a] -&gt; b) -&gt; b
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-26"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-27"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Polymorphism.html#quux"
+	  ><span class="hs-identifier hs-type"
+	    >quux</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>(</span
+	><span class="hs-keyword"
+	>forall</span
+	><span
+	> </span
+	><span id=""
+	><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ></span
+	><span class="hs-operator"
+	>.</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>)</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-28"
+      ></span
+      ><span id="quux"
+      ><span class="annot"
+	><span class="annottext"
+	  >quux :: forall a. a -&gt; (forall a. a -&gt; a) -&gt; a
+</span
+	  ><a href="Polymorphism.html#quux"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >quux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >forall a. a -&gt; a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >f</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a
+forall a. a -&gt; a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >f</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-29"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-30"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#quux%27"
+	><span class="hs-identifier hs-type"
+	  >quux'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-31"
+      ></span
+      ><span id="quux%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >quux' :: forall a. a -&gt; (forall a. a -&gt; a) -&gt; a
+</span
+	  ><a href="Polymorphism.html#quux%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >quux'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >forall a. a -&gt; a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >f</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a
+forall a. a -&gt; a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >f</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-32"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-33"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-34"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Polymorphism.html#num"
+	  ><span class="hs-identifier hs-type"
+	    >num</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="annot"
+	><span class="hs-identifier hs-type"
+	  >Num</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>=&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-35"
+      ></span
+      ><span id="num"
+      ><span class="annot"
+	><span class="annottext"
+	  >num :: forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	  ><a href="Polymorphism.html#num"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >num</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a -&gt; a
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-36"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-37"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#num%27"
+	><span class="hs-identifier hs-type"
+	  >num'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Num</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-38"
+      ></span
+      ><span id="num%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >num' :: forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	  ><a href="Polymorphism.html#num%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >num'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; a -&gt; a
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-39"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-40"
+      ></span
+      ><span id=""
+      ><span id=""
+	><span class="annot"
+	  ><a href="Polymorphism.html#eq"
+	    ><span class="hs-identifier hs-type"
+	      >eq</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >::</span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >(</span
+	  ><span class="annot"
+	  ><span class="hs-identifier hs-type"
+	    >Eq</span
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >,</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><span class="hs-identifier hs-type"
+	    >Eq</span
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >)</span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >=&gt;</span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >[</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >]</span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >[</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >]</span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >(</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >,</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >b</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >)</span
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-41"
+      ></span
+      ><span id="eq"
+      ><span class="annot"
+	><span class="annottext"
+	  >eq :: forall a b. (Eq a, Eq b) =&gt; [a] -&gt; [b] -&gt; (a, b)
+</span
+	  ><a href="Polymorphism.html#eq"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >eq</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; [b] -&gt; (a, b)
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-42"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-43"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#eq%27"
+	><span class="hs-identifier hs-type"
+	  >eq'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Eq</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Eq</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-44"
+      ></span
+      ><span id="eq%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >eq' :: forall a b. (Eq a, Eq b) =&gt; [a] -&gt; [b] -&gt; (a, b)
+</span
+	  ><a href="Polymorphism.html#eq%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >eq'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[a] -&gt; [b] -&gt; (a, b)
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-45"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-46"
+      ></span
+      ><span id=""
+      ><span id=""
+	><span class="annot"
+	  ><a href="Polymorphism.html#mon"
+	    ><span class="hs-identifier hs-type"
+	      >mon</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >::</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><span class="hs-identifier hs-type"
+	    >Monad</span
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >m</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >=&gt;</span
+	  ><span
+	  > </span
+	  ><span class="hs-special"
+	  >(</span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >m</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ><span class="hs-special"
+	  >)</span
+	  ><span
+	  > </span
+	  ><span class="hs-glyph"
+	  >-&gt;</span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >m</span
+	      ></a
+	    ></span
+	  ><span
+	  > </span
+	  ><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-47"
+      ></span
+      ><span id="mon"
+      ><span class="annot"
+	><span class="annottext"
+	  >mon :: forall (m :: * -&gt; *) a. Monad m =&gt; (a -&gt; m a) -&gt; m a
+</span
+	  ><a href="Polymorphism.html#mon"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >mon</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(a -&gt; m a) -&gt; m a
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-48"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-49"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#mon%27"
+	><span class="hs-identifier hs-type"
+	  >mon'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >m</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Monad</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >m</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >m</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >m</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-50"
+      ></span
+      ><span id="mon%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >mon' :: forall (m :: * -&gt; *) a. Monad m =&gt; (a -&gt; m a) -&gt; m a
+</span
+	  ><a href="Polymorphism.html#mon%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >mon'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(a -&gt; m a) -&gt; m a
+forall a. HasCallStack =&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>undefined</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-51"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-52"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-53"
+      ></span
+      ><span id=""
+      ><span class="annot"
+	><a href="Polymorphism.html#norf"
+	  ><span class="hs-identifier hs-type"
+	    >norf</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="hs-special"
+	>(</span
+	><span class="hs-keyword"
+	>forall</span
+	><span
+	> </span
+	><span id=""
+	><span class="annot"
+	  ><a href="#"
+	    ><span class="hs-identifier hs-type"
+	      >a</span
+	      ></a
+	    ></span
+	  ></span
+	><span class="hs-operator"
+	>.</span
+	><span
+	> </span
+	><span class="annot"
+	><span class="hs-identifier hs-type"
+	  >Ord</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>=&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	><span class="hs-special"
+	>)</span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-54"
+      ></span
+      ><span id="norf"
+      ><span class="annot"
+	><span class="annottext"
+	  >norf :: forall a. a -&gt; (forall a. Ord a =&gt; a -&gt; a) -&gt; a
+</span
+	  ><a href="Polymorphism.html#norf"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >norf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >forall a. Ord a =&gt; a -&gt; a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >f</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-55"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-56"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#norf%27"
+	><span class="hs-identifier hs-type"
+	  >norf'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Ord</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-57"
+      ></span
+      ><span id="norf%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >norf' :: forall a. a -&gt; (forall a. Ord a =&gt; a -&gt; a) -&gt; a
+</span
+	  ><a href="Polymorphism.html#norf%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >norf'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >forall a. Ord a =&gt; a -&gt; a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >f</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-58"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-59"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-60"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#plugh"
+	><span class="hs-identifier hs-type"
+	  >plugh</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-61"
+      ></span
+      ><span id="plugh"
+      ><span class="annot"
+	><span class="annottext"
+	  >plugh :: forall a. a -&gt; a
+</span
+	  ><a href="Polymorphism.html#plugh"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >plugh</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-62"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-63"
+      ></span
+      ><span class="annot"
+      ><a href="Polymorphism.html#thud"
+	><span class="hs-identifier hs-type"
+	  >thud</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >forall</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-operator"
+      >.</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-64"
+      ></span
+      ><span id="thud"
+      ><span class="annot"
+	><span class="annottext"
+	  >thud :: forall a b. (a -&gt; b) -&gt; a -&gt; (a, b)
+</span
+	  ><a href="Polymorphism.html#thud"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >thud</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a -&gt; b
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >f</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      >
+</span
+      ><span id="line-65"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>b
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-66"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-67"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >y :: b
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; b
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >f</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >a</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >b</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-68"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/PositionPragmas.html b/utils/haddock/hypsrc-test/ref/src/PositionPragmas.html
new file mode 100644
index 0000000000000000000000000000000000000000..b12713265dfa566daac9c9e69639ed0570f6eb4e
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/PositionPragmas.html
@@ -0,0 +1,190 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LINE 4 &quot;hypsrc-test/src/PositionPragmas.hs&quot; #-}</span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="PositionPragmas.html"
+	><span class="hs-identifier"
+	  >PositionPragmas</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LINE 8 &quot;hypsrc-test/src/PositionPragmas.hs&quot; #-}</span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span class="annot"
+      ><a href="PositionPragmas.html#foo"
+	><span class="hs-identifier hs-type"
+	  >foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>String</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span id="foo"
+      ><span class="annot"
+	><span class="annottext"
+	  >foo :: String
+</span
+	  ><a href="PositionPragmas.html#foo"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String
+</span
+	><a href="PositionPragmas.html#bar"
+	><span class="hs-identifier hs-var"
+	  >bar</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LINE 23 &quot;hypsrc-test/src/PositionPragmas.hs&quot; #-}</span
+      ><span
+      >
+</span
+      ><span id="line-23"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-24"
+      ></span
+      ><span class="annot"
+      ><a href="PositionPragmas.html#bar"
+	><span class="hs-identifier hs-type"
+	  >bar</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>String</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-25"
+      ></span
+      ><span id="bar"
+      ><span class="annot"
+	><span class="annottext"
+	  >bar :: String
+</span
+	  ><a href="PositionPragmas.html#bar"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String
+</span
+	><a href="PositionPragmas.html#foo"
+	><span class="hs-identifier hs-var"
+	  >foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span
+      >
+</span
+      ><span id="line-26"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-27"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/Quasiquoter.html b/utils/haddock/hypsrc-test/ref/src/Quasiquoter.html
new file mode 100644
index 0000000000000000000000000000000000000000..6ca35d7ec2036abaef38e0a05f9bf819f6567cbc
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Quasiquoter.html
@@ -0,0 +1,431 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Quasiquoter.html"
+	><span class="hs-identifier"
+	  >Quasiquoter</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Quasiquoter.html#string"
+	><span class="hs-identifier"
+	  >string</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span class="hs-keyword"
+      >import</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier"
+	>Language.Haskell.TH.Quote</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span class="hs-keyword"
+      >import</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier"
+	>Language.Haskell.TH.Syntax</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span class="annot"
+      ><span class="hs-comment"
+	>-- | Quoter for constructing multiline string literals</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span class="annot"
+      ><a href="Quasiquoter.html#string"
+	><span class="hs-identifier hs-type"
+	  >string</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>QuasiQuoter</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span id="string"
+      ><span class="annot"
+	><span class="annottext"
+	  >string :: QuasiQuoter
+</span
+	  ><a href="Quasiquoter.html#string"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >string</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>QuasiQuoter</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >{</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>quoteExp :: String -&gt; Q Exp
+</span
+	><span class="hs-identifier hs-var"
+	>quoteExp</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Exp -&gt; Q Exp
+forall a. a -&gt; Q a
+forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
+</span
+	><span class="hs-identifier hs-var"
+	>pure</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(Exp -&gt; Q Exp) -&gt; (String -&gt; Exp) -&gt; String -&gt; Q Exp
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	><span class="hs-operator hs-var"
+	>.</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Lit -&gt; Exp
+</span
+	><span class="hs-identifier hs-var"
+	>LitE</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>(Lit -&gt; Exp) -&gt; (String -&gt; Lit) -&gt; String -&gt; Exp
+forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
+</span
+	><span class="hs-operator hs-var"
+	>.</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String -&gt; Lit
+</span
+	><span class="hs-identifier hs-var"
+	>StringL</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>quotePat :: String -&gt; Q Pat
+</span
+	><span class="hs-identifier hs-var"
+	>quotePat</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String -&gt; Q Pat
+forall a. String -&gt; Q a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >invalidDomain</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>quoteType :: String -&gt; Q Type
+</span
+	><span class="hs-identifier hs-var"
+	>quoteType</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String -&gt; Q Type
+forall a. String -&gt; Q a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >invalidDomain</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>quoteDec :: String -&gt; Q [Dec]
+</span
+	><span class="hs-identifier hs-var"
+	>quoteDec</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String -&gt; Q [Dec]
+forall a. String -&gt; Q a
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >invalidDomain</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >}</span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >invalidDomain</span
+	    ></a
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>::</span
+	><span
+	> </span
+	><span class="annot"
+	><span class="hs-identifier hs-type"
+	  >String</span
+	  ></span
+	><span
+	> </span
+	><span class="hs-glyph"
+	>-&gt;</span
+	><span
+	> </span
+	><span class="annot"
+	><span class="hs-identifier hs-type"
+	  >Q</span
+	  ></span
+	><span
+	> </span
+	><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >invalidDomain :: forall a. String -&gt; Q a
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >invalidDomain</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String
+</span
+	><span class="hs-identifier"
+	>_</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String -&gt; Q a
+forall a. String -&gt; Q a
+forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
+</span
+	><span class="hs-identifier hs-var"
+	>fail</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>String
+</span
+	><span class="hs-string"
+	>&quot;stringQuoter: only valid in expression context&quot;</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/Records.html b/utils/haddock/hypsrc-test/ref/src/Records.html
new file mode 100644
index 0000000000000000000000000000000000000000..82403b94aba70136b269d572dd9c63648c577186
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Records.html
@@ -0,0 +1,1391 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE NamedFieldPuns #-}</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE RecordWildCards #-}</span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html"
+	><span class="hs-identifier"
+	  >Records</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span class="hs-keyword"
+      >data</span
+      ><span
+      > </span
+      ><span id="Point"
+      ><span class="annot"
+	><a href="Records.html#Point"
+	  ><span class="hs-identifier hs-var"
+	    >Point</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span id="Point"
+      ><span class="annot"
+	><a href="Records.html#Point"
+	  ><span class="hs-identifier hs-var"
+	    >Point</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >{</span
+      ><span
+      > </span
+      ><span id="x"
+      ><span class="annot"
+	><span class="annottext"
+	  >Point -&gt; Int
+</span
+	  ><a href="Records.html#x"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >!</span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span id="y"
+      ><span class="annot"
+	><span class="annottext"
+	  >Point -&gt; Int
+</span
+	  ><a href="Records.html#y"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >!</span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >}</span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span class="annot"
+      ><a href="Records.html#point"
+	><span class="hs-identifier hs-type"
+	  >point</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span id="point"
+      ><span class="annot"
+	><span class="annottext"
+	  >point :: Int -&gt; Int -&gt; Point
+</span
+	  ><a href="Records.html#point"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >point</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >{</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>x :: Int
+</span
+	><a href="Records.html#x"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>y :: Int
+</span
+	><a href="Records.html#y"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >}</span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ><span class="annot"
+      ><a href="Records.html#lengthSqr"
+	><span class="hs-identifier hs-type"
+	  >lengthSqr</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-20"
+      ></span
+      ><span id="lengthSqr"
+      ><span class="annot"
+	><span class="annottext"
+	  >lengthSqr :: Point -&gt; Int
+</span
+	  ><a href="Records.html#lengthSqr"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >lengthSqr</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >{</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>x :: Point -&gt; Int
+</span
+	><a href="Records.html#x"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>y :: Point -&gt; Int
+</span
+	><a href="Records.html#y"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >}</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-21"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-22"
+      ></span
+      ><span class="annot"
+      ><a href="Records.html#lengthSqr%27"
+	><span class="hs-identifier hs-type"
+	  >lengthSqr'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-23"
+      ></span
+      ><span id="lengthSqr%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >lengthSqr' :: Point -&gt; Int
+</span
+	  ><a href="Records.html#lengthSqr%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >lengthSqr'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >{</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+x :: Point -&gt; Int
+x :: Int
+</span
+	  ><a href="Records.html#x"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+y :: Point -&gt; Int
+y :: Int
+</span
+	  ><a href="Records.html#y"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >}</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int -&gt; Int -&gt; Int
+forall a. Num a =&gt; a -&gt; a -&gt; a
+</span
+	><span class="hs-operator hs-var"
+	>*</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-24"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-25"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-26"
+      ></span
+      ><span class="annot"
+      ><a href="Records.html#translateX"
+	><span class="hs-identifier hs-type"
+	  >translateX</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#translateY"
+	><span class="hs-identifier hs-type"
+	  >translateY</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-27"
+      ></span
+      ><span id="translateX"
+      ><span class="annot"
+	><span class="annottext"
+	  >translateX :: Point -&gt; Int -&gt; Point
+</span
+	  ><a href="Records.html#translateX"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >translateX</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Point
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >p</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >d</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Point
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >p</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >{</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#x"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#x"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >p</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-operator hs-type"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >d</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >}</span
+      ><span
+      >
+</span
+      ><span id="line-28"
+      ></span
+      ><span id="translateY"
+      ><span class="annot"
+	><span class="annottext"
+	  >translateY :: Point -&gt; Int -&gt; Point
+</span
+	  ><a href="Records.html#translateY"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >translateY</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Point
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >p</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >d</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Point
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >p</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >{</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#y"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#y"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >p</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-operator hs-type"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >d</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >}</span
+      ><span
+      >
+</span
+      ><span id="line-29"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-30"
+      ></span
+      ><span class="annot"
+      ><a href="Records.html#translate"
+	><span class="hs-identifier hs-type"
+	  >translate</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-31"
+      ></span
+      ><span id="translate"
+      ><span class="annot"
+	><span class="annottext"
+	  >translate :: Int -&gt; Int -&gt; Point -&gt; Point
+</span
+	  ><a href="Records.html#translate"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >translate</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >x</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Point
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >p</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      >
+</span
+      ><span id="line-32"
+      ></span
+      ><span
+      >    </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Point -&gt; Point
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >aux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Point
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >p</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-33"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-34"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >(</span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >dx</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >Int
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >dy</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-35"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><span class="annottext"
+	  >aux :: Point -&gt; Point
+</span
+	  ><a href="#"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >aux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#Point"
+	><span class="hs-identifier hs-type"
+	  >Point</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >{</span
+      ><span id=""
+      ><span id=""
+	><span class="annot"
+	  ><span class="annottext"
+	    >Int
+x :: Point -&gt; Int
+y :: Point -&gt; Int
+x :: Int
+y :: Int
+</span
+	    ><a href="Records.html#x"
+	    ><span class="hs-glyph hs-var hs-var hs-var hs-var"
+	      >..</span
+	      ></a
+	    ></span
+	  ></span
+	></span
+      ><span class="hs-special"
+      >}</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Point
+</span
+	><a href="#"
+	><span class="hs-identifier hs-var"
+	  >p</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >{</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#x"
+	><span class="hs-identifier hs-var"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >x</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-operator hs-type"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >dx</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Records.html#y"
+	><span class="hs-identifier hs-var"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >y</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-operator hs-type"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >dy</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >}</span
+      ><span
+      >
+</span
+      ><span id="line-36"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/TemplateHaskellQuasiquotes.html b/utils/haddock/hypsrc-test/ref/src/TemplateHaskellQuasiquotes.html
new file mode 100644
index 0000000000000000000000000000000000000000..0e4f94e53ca284b5653358a3600f144bfebe9b81
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/TemplateHaskellQuasiquotes.html
@@ -0,0 +1,950 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE TemplateHaskell #-}</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html"
+	><span class="hs-identifier"
+	  >TemplateHaskellQuasiquotes</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span class="hs-keyword"
+      >import</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier"
+	>Language.Haskell.TH</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#aDecl"
+	><span class="hs-identifier hs-type"
+	  >aDecl</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>DecsQ</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span id="aDecl"
+      ><span class="annot"
+	><span class="annottext"
+	  >aDecl :: DecsQ
+</span
+	  ><a href="TemplateHaskellQuasiquotes.html#aDecl"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >aDecl</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[d|</span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span
+      >    </span
+      ><span class="annot"
+      ><a href="#"
+	><span class="hs-identifier hs-type"
+	  >bar</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >$</span
+      ><span class="annot"
+      ><span class="annottext"
+	>TypeQ
+</span
+	><a href="TemplateHaskellQuasiquotes.html#aType"
+	><span class="hs-identifier hs-var"
+	  >aType</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>String</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >$</span
+      ><span class="annot"
+      ><span class="annottext"
+	>PatQ
+</span
+	><a href="TemplateHaskellQuasiquotes.html#aPattern"
+	><span class="hs-identifier hs-var"
+	  >aPattern</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >$</span
+      ><span class="annot"
+      ><span class="annottext"
+	>ExpQ
+</span
+	><a href="TemplateHaskellQuasiquotes.html#anExpression"
+	><span class="hs-identifier hs-var"
+	  >anExpression</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >|]</span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#aPattern"
+	><span class="hs-identifier hs-type"
+	  >aPattern</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>PatQ</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span id="aPattern"
+      ><span class="annot"
+	><span class="annottext"
+	  >aPattern :: PatQ
+</span
+	  ><a href="TemplateHaskellQuasiquotes.html#aPattern"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >aPattern</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[p|</span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >[</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >aCrazyLongVariableName</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >_unused</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >y</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >z</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >$</span
+      ><span class="annot"
+      ><span class="annottext"
+	>PatQ
+</span
+	><a href="TemplateHaskellQuasiquotes.html#aNumberPattern"
+	><span class="hs-identifier hs-var"
+	  >aNumberPattern</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-string"
+	>&quot;hello&quot;</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-20"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      >
+</span
+      ><span id="line-21"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >|]</span
+      ><span
+      >
+</span
+      ><span id="line-22"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-23"
+      ></span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#aNumberPattern"
+	><span class="hs-identifier hs-type"
+	  >aNumberPattern</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>PatQ</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-24"
+      ></span
+      ><span id="aNumberPattern"
+      ><span class="annot"
+	><span class="annottext"
+	  >aNumberPattern :: PatQ
+</span
+	  ><a href="TemplateHaskellQuasiquotes.html#aNumberPattern"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >aNumberPattern</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[p|</span
+      ><span
+      >
+</span
+      ><span id="line-25"
+      ></span
+      ><span
+      >    </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >w</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-glyph"
+      >@</span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-var"
+	    >v</span
+	    ></a
+	  ></span
+	></span
+      ><span class="hs-glyph"
+      >@</span
+      ><span class="annot"
+      ><span class="hs-number"
+	>4.5</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-26"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >|]</span
+      ><span
+      >
+</span
+      ><span id="line-27"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-28"
+      ></span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#anExpression"
+	><span class="hs-identifier hs-type"
+	  >anExpression</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#anExpression2"
+	><span class="hs-identifier hs-type"
+	  >anExpression2</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>ExpQ</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-29"
+      ></span
+      ><span id="anExpression"
+      ><span class="annot"
+	><span class="annottext"
+	  >anExpression :: ExpQ
+</span
+	  ><a href="TemplateHaskellQuasiquotes.html#anExpression"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >anExpression</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[e|</span
+      ><span
+      >
+</span
+      ><span id="line-30"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >[</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="hs-number"
+	>1</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-operator hs-type"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >$</span
+      ><span class="annot"
+      ><span class="annottext"
+	>ExpQ
+</span
+	><a href="TemplateHaskellQuasiquotes.html#anExpression2"
+	><span class="hs-identifier hs-var"
+	  >anExpression2</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-string"
+	>&quot;world&quot;</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      >
+</span
+      ><span id="line-31"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >|]</span
+      ><span
+      >
+</span
+      ><span id="line-32"
+      ></span
+      ><span id="anExpression2"
+      ><span class="annot"
+	><span class="annottext"
+	  >anExpression2 :: ExpQ
+</span
+	  ><a href="TemplateHaskellQuasiquotes.html#anExpression2"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >anExpression2</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[|</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="hs-number"
+	>1</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-operator hs-type"
+	>+</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>round</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>pi</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >|]</span
+      ><span
+      >
+</span
+      ><span id="line-33"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-34"
+      ></span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#aType"
+	><span class="hs-identifier hs-type"
+	  >aType</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>TypeQ</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-35"
+      ></span
+      ><span id="aType"
+      ><span class="annot"
+	><span class="annottext"
+	  >aType :: TypeQ
+</span
+	  ><a href="TemplateHaskellQuasiquotes.html#aType"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >aType</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[t|</span
+      ><span
+      >
+</span
+      ><span id="line-36"
+      ></span
+      ><span
+      >    </span
+      ><span class="hs-special"
+      >[</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Double</span
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>String</span
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >]</span
+      ><span
+      >
+</span
+      ><span id="line-37"
+      ></span
+      ><span
+      >  </span
+      ><span class="hs-special"
+      >|]</span
+      ><span
+      >
+</span
+      ><span id="line-38"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-39"
+      ></span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#typedExpr1"
+	><span class="hs-identifier hs-type"
+	  >typedExpr1</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Code</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Q</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-40"
+      ></span
+      ><span id="typedExpr1"
+      ><span class="annot"
+	><span class="annottext"
+	  >typedExpr1 :: Code Q ()
+</span
+	  ><a href="TemplateHaskellQuasiquotes.html#typedExpr1"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >typedExpr1</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[||</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >||]</span
+      ><span
+      >
+</span
+      ><span id="line-41"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-42"
+      ></span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#typedExpr"
+	><span class="hs-identifier hs-type"
+	  >typedExpr</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Code</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Q</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-43"
+      ></span
+      ><span id="typedExpr"
+      ><span class="annot"
+	><span class="annottext"
+	  >typedExpr :: Code Q ()
+</span
+	  ><a href="TemplateHaskellQuasiquotes.html#typedExpr"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >typedExpr</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >[||</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>a -&gt; b -&gt; a
+forall a b. a -&gt; b -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>const</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >$$</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Code Q ()
+</span
+	><a href="TemplateHaskellQuasiquotes.html#typedExpr1"
+	><span class="hs-identifier hs-var"
+	  >typedExpr1</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >||]</span
+      ><span
+      >
+</span
+      ><span id="line-44"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-45"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-46"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-47"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/TemplateHaskellSplices.html b/utils/haddock/hypsrc-test/ref/src/TemplateHaskellSplices.html
new file mode 100644
index 0000000000000000000000000000000000000000..ea0fa87bb5c297e13c20bebe79bdd9aef3ea6b4a
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/TemplateHaskellSplices.html
@@ -0,0 +1,240 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE TemplateHaskell #-}</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="TemplateHaskellSplices.html"
+	><span class="hs-identifier"
+	  >TemplateHaskellSplices</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span class="hs-keyword"
+      >import</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html"
+	><span class="hs-identifier"
+	  >TemplateHaskellQuasiquotes</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span class="hs-special"
+      >$</span
+      ><span id="bar"
+      ><span class="hs-special"
+	>(</span
+	><span class="hs-identifier"
+	>aDecl</span
+	><span class="hs-special"
+	>)</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span id="foo"
+      ><span class="annot"
+	><span class="annottext"
+	  >foo :: Integer
+</span
+	  ><a href="TemplateHaskellSplices.html#foo"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Integer -&gt; Integer
+forall a. a -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>id</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >$</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#anExpression2"
+	><span class="hs-identifier hs-type"
+	  >anExpression2</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span id="pat"
+      ><span class="annot"
+	><span class="annottext"
+	  >pat :: [(a, String)] -&gt; ()
+</span
+	  ><a href="TemplateHaskellSplices.html#pat"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >pat</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >$</span
+      ><span id=""
+      ><span id=""
+	><span id=""
+	  ><span id=""
+	    ><span id=""
+	      ><span id=""
+		><span class="hs-special"
+		  >(</span
+		  ><span class="annot"
+		  ><a href="TemplateHaskellQuasiquotes.html#aPattern"
+		    ><span class="hs-identifier hs-type"
+		      >aPattern</span
+		      ></a
+		    ></span
+		  ><span class="hs-special"
+		  >)</span
+		  ></span
+		></span
+	      ></span
+	    ></span
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span id="qux"
+      ><span class="annot"
+	><span class="annottext"
+	  >qux :: ()
+</span
+	  ><a href="TemplateHaskellSplices.html#qux"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >qux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>() -&gt; ()
+forall a. a -&gt; a
+</span
+	><span class="hs-identifier hs-var"
+	>id</span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >$$</span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="TemplateHaskellQuasiquotes.html#typedExpr"
+	><span class="hs-identifier hs-type"
+	  >typedExpr</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/Types.html b/utils/haddock/hypsrc-test/ref/src/Types.html
new file mode 100644
index 0000000000000000000000000000000000000000..3c19744c4a9791382736c06c96d7b05424af80e9
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/Types.html
@@ -0,0 +1,1341 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE TypeFamilies #-}</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html"
+	><span class="hs-identifier"
+	  >Types</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-8"
+      ></span
+      ><span class="hs-keyword"
+      >data</span
+      ><span
+      > </span
+      ><span id="Quux"
+      ><span class="annot"
+	><a href="Types.html#Quux"
+	  ><span class="hs-identifier hs-var"
+	    >Quux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span id="Bar"
+      ><span class="annot"
+	><a href="Types.html#Bar"
+	  ><span class="hs-identifier hs-var"
+	    >Bar</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >|</span
+      ><span
+      > </span
+      ><span id="Baz"
+      ><span class="annot"
+	><a href="Types.html#Baz"
+	  ><span class="hs-identifier hs-var"
+	    >Baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-9"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-10"
+      ></span
+      ><span class="hs-keyword"
+      >newtype</span
+      ><span
+      > </span
+      ><span id="Foo"
+      ><span class="annot"
+	><a href="Types.html#Foo"
+	  ><span class="hs-identifier hs-var"
+	    >Foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span id="Foo"
+      ><span class="annot"
+	><a href="Types.html#Foo"
+	  ><span class="hs-identifier hs-var"
+	    >Foo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-12"
+      ></span
+      ><span class="hs-keyword"
+      >type</span
+      ><span
+      > </span
+      ><span id="FooQuux"
+      ><span class="annot"
+	><a href="Types.html#FooQuux"
+	  ><span class="hs-identifier hs-var"
+	    >FooQuux</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-13"
+      ></span
+      ><span class="hs-keyword"
+      >type</span
+      ><span
+      > </span
+      ><span id="QuuxFoo"
+      ><span class="annot"
+	><a href="Types.html#QuuxFoo"
+	  ><span class="hs-identifier hs-var"
+	    >QuuxFoo</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-14"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-15"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-16"
+      ></span
+      ><span class="hs-keyword"
+      >data</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >family</span
+      ><span
+      > </span
+      ><span id="Norf"
+      ><span class="annot"
+	><a href="Types.html#Norf"
+	  ><span class="hs-identifier hs-var"
+	    >Norf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-17"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-18"
+      ></span
+      ><span class="hs-keyword"
+      >data</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >instance</span
+      ><span
+      > </span
+      ><span id="Norf"
+      ><span class="annot"
+	><a href="Types.html#Norf"
+	  ><span class="hs-identifier hs-var"
+	    >Norf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span id="NFQ"
+      ><span class="annot"
+	><a href="Types.html#NFQ"
+	  ><span class="hs-identifier hs-var"
+	    >NFQ</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-19"
+      ></span
+      ><span class="hs-keyword"
+      >data</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >instance</span
+      ><span
+      > </span
+      ><span id="Norf"
+      ><span class="annot"
+	><a href="Types.html#Norf"
+	  ><span class="hs-identifier hs-var"
+	    >Norf</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span id="NQF"
+      ><span class="annot"
+	><a href="Types.html#NQF"
+	  ><span class="hs-identifier hs-var"
+	    >NQF</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-20"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-21"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-22"
+      ></span
+      ><span class="hs-keyword"
+      >type</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >family</span
+      ><span
+      > </span
+      ><span id="Norf%27"
+      ><span class="annot"
+	><a href="Types.html#Norf%27"
+	  ><span class="hs-identifier hs-var"
+	    >Norf'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >a</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span id=""
+      ><span class="annot"
+	><a href="#"
+	  ><span class="hs-identifier hs-type"
+	    >b</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-23"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-24"
+      ></span
+      ><span class="hs-keyword"
+      >type</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >instance</span
+      ><span
+      > </span
+      ><span id="Norf%27"
+      ><span class="annot"
+	><a href="Types.html#Norf%27"
+	  ><span class="hs-identifier hs-var"
+	    >Norf'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-25"
+      ></span
+      ><span class="hs-keyword"
+      >type</span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >instance</span
+      ><span
+      > </span
+      ><span id="Norf%27"
+      ><span class="annot"
+	><a href="Types.html#Norf%27"
+	  ><span class="hs-identifier hs-var"
+	    >Norf'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      >
+</span
+      ><span id="line-26"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-27"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-28"
+      ></span
+      ><span class="annot"
+      ><a href="Types.html#norf1"
+	><span class="hs-identifier hs-type"
+	  >norf1</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Norf"
+	><span class="hs-identifier hs-type"
+	  >Norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-29"
+      ></span
+      ><span id="norf1"
+      ><span class="annot"
+	><span class="annottext"
+	  >norf1 :: Norf Foo Quux -&gt; Int
+</span
+	  ><a href="Types.html#norf1"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >norf1</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#NFQ"
+	><span class="hs-identifier hs-type"
+	  >NFQ</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Quux
+</span
+	><a href="Types.html#Bar"
+	><span class="hs-identifier hs-var"
+	  >Bar</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-30"
+      ></span
+      ><span class="annot"
+      ><a href="Types.html#norf1"
+	><span class="hs-identifier hs-var"
+	  >norf1</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#NFQ"
+	><span class="hs-identifier hs-type"
+	  >NFQ</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Quux
+</span
+	><a href="Types.html#Baz"
+	><span class="hs-identifier hs-var"
+	  >Baz</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>1</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-31"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-32"
+      ></span
+      ><span class="annot"
+      ><a href="Types.html#norf2"
+	><span class="hs-identifier hs-type"
+	  >norf2</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Norf"
+	><span class="hs-identifier hs-type"
+	  >Norf</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-33"
+      ></span
+      ><span id="norf2"
+      ><span class="annot"
+	><span class="annottext"
+	  >norf2 :: Norf Quux Foo -&gt; Int
+</span
+	  ><a href="Types.html#norf2"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >norf2</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#NQF"
+	><span class="hs-identifier hs-type"
+	  >NQF</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Quux
+</span
+	><a href="Types.html#Bar"
+	><span class="hs-identifier hs-var"
+	  >Bar</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-34"
+      ></span
+      ><span class="annot"
+      ><a href="Types.html#norf2"
+	><span class="hs-identifier hs-var"
+	  >norf2</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#NQF"
+	><span class="hs-identifier hs-type"
+	  >NQF</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Quux
+</span
+	><a href="Types.html#Baz"
+	><span class="hs-identifier hs-var"
+	  >Baz</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>1</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-35"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-36"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-37"
+      ></span
+      ><span class="annot"
+      ><a href="Types.html#norf1%27"
+	><span class="hs-identifier hs-type"
+	  >norf1'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Norf%27"
+	><span class="hs-identifier hs-type"
+	  >Norf'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-38"
+      ></span
+      ><span id="norf1%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >norf1' :: Norf' Foo Quux -&gt; Int
+</span
+	  ><a href="Types.html#norf1%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >norf1'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Quux
+</span
+	><a href="Types.html#Bar"
+	><span class="hs-identifier hs-var"
+	  >Bar</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-39"
+      ></span
+      ><span class="annot"
+      ><a href="Types.html#norf1%27"
+	><span class="hs-identifier hs-var"
+	  >norf1'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Quux
+</span
+	><a href="Types.html#Baz"
+	><span class="hs-identifier hs-var"
+	  >Baz</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>1</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-40"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-41"
+      ></span
+      ><span class="annot"
+      ><a href="Types.html#norf2%27"
+	><span class="hs-identifier hs-type"
+	  >norf2'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >::</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Norf%27"
+	><span class="hs-identifier hs-type"
+	  >Norf'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Quux"
+	><span class="hs-identifier hs-type"
+	  >Quux</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >-&gt;</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="hs-identifier hs-type"
+	>Int</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-42"
+      ></span
+      ><span id="norf2%27"
+      ><span class="annot"
+	><span class="annottext"
+	  >norf2' :: Norf' Quux Foo -&gt; Int
+</span
+	  ><a href="Types.html#norf2%27"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >norf2'</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Quux
+</span
+	><a href="Types.html#Bar"
+	><span class="hs-identifier hs-var"
+	  >Bar</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>0</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-43"
+      ></span
+      ><span class="annot"
+      ><a href="Types.html#norf2%27"
+	><span class="hs-identifier hs-var"
+	  >norf2'</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="annot"
+      ><span class="annottext"
+	>Quux
+</span
+	><a href="Types.html#Baz"
+	><span class="hs-identifier hs-var"
+	  >Baz</span
+	  ></a
+	></span
+      ><span class="hs-special"
+      >,</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Types.html#Foo"
+	><span class="hs-identifier hs-type"
+	  >Foo</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-special"
+      >(</span
+      ><span class="hs-special"
+      >)</span
+      ><span class="hs-special"
+      >)</span
+      ><span
+      > </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>Int
+</span
+	><span class="hs-number"
+	>1</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-44"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/ref/src/UsingQuasiquotes.html b/utils/haddock/hypsrc-test/ref/src/UsingQuasiquotes.html
new file mode 100644
index 0000000000000000000000000000000000000000..ae1d669d088a8270d05732accf4797b693175fa9
--- /dev/null
+++ b/utils/haddock/hypsrc-test/ref/src/UsingQuasiquotes.html
@@ -0,0 +1,121 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><link rel="stylesheet" type="text/css" href="style.css"
+     /><script type="text/javascript" src="highlight.js"
+    ></script
+    ></head
+  ><body
+  ><pre
+    ><span class="hs-pragma"
+      >{-# LANGUAGE Haskell2010 #-}</span
+      ><span
+      >
+</span
+      ><span id="line-2"
+      ></span
+      ><span class="hs-pragma"
+      >{-# LANGUAGE QuasiQuotes #-}</span
+      ><span
+      >
+</span
+      ><span id="line-3"
+      ></span
+      ><span class="hs-keyword"
+      >module</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="UsingQuasiquotes.html"
+	><span class="hs-identifier"
+	  >UsingQuasiquotes</span
+	  ></a
+	></span
+      ><span
+      > </span
+      ><span class="hs-keyword"
+      >where</span
+      ><span
+      >
+</span
+      ><span id="line-4"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-5"
+      ></span
+      ><span class="hs-keyword"
+      >import</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><a href="Quasiquoter.html"
+	><span class="hs-identifier"
+	  >Quasiquoter</span
+	  ></a
+	></span
+      ><span
+      >
+</span
+      ><span id="line-6"
+      ></span
+      ><span
+      >
+</span
+      ><span id="line-7"
+      ></span
+      ><span id="baz"
+      ><span class="annot"
+	><span class="annottext"
+	  >baz :: [Char]
+</span
+	  ><a href="UsingQuasiquotes.html#baz"
+	  ><span class="hs-identifier hs-var hs-var"
+	    >baz</span
+	    ></a
+	  ></span
+	></span
+      ><span
+      >  </span
+      ><span class="hs-glyph"
+      >=</span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Char]
+</span
+	><span class=""
+	>[string| foo bar |]</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Char] -&gt; [Char] -&gt; [Char]
+forall a. [a] -&gt; [a] -&gt; [a]
+</span
+	><span class="hs-operator hs-var"
+	>++</span
+	></span
+      ><span
+      > </span
+      ><span class="annot"
+      ><span class="annottext"
+	>[Char]
+</span
+	><span class=""
+	>[string| some
+  mulitline
+  quasiquote
+|]</span
+	></span
+      ><span
+      >
+</span
+      ><span id="line-11"
+      ></span
+      ></pre
+    ></body
+  ></html
+>
diff --git a/utils/haddock/hypsrc-test/run b/utils/haddock/hypsrc-test/run
new file mode 100755
index 0000000000000000000000000000000000000000..3e72be809736d303b1a9c9fabc65d7ae7a177683
--- /dev/null
+++ b/utils/haddock/hypsrc-test/run
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+export HADDOCK_PATH=$(which haddock)
+LIB_PATH="$(dirname "$BASH_SOURCE")/../haddock-test/src/"
+MAIN_PATH="$(dirname "$BASH_SOURCE")/Main.hs"
+runhaskell -i:"$LIB_PATH" $MAIN_PATH $@
diff --git a/utils/haddock/hypsrc-test/src/Bug1091.hs b/utils/haddock/hypsrc-test/src/Bug1091.hs
new file mode 100644
index 0000000000000000000000000000000000000000..013acbbc8b89df3a36c7968d8ed5525931294a85
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Bug1091.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE CPP #-}
+module Bug1091 where
+
+#include "Include1For1091.h"
diff --git a/utils/haddock/hypsrc-test/src/CPP.hs b/utils/haddock/hypsrc-test/src/CPP.hs
new file mode 100644
index 0000000000000000000000000000000000000000..59cb603470d35a800e4c3e80a847eaaa097997ab
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/CPP.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE CPP #-}
+module CPP where
+
+#define SOMETHING1
+
+foo :: String
+foo = {-  " single quotes are fine in block comments
+          {- nested block comments are fine -}
+       -} "foo"
+
+#define SOMETHING2
+
+bar :: String
+bar = "block comment in a string is not a comment {- "
+
+#define SOMETHING3
+
+-- " single quotes are fine in line comments
+-- {- unclosed block comments are fine in line comments
+
+-- Multiline CPP is also fine
+#define FOO\
+  1
+
+baz :: String
+baz = "line comment in a string is not a comment --"
diff --git a/utils/haddock/hypsrc-test/src/Classes.hs b/utils/haddock/hypsrc-test/src/Classes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..0f2416de1127ec0f86a0cd1086383fc334209aab
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Classes.hs
@@ -0,0 +1,39 @@
+{-# LANGUAGE Haskell2010 #-}
+module Classes where
+
+
+class Foo a where
+    bar :: a -> Int
+    baz :: Int -> (a, a)
+
+instance Foo Int where
+    bar = id
+    baz x = (x, x)
+
+instance Foo [a] where
+    bar = length
+    baz _ = ([], [])
+
+
+class Foo a => Foo' a where
+    quux :: (a, a) -> a
+    quux (x, y) = norf [x, y]
+
+    norf :: [a] -> a
+    norf = quux . baz . sum . map bar
+
+instance Foo' Int where
+    norf = sum
+
+instance Foo' [a] where
+    quux = uncurry (++)
+
+
+class Plugh p where
+    plugh :: p a a -> p b b -> p (a -> b) (b -> a)
+
+instance Plugh Either where
+    plugh (Left a) _ = Right $ const a
+    plugh (Right a) _ = Right $ const a
+    plugh _ (Left b) = Left $ const b
+    plugh _ (Right b) = Left $ const b
diff --git a/utils/haddock/hypsrc-test/src/Constructors.hs b/utils/haddock/hypsrc-test/src/Constructors.hs
new file mode 100644
index 0000000000000000000000000000000000000000..66260ee8998fec134da2bf7adf5a2d974890b78a
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Constructors.hs
@@ -0,0 +1,36 @@
+{-# LANGUAGE Haskell2010 #-}
+module Constructors where
+
+
+data Foo
+    = Bar
+    | Baz
+    | Quux Foo Int
+
+newtype Norf = Norf (Foo, [Foo], Foo)
+
+
+bar, baz, quux :: Foo
+bar = Bar
+baz = Baz
+quux = Quux quux 0
+
+
+unfoo :: Foo -> Int
+unfoo Bar = 0
+unfoo Baz = 0
+unfoo (Quux foo n) = 42 * n + unfoo foo
+
+
+unnorf :: Norf -> [Foo]
+unnorf (Norf (Bar, xs, Bar)) = xs
+unnorf (Norf (Baz, xs, Baz)) = reverse xs
+unnorf _ = undefined
+
+
+unnorf' :: Norf -> Int
+unnorf' x@(Norf (f1@(Quux _ n), _, f2@(Quux f3 _))) =
+    x' + n * unfoo f1 + aux f3
+  where
+    aux fx = unfoo f2 * unfoo fx * unfoo f3
+    x' = sum . map unfoo . unnorf $ x
diff --git a/utils/haddock/hypsrc-test/src/Identifiers.hs b/utils/haddock/hypsrc-test/src/Identifiers.hs
new file mode 100644
index 0000000000000000000000000000000000000000..72853a4a700c31e505a7ba9b66ddc24cddbd8395
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Identifiers.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE Haskell2010 #-}
+module Identifiers where
+
+
+foo, bar, baz :: Int -> Int -> Int
+foo x y = x + x * bar y x * y + y
+bar x y = y + x - baz x y - x + y
+baz x y = x * y * y * y * x
+
+quux :: Int -> Int
+quux x = foo (bar x x) (bar x x)
+
+norf :: Int -> Int -> Int -> Int
+norf x y z
+    | x < 0 = quux x
+    | y < 0 = quux y
+    | z < 0 = quux z
+    | otherwise = norf (-x) (-y) (-z)
+
+
+main :: IO ()
+main = do
+    putStrLn . show $ foo x y
+    putStrLn . show $ quux z
+    putStrLn . show $ Identifiers.norf x y z
+  where
+    x = 10
+    y = 20
+    z = 30
diff --git a/utils/haddock/hypsrc-test/src/Include1For1091.h b/utils/haddock/hypsrc-test/src/Include1For1091.h
new file mode 100644
index 0000000000000000000000000000000000000000..32854b958a7d2b3d1b545ceb797260fcd8f62404
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Include1For1091.h
@@ -0,0 +1,6 @@
+/* Include1For1091.h */
+
+foo :: Int
+foo = 42
+
+#include "Include2For1091.h"
diff --git a/utils/haddock/hypsrc-test/src/Include2For1091.h b/utils/haddock/hypsrc-test/src/Include2For1091.h
new file mode 100644
index 0000000000000000000000000000000000000000..c0848fa9c2f9a8dd2dd82c1fb3ce856b0402f525
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Include2For1091.h
@@ -0,0 +1,4 @@
+/* Include2For1091.h */
+
+bar :: Int
+bar = 27
diff --git a/utils/haddock/hypsrc-test/src/LinkingIdentifiers.hs b/utils/haddock/hypsrc-test/src/LinkingIdentifiers.hs
new file mode 100644
index 0000000000000000000000000000000000000000..068ac5420d947cddca5392bbf28288f76bd98c3b
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/LinkingIdentifiers.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE Haskell2010 #-}
+-- Tests that the identifiers/operators are properly linked even when:
+--
+--   * backquoted, parenthesized, vanilla
+--   * qualified, not-qualified
+--
+module LinkingIdentifiers where
+
+ident :: Int -> Int -> Int
+x `ident` 2 = (x `ident` 2) + (x `LinkingIdentifiers.ident` 2)
+ident x 2 = ident x 2 + LinkingIdentifiers.ident x 2
+
+(++:++) :: Int -> Int -> Int
+x ++:++ 2 = (x ++:++ 2) + (x LinkingIdentifiers.++:++ 2)
+(++:++) x 2 = (++:++) x 2 + (LinkingIdentifiers.++:++) x 2
diff --git a/utils/haddock/hypsrc-test/src/Literals.hs b/utils/haddock/hypsrc-test/src/Literals.hs
new file mode 100644
index 0000000000000000000000000000000000000000..d862bf87b3f2fe5c037f69c29eae4fa16d142e7f
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Literals.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE Haskell2010 #-}
+module Literals where
+
+
+str :: String
+str = "str literal"
+
+num :: Num a => a
+num = 0 + 1 + 1010011 * 41231 + 12131
+
+frac :: Fractional a => a
+frac = 42.0000001
+
+list :: [[[[a]]]]
+list = [[], [[]], [[[]]]]
+
+pair :: ((), ((), (), ()), ())
+pair = ((), ((), (), ()), ())
diff --git a/utils/haddock/hypsrc-test/src/Operators.hs b/utils/haddock/hypsrc-test/src/Operators.hs
new file mode 100644
index 0000000000000000000000000000000000000000..82c4da04c9cb7d34ec92864d709551afdb48b2a1
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Operators.hs
@@ -0,0 +1,21 @@
+{-# LANGUAGE Haskell2010 #-}
+module Operators where
+
+(+++) :: [a] -> [a] -> [a]
+a +++ b = a ++ b ++ a
+
+($$$) :: [a] -> [a] -> [a]
+a $$$ b = b +++ a
+
+(***) :: [a] -> [a] -> [a]
+(***) a [] = a
+(***) a (_:b) = a +++ (a *** b)
+
+(*/\*) :: [[a]] -> [a] -> [a]
+a */\* b = concatMap (*** b) a
+
+(**/\**) :: [[a]] -> [[a]] -> [[a]]
+a **/\** b = zipWith (*/\*) [a +++ b] (a $$$ b)
+
+(#.#) :: a -> b -> (c -> (a, b))
+a #.# b = const (a, b)
diff --git a/utils/haddock/hypsrc-test/src/Polymorphism.hs b/utils/haddock/hypsrc-test/src/Polymorphism.hs
new file mode 100644
index 0000000000000000000000000000000000000000..dfcb37fa2649092d414143e1a31bf10f0fcd476b
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Polymorphism.hs
@@ -0,0 +1,67 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
+
+module Polymorphism where
+
+
+foo :: a -> a -> a
+foo = undefined
+
+foo' :: forall a. a -> a -> a
+foo' = undefined
+
+bar :: a -> b -> (a, b)
+bar = undefined
+
+bar' :: forall a b. a -> b -> (a, b)
+bar' = undefined
+
+baz :: a -> (a -> [a -> a] -> b) -> b
+baz = undefined
+
+baz' :: forall a b. a -> (a -> [a -> a] -> b) -> b
+baz' = undefined
+
+quux :: a -> (forall a. a -> a) -> a
+quux x f = f x
+
+quux' :: forall a. a -> (forall a. a -> a) -> a
+quux' x f = f x
+
+
+num :: Num a => a -> a -> a
+num = undefined
+
+num' :: forall a. Num a => a -> a -> a
+num' = undefined
+
+eq :: (Eq a, Eq b) => [a] -> [b] -> (a, b)
+eq = undefined
+
+eq' :: forall a b. (Eq a, Eq b) => [a] -> [b] -> (a, b)
+eq' = undefined
+
+mon :: Monad m => (a -> m a) -> m a
+mon = undefined
+
+mon' :: forall m a. Monad m => (a -> m a) -> m a
+mon' = undefined
+
+
+norf :: a -> (forall a. Ord a => a -> a) -> a
+norf x f = x
+
+norf' :: forall a. a -> (forall a. Ord a => a -> a) -> a
+norf' x f = x
+
+
+plugh :: forall a. a -> a
+plugh x = x :: a
+
+thud :: forall a b. (a -> b) -> a -> (a, b)
+thud f x =
+    (x :: a, y) :: (a, b)
+  where
+    y = (f :: a -> b) x :: b
diff --git a/utils/haddock/hypsrc-test/src/PositionPragmas.hs b/utils/haddock/hypsrc-test/src/PositionPragmas.hs
new file mode 100644
index 0000000000000000000000000000000000000000..d6985341b30913c38aabfe49aadfb834e20deb44
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/PositionPragmas.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LINE 4 "hypsrc-test/src/PositionPragmas.hs" #-}
+module PositionPragmas where
+
+{-# LINE 8 "hypsrc-test/src/PositionPragmas.hs" #-}
+
+foo :: String
+foo = bar
+
+{-# LINE 23 "hypsrc-test/src/PositionPragmas.hs" #-}
+
+bar :: String
+bar = foo 
+
diff --git a/utils/haddock/hypsrc-test/src/Quasiquoter.hs b/utils/haddock/hypsrc-test/src/Quasiquoter.hs
new file mode 100644
index 0000000000000000000000000000000000000000..48f1b155efad2d35c12d2b0246d3be590a117f90
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Quasiquoter.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE Haskell2010 #-}
+module Quasiquoter ( string ) where
+
+import Language.Haskell.TH.Quote
+import Language.Haskell.TH.Syntax
+
+-- | Quoter for constructing multiline string literals
+string :: QuasiQuoter
+string = QuasiQuoter
+  { quoteExp = pure . LitE . StringL
+  , quotePat = invalidDomain
+  , quoteType = invalidDomain
+  , quoteDec = invalidDomain
+  }
+  where
+    invalidDomain :: String -> Q a
+    invalidDomain _ = fail "stringQuoter: only valid in expression context"
diff --git a/utils/haddock/hypsrc-test/src/Records.hs b/utils/haddock/hypsrc-test/src/Records.hs
new file mode 100644
index 0000000000000000000000000000000000000000..ae5a0c5560c9e3ae287eb2335736c7427bcdbb80
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Records.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE NamedFieldPuns #-}
+{-# LANGUAGE RecordWildCards #-}
+
+
+module Records where
+
+
+data Point = Point
+    { x :: !Int
+    , y :: !Int
+    }
+
+
+point :: Int -> Int -> Point
+point x y = Point { x = x, y = y }
+
+
+lengthSqr :: Point -> Int
+lengthSqr (Point { x = x, y = y }) = x * x + y * y
+
+lengthSqr' :: Point -> Int
+lengthSqr' (Point { x, y }) = y * y + x * x
+
+
+translateX, translateY :: Point -> Int -> Point
+translateX p d = p { x = x p + d }
+translateY p d = p { y = y p + d }
+
+translate :: Int -> Int -> Point -> Point
+translate x y p =
+    aux p
+  where
+    (dx, dy) = (x, y)
+    aux Point{..} = p { x = x + dx, y = y + dy }
diff --git a/utils/haddock/hypsrc-test/src/TemplateHaskellQuasiquotes.hs b/utils/haddock/hypsrc-test/src/TemplateHaskellQuasiquotes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c94983208265368bf51a533420ab7f8867bfba1c
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/TemplateHaskellQuasiquotes.hs
@@ -0,0 +1,46 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+module TemplateHaskellQuasiquotes where
+
+import Language.Haskell.TH
+
+aDecl :: DecsQ
+aDecl = [d|
+    bar :: $aType -> [ (Int, String) ]
+    bar $aPattern = $anExpression
+  |]
+
+aPattern :: PatQ
+aPattern = [p|
+    [ aCrazyLongVariableName
+    , _unused
+    , (y, z)
+    , ( $aNumberPattern, "hello")
+    ]
+  |]
+
+aNumberPattern :: PatQ
+aNumberPattern = [p|
+    w@v@4.5
+  |]
+
+anExpression, anExpression2 :: ExpQ
+anExpression = [e|
+    [ (1 + $anExpression2, "world") ]
+  |]
+anExpression2 = [| (1 + round pi) |]
+
+aType :: TypeQ
+aType = [t|
+    [ (Double, String) ]
+  |]
+
+typedExpr1 :: Code Q ()
+typedExpr1 = [|| () ||]
+
+typedExpr :: Code Q ()
+typedExpr = [|| const $$(typedExpr1) () ||]
+
+
+
diff --git a/utils/haddock/hypsrc-test/src/TemplateHaskellSplices.hs b/utils/haddock/hypsrc-test/src/TemplateHaskellSplices.hs
new file mode 100644
index 0000000000000000000000000000000000000000..66af36a39310cbe7cbc979d19957d7da6b312c89
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/TemplateHaskellSplices.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TemplateHaskell #-}
+module TemplateHaskellSplices where
+
+import TemplateHaskellQuasiquotes
+
+$(aDecl)
+
+foo = id $(anExpression2)
+
+pat $(aPattern) = ()
+
+qux = id $$(typedExpr)
diff --git a/utils/haddock/hypsrc-test/src/Types.hs b/utils/haddock/hypsrc-test/src/Types.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a0481e82e7121104722ee5ba664d5895ef9d5942
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/Types.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies #-}
+
+
+module Types where
+
+
+data Quux = Bar | Baz
+
+newtype Foo = Foo ()
+
+type FooQuux = (Foo, Quux)
+type QuuxFoo = (Quux, Foo)
+
+
+data family Norf a b
+
+data instance Norf Foo Quux = NFQ Foo Quux
+data instance Norf Quux Foo = NQF Quux Foo
+
+
+type family Norf' a b
+
+type instance Norf' Foo Quux = (Foo, Quux)
+type instance Norf' Quux Foo = (Quux, Foo)
+
+
+norf1 :: Norf Foo Quux -> Int
+norf1 (NFQ (Foo ()) Bar) = 0
+norf1 (NFQ (Foo ()) Baz) = 1
+
+norf2 :: Norf Quux Foo -> Int
+norf2 (NQF Bar (Foo ())) = 0
+norf2 (NQF Baz (Foo ())) = 1
+
+
+norf1' :: Norf' Foo Quux -> Int
+norf1' (Foo (), Bar) = 0
+norf1' (Foo (), Baz) = 1
+
+norf2' :: Norf' Quux Foo -> Int
+norf2' (Bar, Foo ()) = 0
+norf2' (Baz, Foo ()) = 1
diff --git a/utils/haddock/hypsrc-test/src/UsingQuasiquotes.hs b/utils/haddock/hypsrc-test/src/UsingQuasiquotes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..44da0c4bd854cd1a700a39dee7501057a1943520
--- /dev/null
+++ b/utils/haddock/hypsrc-test/src/UsingQuasiquotes.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE QuasiQuotes #-}
+module UsingQuasiquotes where
+
+import Quasiquoter
+
+baz  = [string| foo bar |] ++ [string| some
+  mulitline
+  quasiquote
+|]
diff --git a/utils/haddock/latex-test/Main.hs b/utils/haddock/latex-test/Main.hs
new file mode 100755
index 0000000000000000000000000000000000000000..17ae8ae84bd69d8bdce2ff52e7a185321fb9d887
--- /dev/null
+++ b/utils/haddock/latex-test/Main.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE CPP #-}
+
+
+import Data.Function
+import System.Environment
+import System.FilePath
+
+import Test.Haddock
+import Test.Haddock.Utils
+
+
+checkConfig :: CheckConfig String
+checkConfig = CheckConfig
+    { ccfgRead = Just
+    , ccfgClean = \_ -> id
+    , ccfgDump = id
+    , ccfgEqual = (==) `on` crlfToLf
+    }
+
+
+dirConfig :: DirConfig
+dirConfig = (defaultDirConfig $ takeDirectory __FILE__)
+  { dcfgCheckIgnore = (`elem` ["haddock.sty", "main.tex"]) . takeFileName
+  }
+
+
+main :: IO ()
+main = do
+    cfg <- parseArgs checkConfig dirConfig =<< getArgs
+    runAndCheck $ cfg
+        { cfgHaddockArgs = cfgHaddockArgs cfg ++ ["--latex"]
+        }
diff --git a/utils/haddock/latex-test/ref/ConstructorArgs/ConstructorArgs.tex b/utils/haddock/latex-test/ref/ConstructorArgs/ConstructorArgs.tex
new file mode 100644
index 0000000000000000000000000000000000000000..b7870fa99a23229b27d76458e9b33ff5e71ce70e
--- /dev/null
+++ b/utils/haddock/latex-test/ref/ConstructorArgs/ConstructorArgs.tex
@@ -0,0 +1,71 @@
+\haddockmoduleheading{ConstructorArgs}
+\label{module:ConstructorArgs}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module ConstructorArgs (
+    Foo((:|), Rec, x, y, Baz, Boa, (:*)), Boo(Foo, Foa, Fo, Fo'), pattern Bo,
+    pattern Bo'
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data Foo
+\end{tabular}]
+{\haddockbegindoc
+\enspace \emph{Constructors}\par
+\haddockbeginconstrs
+\haddockdecltt{=} & \haddockdecltt{Rec} & doc on a record \\
+                                          & \haddocktt{\qquad \{} \haddockdecltt{x :: String} & doc on the \haddockid{String} field of \haddockid{Rec} \\
+                                          & \haddocktt{\qquad ,} \haddockdecltt{y :: String} & doc on the \haddockid{String} field of \haddockid{Rec} \\ & \haddocktt{\qquad \}} \\
+\haddockdecltt{|} & \haddockdecltt{Baz Int String} & old prefix doc style \\
+\haddockdecltt{|} & \haddockdecltt{Boa} & doc on the \haddockid{Boa} constrictor \\
+                                          & \qquad \haddockdecltt{!Int} & doc on the \haddockid{Int} field of \haddockid{Boa} \\
+                                          & \qquad \haddockdecltt{!String} & doc on the \haddockid{String} field of \haddockid{Boa} \\
+\haddockdecltt{|} & \haddockdecltt{Int :| String} & old infix doc style \\
+\haddockdecltt{|} & \haddockdecltt{(:*)} & doc on the \haddockid{:*} constructor \\
+                                           & \qquad \haddockdecltt{Int} & doc on the \haddockid{Int} field of the \haddockid{:*} constructor \\
+                                           & \qquad \haddockdecltt{String} & doc on the \haddockid{String} field of the \haddockid{:*} constructor \\
+\end{tabulary}\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data Boo where
+\end{tabular}]
+{\haddockbegindoc
+\enspace \emph{Constructors}\par
+\haddockbeginconstrs
+& \haddockdecltt{Foo} & Info about a \haddockid{Foo} \\
+                        & \qquad \haddockdecltt{::} \enspace \haddockdecltt{Int} & \haddockid{Int} field of \haddockid{Foo} \\
+                        & \qquad \haddockdecltt{->} \enspace \haddockdecltt{String} & \haddockid{String} field of \haddockid{Foo} \\
+                        & \qquad \haddockdecltt{->} \enspace \haddockdecltt{Boo} & Make a \haddockid{Boo} \\
+& \haddockdecltt{Foa :: Int -> Boo} & no argument docs GADT \\
+\end{tabulary}\par
+\enspace \emph{Bundled Patterns}\par
+\haddockbeginconstrs
+& \haddockdecltt{pattern Fo} & Info about bundled \haddockid{Fo} \\
+                               & \qquad \haddockdecltt{::} \enspace \haddockdecltt{Int} & an \haddockid{Int} \\
+                               & \qquad \haddockdecltt{->} \enspace \haddockdecltt{String} & a \haddockid{String} \\
+                               & \qquad \haddockdecltt{->} \enspace \haddockdecltt{Boo} & a \haddockid{Boo} \\
+& \haddockdecltt{pattern Fo' :: Boo} & Bundled and no argument docs \\
+\end{tabulary}\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+pattern Bo
+\end{tabular}]
+{\haddockbegindoc
+\haddockbeginargs
+\haddockdecltt{::} & \haddockdecltt{Int} & an \haddockid{Int} \\
+\haddockdecltt{->} & \haddockdecltt{String} & a \haddockid{String} \\
+\haddockdecltt{->} & \haddockdecltt{Boo} & a \haddockid{Boo} pattern \\
+\end{tabulary}\par
+Info about not-bundled \haddockid{Bo}\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+pattern Bo' :: Int -> String -> Boo
+\end{tabular}]
+{\haddockbegindoc
+Not bunded and no argument docs\par}
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/DefaultSignatures/DefaultSignatures.tex b/utils/haddock/latex-test/ref/DefaultSignatures/DefaultSignatures.tex
new file mode 100644
index 0000000000000000000000000000000000000000..161320835d59bf716a159259781cc10557216198
--- /dev/null
+++ b/utils/haddock/latex-test/ref/DefaultSignatures/DefaultSignatures.tex
@@ -0,0 +1,48 @@
+\haddockmoduleheading{DefaultSignatures}
+\label{module:DefaultSignatures}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module DefaultSignatures (
+    Foo(baz', baz, bar)
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+class Foo a where
+\end{tabular}]
+{\haddockbegindoc
+Documentation for Foo.\par
+\haddockpremethods{}\emph{Methods}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+bar :: a -> String
+\end{tabular}]
+{\haddockbegindoc
+Documentation for bar and baz.\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+default bar :: Show a => a -> String
+\end{tabular}]
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+baz :: a -> String
+\end{tabular}]
+{\haddockbegindoc
+Documentation for bar and baz.\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+baz' :: String -> a
+\end{tabular}]
+{\haddockbegindoc
+Documentation for baz'.\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+default baz' :: Read a => String -> a
+\end{tabular}]
+\end{haddockdesc}}
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/Deprecated/Deprecated.tex b/utils/haddock/latex-test/ref/Deprecated/Deprecated.tex
new file mode 100644
index 0000000000000000000000000000000000000000..0ae2410b0c50cf7d916d92863c013f234237c2ef
--- /dev/null
+++ b/utils/haddock/latex-test/ref/Deprecated/Deprecated.tex
@@ -0,0 +1,17 @@
+\haddockmoduleheading{Deprecated}
+\label{module:Deprecated}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module Deprecated (
+    deprecated
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+deprecated :: Int
+\end{tabular}]
+{\haddockbegindoc
+Deprecated: Don't use this\par
+Docs for something deprecated\par}
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/Example/Example.tex b/utils/haddock/latex-test/ref/Example/Example.tex
new file mode 100644
index 0000000000000000000000000000000000000000..11f7e734955cd637b8f5b2758cffaa8e04b6f016
--- /dev/null
+++ b/utils/haddock/latex-test/ref/Example/Example.tex
@@ -0,0 +1,30 @@
+\haddockmoduleheading{Example}
+\label{module:Example}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module Example (
+    split
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+split :: Int -> ()
+\end{tabular}]
+{\haddockbegindoc
+Example use.\par
+\begin{quote}
+{\haddockverb\begin{verbatim}
+>>> split 1
+()
+
+\end{verbatim}}
+\end{quote}
+\begin{quote}
+{\haddockverb\begin{verbatim}
+>>> split 2
+()
+
+\end{verbatim}}
+\end{quote}}
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/GadtConstructorArgs/GadtConstructorArgs.tex b/utils/haddock/latex-test/ref/GadtConstructorArgs/GadtConstructorArgs.tex
new file mode 100644
index 0000000000000000000000000000000000000000..e5b2123df106f3ac78b3033bff47f9e686218b0b
--- /dev/null
+++ b/utils/haddock/latex-test/ref/GadtConstructorArgs/GadtConstructorArgs.tex
@@ -0,0 +1,26 @@
+\haddockmoduleheading{GadtConstructorArgs}
+\label{module:GadtConstructorArgs}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module GadtConstructorArgs (
+    Boo(Fot, x, y, Fob, w, z)
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data Boo where
+\end{tabular}]
+{\haddockbegindoc
+\enspace \emph{Constructors}\par
+\haddockbeginconstrs
+& \haddockdecltt{Fot} & \\
+                        & \qquad \haddockdecltt{:: {\char '173}} \enspace \haddockdecltt{x :: Int} & an \haddockid{x} \\
+                        & \qquad \haddockdecltt{\ \ \ \ ,} \enspace \haddockdecltt{y :: Int} & a \haddockid{y} \\
+                        & \qquad \haddockdecltt{\ \ \ \ {\char '175} ->} \enspace \haddockdecltt{Boo} & \\
+& \haddockdecltt{Fob} & Record GADT with docs \\
+                        & \qquad \haddockdecltt{:: {\char '173}} \enspace \haddockdecltt{w :: Int} & a \haddockid{w} \\
+                        & \qquad \haddockdecltt{\ \ \ \ ,} \enspace \haddockdecltt{z :: Int} & a \haddockid{z} \\
+                        & \qquad \haddockdecltt{\ \ \ \ {\char '175} ->} \enspace \haddockdecltt{Boo} & a \haddockid{Boo} \\
+\end{tabulary}\par}
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/LinearTypes/LinearTypes.tex b/utils/haddock/latex-test/ref/LinearTypes/LinearTypes.tex
new file mode 100644
index 0000000000000000000000000000000000000000..c2eefe1a8731ed74a7a8e85c0c6d8a23f3f03a3a
--- /dev/null
+++ b/utils/haddock/latex-test/ref/LinearTypes/LinearTypes.tex
@@ -0,0 +1,30 @@
+\haddockmoduleheading{LinearTypes}
+\label{module:LinearTypes}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module LinearTypes (
+    unrestricted, linear, poly
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+unrestricted :: a -> b
+\end{tabular}]
+{\haddockbegindoc
+Does something unrestricted.\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+linear :: a {\char '45}1 -> b
+\end{tabular}]
+{\haddockbegindoc
+Does something linear.\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+poly :: forall a (m :: Multiplicity) b. a {\char '45}m -> b
+\end{tabular}]
+{\haddockbegindoc
+Does something polymorphic.\par}
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/LinearTypes/haddock.sty b/utils/haddock/latex-test/ref/LinearTypes/haddock.sty
new file mode 100644
index 0000000000000000000000000000000000000000..6e031a98b61441ec5feec8830c46504e560b78cf
--- /dev/null
+++ b/utils/haddock/latex-test/ref/LinearTypes/haddock.sty
@@ -0,0 +1,57 @@
+% Default Haddock style definitions.  To use your own style, invoke
+% Haddock with the option --latex-style=mystyle.
+
+\usepackage{tabulary} % see below
+
+% make hyperlinks in the PDF, and add an expandabale index
+\usepackage[pdftex,bookmarks=true]{hyperref}
+
+\newenvironment{haddocktitle}
+  {\begin{center}\bgroup\large\bfseries}
+  {\egroup\end{center}}
+\newenvironment{haddockprologue}{\vspace{1in}}{}
+
+\newcommand{\haddockmoduleheading}[1]{\chapter{\texttt{#1}}}
+
+\newcommand{\haddockbeginheader}{\hrulefill}
+\newcommand{\haddockendheader}{\noindent\hrulefill}
+
+% a little gap before the ``Methods'' header
+\newcommand{\haddockpremethods}{\vspace{2ex}}
+
+% inserted before \\begin{verbatim}
+\newcommand{\haddockverb}{\small}
+
+% an identifier: add an index entry
+\newcommand{\haddockid}[1]{\haddocktt{#1}\index{#1@\texttt{#1}}}
+
+% The tabulary environment lets us have a column that takes up ``the
+% rest of the space''.  Unfortunately it doesn't allow
+% the \end{tabulary} to be in the expansion of a macro, it must appear
+% literally in the document text, so Haddock inserts
+% the \end{tabulary} itself.
+\newcommand{\haddockbeginconstrs}{\begin{tabulary}{\linewidth}{@{}llJ@{}}}
+\newcommand{\haddockbeginargs}{\begin{tabulary}{\linewidth}{@{}llJ@{}}}
+
+\newcommand{\haddocktt}[1]{{\small \texttt{#1}}}
+\newcommand{\haddockdecltt}[1]{{\small\bfseries \texttt{#1}}}
+
+\makeatletter
+\newenvironment{haddockdesc}
+               {\list{}{\labelwidth\z@ \itemindent-\leftmargin
+                        \let\makelabel\haddocklabel}}
+               {\endlist}
+\newcommand*\haddocklabel[1]{\hspace\labelsep\haddockdecltt{#1}}
+\makeatother
+
+% after a declaration, start a new line for the documentation.
+% Otherwise, the documentation starts right after the declaration,
+% because we're using the list environment and the declaration is the
+% ``label''.  I tried making this newline part of the label, but
+% couldn't get that to work reliably (the space seemed to stretch
+% sometimes).
+\newcommand{\haddockbegindoc}{\hfill\\[1ex]}
+
+% spacing between paragraphs and no \parindent looks better
+\parskip=10pt plus2pt minus2pt
+\setlength{\parindent}{0cm}
diff --git a/utils/haddock/latex-test/ref/LinearTypes/main.tex b/utils/haddock/latex-test/ref/LinearTypes/main.tex
new file mode 100644
index 0000000000000000000000000000000000000000..655261c3987c185c1f9f29c33da0a6f8988a504d
--- /dev/null
+++ b/utils/haddock/latex-test/ref/LinearTypes/main.tex
@@ -0,0 +1,11 @@
+\documentclass{book}
+\usepackage{haddock}
+\begin{document}
+\begin{titlepage}
+\begin{haddocktitle}
+
+\end{haddocktitle}
+\end{titlepage}
+\tableofcontents
+\input{LinearTypes}
+\end{document}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/NamespacedIdentifier/NamespacedIdentifiers.tex b/utils/haddock/latex-test/ref/NamespacedIdentifier/NamespacedIdentifiers.tex
new file mode 100644
index 0000000000000000000000000000000000000000..44c052c616cd3cbf78904d896d420930846c5e50
--- /dev/null
+++ b/utils/haddock/latex-test/ref/NamespacedIdentifier/NamespacedIdentifiers.tex
@@ -0,0 +1,37 @@
+\haddockmoduleheading{NamespacedIdentifiers}
+\label{module:NamespacedIdentifiers}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module NamespacedIdentifiers (
+    Foo(Bar), Bar
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data Foo
+\end{tabular}]
+{\haddockbegindoc
+A link to:\par
+\vbox{\begin{itemize}
+\item
+the type \haddockid{Bar}\par
+\item
+the constructor \haddockid{Bar}\par
+\item
+the unimported but qualified type \haddockid{A}\par
+\item
+the unimported but qualified value \haddockid{A}\par
+\end{itemize}}
+\enspace \emph{Constructors}\par
+\haddockbeginconstrs
+\haddockdecltt{=} & \haddockdecltt{Bar} & \\
+\end{tabulary}\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data Bar
+\end{tabular}]
+{\haddockbegindoc
+A link to the value \haddocktt{Foo} (which shouldn't exist).\par}
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/Simple/Simple.tex b/utils/haddock/latex-test/ref/Simple/Simple.tex
new file mode 100644
index 0000000000000000000000000000000000000000..96e9338a9fbe95e13f9d736d87410259e7efbee4
--- /dev/null
+++ b/utils/haddock/latex-test/ref/Simple/Simple.tex
@@ -0,0 +1,16 @@
+\haddockmoduleheading{Simple}
+\label{module:Simple}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module Simple (
+    foo
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+foo :: t
+\end{tabular}]
+{\haddockbegindoc
+This is foo.\par}
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/TypeFamilies3/TypeFamilies3.tex b/utils/haddock/latex-test/ref/TypeFamilies3/TypeFamilies3.tex
new file mode 100644
index 0000000000000000000000000000000000000000..6ceb36864af0a1601d7cdc7b1826375b01b09c81
--- /dev/null
+++ b/utils/haddock/latex-test/ref/TypeFamilies3/TypeFamilies3.tex
@@ -0,0 +1,44 @@
+\haddockmoduleheading{TypeFamilies3}
+\label{module:TypeFamilies3}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module TypeFamilies3 (
+    Foo, Bar, Baz(Baz3, Baz2, Baz1)
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+type family Foo a where
+\end{tabular}]
+{\haddockbegindoc
+\haddockbeginargs
+\haddockdecltt{Foo () = Int} \\
+\haddockdecltt{Foo {\char '137}1 = ()} \\
+\end{tabulary}\par
+A closed type family\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+type family Bar a
+\end{tabular}]
+{\haddockbegindoc
+An open family\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+type instance Bar () = Int\\type instance Bar Int = ()
+\end{tabular}]
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data family Baz a
+\end{tabular}]
+{\haddockbegindoc
+A data family\par}
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data instance Baz ()\\newtype instance Baz Double\\data instance Baz Int
+\end{tabular}]
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/ref/UnboxedStuff/UnboxedStuff.tex b/utils/haddock/latex-test/ref/UnboxedStuff/UnboxedStuff.tex
new file mode 100644
index 0000000000000000000000000000000000000000..990d2a5be93cd9f29d3ca9e6b997ff7f0c76921d
--- /dev/null
+++ b/utils/haddock/latex-test/ref/UnboxedStuff/UnboxedStuff.tex
@@ -0,0 +1,36 @@
+\haddockmoduleheading{UnboxedStuff}
+\label{module:UnboxedStuff}
+\haddockbeginheader
+{\haddockverb\begin{verbatim}
+module UnboxedStuff (
+    X, Y, Z, unboxedUnit, unboxedTuple, unboxedSum
+  ) where\end{verbatim}}
+\haddockendheader
+
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data X
+\end{tabular}]
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data Y
+\end{tabular}]
+\end{haddockdesc}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+data Z
+\end{tabular}]
+\end{haddockdesc}
+\section{Unboxed type constructors}
+\begin{haddockdesc}
+\item[\begin{tabular}{@{}l}
+unboxedUnit :: ({\char '43} {\char '43}) -> ({\char '43} {\char '43})
+\end{tabular}]
+\item[\begin{tabular}{@{}l}
+unboxedTuple :: ({\char '43} X, Y {\char '43}) -> ({\char '43} X, Y, Z {\char '43})
+\end{tabular}]
+\item[\begin{tabular}{@{}l}
+unboxedSum :: ({\char '43} X | Y {\char '43}) -> ({\char '43} X | Y | Z {\char '43})
+\end{tabular}]
+\end{haddockdesc}
\ No newline at end of file
diff --git a/utils/haddock/latex-test/run b/utils/haddock/latex-test/run
new file mode 100755
index 0000000000000000000000000000000000000000..3e72be809736d303b1a9c9fabc65d7ae7a177683
--- /dev/null
+++ b/utils/haddock/latex-test/run
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+export HADDOCK_PATH=$(which haddock)
+LIB_PATH="$(dirname "$BASH_SOURCE")/../haddock-test/src/"
+MAIN_PATH="$(dirname "$BASH_SOURCE")/Main.hs"
+runhaskell -i:"$LIB_PATH" $MAIN_PATH $@
diff --git a/utils/haddock/latex-test/src/ConstructorArgs/ConstructorArgs.hs b/utils/haddock/latex-test/src/ConstructorArgs/ConstructorArgs.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c3b848c39b5bf7fcf652c2f20fec5a9b4e7bf1bd
--- /dev/null
+++ b/utils/haddock/latex-test/src/ConstructorArgs/ConstructorArgs.hs
@@ -0,0 +1,57 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE GADTs, PatternSynonyms #-}
+
+module ConstructorArgs (Foo(..), Boo(Foo, Foa, Fo, Fo'), pattern Bo, pattern Bo') where
+
+data Foo
+  = Rec             -- ^ doc on a record
+     { x :: String  -- ^ doc on the `String` field of `Rec`
+     , y :: String  -- ^ doc on the `String` field of `Rec`
+     }
+   | Baz Int String  -- ^ old prefix doc style
+   | Boa             -- ^ doc on the `Boa` constrictor
+       !Int          -- ^ doc on the `Int` field of `Boa`
+       !String       -- ^ doc on the `String` field of `Boa`
+   | Int :| String   -- ^ old infix doc style
+   | Int             -- ^ doc on the `Int` field of the `:*` constructor
+       :*            -- ^ doc on the `:*` constructor
+     String          -- ^ doc on the `String` field of the `:*` constructor
+
+infixr 1 `Foo`
+infixr 2 `Boa`
+infixr 3 :*
+
+data Boo where
+  -- | Info about a 'Foo'
+  Foo :: Int    -- ^ `Int` field of `Foo`
+      -> String -- ^ `String` field of `Foo`
+      -> Boo    -- ^ Make a `Boo`
+
+  -- | no argument docs GADT
+  Foa :: Int -> Boo
+
+infixr 4 `Boo`
+
+-- | Info about bundled 'Fo'
+pattern Fo :: Int    -- ^ an 'Int'
+           -> String -- ^ a 'String'
+           -> Boo    -- ^ a 'Boo'
+pattern Fo x y = Foo x y
+
+-- | Bundled and no argument docs
+pattern Fo' :: Boo
+pattern Fo' = Foo 1 "hi"
+
+infixr 5 `Fo`
+
+-- | Info about not-bundled 'Bo'
+pattern Bo :: Int    -- ^ an 'Int'
+           -> String -- ^ a 'String'
+           -> Boo -- ^ a 'Boo' pattern
+pattern Bo x y = Foo x y
+
+-- | Not bunded and no argument docs
+pattern Bo' :: Int -> String -> Boo
+pattern Bo' x y = Foo x y
+
+infixr 6 `Bo`
diff --git a/utils/haddock/latex-test/src/DefaultSignatures/DefaultSignatures.hs b/utils/haddock/latex-test/src/DefaultSignatures/DefaultSignatures.hs
new file mode 100644
index 0000000000000000000000000000000000000000..1b1b8257011606b8e08b20be84d9f931bf7c7108
--- /dev/null
+++ b/utils/haddock/latex-test/src/DefaultSignatures/DefaultSignatures.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE DefaultSignatures #-}
+
+module DefaultSignatures where
+
+-- | Documentation for Foo.
+class Foo a where
+  -- | Documentation for bar and baz.
+  bar, baz :: a -> String
+
+  -- | Documentation for the default signature of bar.
+  default bar :: Show a => a -> String
+  bar = show
+
+  -- | Documentation for baz'.
+  baz' :: String -> a
+
+  -- | Documentation for the default signature of baz'.
+  default baz' :: Read a => String -> a
+  baz' = read
diff --git a/utils/haddock/latex-test/src/Deprecated/Deprecated.hs b/utils/haddock/latex-test/src/Deprecated/Deprecated.hs
new file mode 100644
index 0000000000000000000000000000000000000000..bf7755c671d26499eb8f4bbdf49994df109d3b26
--- /dev/null
+++ b/utils/haddock/latex-test/src/Deprecated/Deprecated.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Haskell2010 #-}
+module Deprecated where
+
+-- | Docs for something deprecated
+deprecated :: Int
+deprecated = 1
+
+{-# DEPRECATED deprecated "Don't use this" #-}
diff --git a/utils/haddock/latex-test/src/Example/Example.hs b/utils/haddock/latex-test/src/Example/Example.hs
new file mode 100644
index 0000000000000000000000000000000000000000..932fddfac81016540430c553104bb6b9f48065ae
--- /dev/null
+++ b/utils/haddock/latex-test/src/Example/Example.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Haskell2010 #-}
+module Example where
+
+-- | Example use.
+--
+-- >>> split 1
+-- ()
+--
+-- >>> split 2
+-- ()
+split :: Int -> ()
+split _ = ()
diff --git a/utils/haddock/latex-test/src/GadtConstructorArgs/GadtConstructorArgs.hs b/utils/haddock/latex-test/src/GadtConstructorArgs/GadtConstructorArgs.hs
new file mode 100644
index 0000000000000000000000000000000000000000..50ff93cc22939816b449412a2eacb8bab27c4f19
--- /dev/null
+++ b/utils/haddock/latex-test/src/GadtConstructorArgs/GadtConstructorArgs.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE GADTs #-}
+
+module GadtConstructorArgs (Boo(..)) where
+
+data Boo where
+  Fot :: { x :: Int  -- ^ an 'x'
+         , y :: Int  -- ^ a 'y'
+         } -> Boo
+
+  -- | Record GADT with docs
+  Fob :: { w :: Int  -- ^ a 'w'
+         , z :: Int  -- ^ a 'z'
+         } -> Boo    -- ^ a 'Boo'
diff --git a/utils/haddock/latex-test/src/LinearTypes/LinearTypes.hs b/utils/haddock/latex-test/src/LinearTypes/LinearTypes.hs
new file mode 100644
index 0000000000000000000000000000000000000000..c4f9c84fd6347e48de3eff12588ce2886166d5cb
--- /dev/null
+++ b/utils/haddock/latex-test/src/LinearTypes/LinearTypes.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE LinearTypes #-}
+module LinearTypes where
+
+-- | Does something unrestricted.
+unrestricted :: a -> b
+unrestricted = undefined
+
+-- | Does something linear.
+linear :: a %1 -> b
+linear = linear
+
+-- | Does something polymorphic.
+poly :: a %m -> b
+poly = poly
diff --git a/utils/haddock/latex-test/src/NamespacedIdentifier/NamespacedIdentifier.hs b/utils/haddock/latex-test/src/NamespacedIdentifier/NamespacedIdentifier.hs
new file mode 100644
index 0000000000000000000000000000000000000000..38fb710138044bbfb03788a91e844d5a90715f1c
--- /dev/null
+++ b/utils/haddock/latex-test/src/NamespacedIdentifier/NamespacedIdentifier.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Haskell2010 #-}
+module NamespacedIdentifiers where
+
+-- | A link to:
+--
+--   * the type t'Bar'
+--   * the constructor v'Bar'
+--   * the unimported but qualified type t'A.A'
+--   * the unimported but qualified value v'A.A'
+--
+data Foo = Bar
+
+-- | A link to the value v'Foo' (which shouldn't exist).
+data Bar
diff --git a/utils/haddock/latex-test/src/Simple/Simple.hs b/utils/haddock/latex-test/src/Simple/Simple.hs
new file mode 100644
index 0000000000000000000000000000000000000000..d1c7cf6d363df022d16d3acd81d14674e1997011
--- /dev/null
+++ b/utils/haddock/latex-test/src/Simple/Simple.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE Haskell2010 #-}
+module Simple (foo) where
+
+-- | This is foo.
+foo :: t
+foo = undefined
diff --git a/utils/haddock/latex-test/src/TypeFamilies3/TypeFamilies3.hs b/utils/haddock/latex-test/src/TypeFamilies3/TypeFamilies3.hs
new file mode 100644
index 0000000000000000000000000000000000000000..80279e365876fc649e66aac34954e80a142fd17c
--- /dev/null
+++ b/utils/haddock/latex-test/src/TypeFamilies3/TypeFamilies3.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE TypeFamilies #-}
+
+module TypeFamilies3 where
+
+-- | A closed type family
+type family Foo a where
+  Foo () = Int
+  Foo _ = ()
+
+-- | An open family
+type family Bar a
+
+type instance Bar Int = ()
+type instance Bar () = Int
+
+-- | A data family
+data family Baz a
+
+data instance Baz () = Baz1
+data instance Baz Int = Baz2 Bool
+newtype instance Baz Double = Baz3 Float
diff --git a/utils/haddock/latex-test/src/UnboxedStuff/UnboxedStuff.hs b/utils/haddock/latex-test/src/UnboxedStuff/UnboxedStuff.hs
new file mode 100644
index 0000000000000000000000000000000000000000..dfeb7429b6ff00b92dd5e37bfaab92bc11119e19
--- /dev/null
+++ b/utils/haddock/latex-test/src/UnboxedStuff/UnboxedStuff.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE UnboxedSums, UnboxedTuples #-}
+module UnboxedStuff where
+
+data X
+data Y
+data Z
+
+-- * Unboxed type constructors
+
+unboxedUnit :: (# #) -> (# #)
+unboxedUnit  = undefined
+
+unboxedTuple :: (# X, Y #) -> (# X, Y, Z #)
+unboxedTuple = undefined 
+
+unboxedSum :: (# X | Y #) -> (# X | Y | Z #)
+unboxedSum = undefined 
+