packages feed

haddock-api 2.20.0 → 2.21.0

raw patch · 24 files changed

+1780/−1301 lines, 24 filesdep ~Cabaldep ~basedep ~ghc

Dependency ranges changed: Cabal, base, ghc, haddock-library, hspec

Files

haddock-api.cabal view
@@ -1,13 +1,13 @@ cabal-version:        2.0 name:                 haddock-api-version:              2.20.0+version:              2.21.0 synopsis:             A documentation-generation tool for Haskell libraries description:          Haddock is a documentation-generation tool for Haskell                       libraries license:              BSD3 license-file:         LICENSE author:               Simon Marlow, David Waern-maintainer:           Alex Biehl <alexbiehl@gmail.com>, Simon Hengel <sol@typeful.net>, Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>+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@@ -40,11 +40,11 @@   default-language: Haskell2010    -- this package typically supports only single major versions-  build-depends: base            ^>= 4.11.0-               , Cabal           ^>= 2.2.0-               , ghc             ^>= 8.4.2+  build-depends: base            ^>= 4.12.0+               , Cabal           ^>= 2.4.0+               , ghc             ^>= 8.6                , ghc-paths       ^>= 0.1.0.9-               , haddock-library ^>= 1.6.0+               , haddock-library ^>= 1.7.0                , xhtml           ^>= 3000.2.2    -- Versions for the dependencies below are transitively pinned by@@ -166,12 +166,12 @@     Haddock.Backends.Hyperlinker.Parser     Haddock.Backends.Hyperlinker.Types -  build-depends: Cabal           ^>= 2.2.0-               , ghc             ^>= 8.4.2+  build-depends: Cabal           ^>= 2.4+               , ghc             ^>= 8.6                , ghc-paths       ^>= 0.1.0.9-               , haddock-library ^>= 1.6.0+               , haddock-library ^>= 1.7.0                , xhtml           ^>= 3000.2.2-               , hspec           ^>= 2.4.4+               , hspec           >= 2.4.4 && < 2.6                , QuickCheck      ^>= 2.11    -- Versions for the dependencies below are transitively pinned by@@ -188,7 +188,7 @@                , transformers    build-tool-depends:-    hspec-discover:hspec-discover ^>= 2.4.4+    hspec-discover:hspec-discover >= 2.4.4 && < 2.6  source-repository head   type:     git
resources/html/haddock-bundle.min.js view
@@ -1,2 +1,2 @@-!function e(t,n,o){function r(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return r(n||e)},u,u.exports,e,t,n,o)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({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";function o(e){var t=d[e];if(void 0==t)throw new Error("could not find <details> element with id '"+e+"'");return t}function r(e){for(var t=e.target,n=t.id,r=o(n),i=r.element.open,s=0,l=r.toggles;s<l.length;s++){var c=l[s];c.classList.contains("details-toggle-control")&&(c.classList.add(i?"collapser":"expander"),c.classList.remove(i?"expander":"collapser"))}t.open==r.openByDefault?delete p[n]:p[n]=!0,a()}function i(){for(var e=0,t=Array.prototype.slice.call(document.getElementsByTagName("details"));e<t.length;e++){var n=t[e];"string"==typeof n.id&&n.id.length>0&&(d[n.id]={element:n,openByDefault:!!n.open,toggles:[]},n.addEventListener("toggle",r))}}function s(e){var t=o(e).element;t.open=!t.open}function a(){var e=Object.keys(p);document.cookie="toggled="+encodeURIComponent(e.join("+"))}function l(){var e=h.getCookie("toggled");if(e)for(var t=0,n=e.split("+");t<n.length;t++){var o=n[t],r=d[o];p[o]=!0,r&&(r.element.open=!r.element.open)}}function c(e){e.preventDefault();var t=e.currentTarget.getAttribute("data-details-id");if(!t)throw new Error("element with class 'details-toggle' has no 'data-details-id' attribute!");s(t)}function u(){Array.prototype.slice.call(document.getElementsByClassName("details-toggle")).forEach(function(e){var t=e.getAttribute("data-details-id");if(!t)throw new Error("element with class 'details-toggle' has no 'data-details-id' attribute!");var n=o(t);n.toggles.push(e),e.addEventListener("click",c),e.classList.contains("details-toggle-control")&&e.classList.add(n.element.open?"collapser":"expander")})}Object.defineProperty(n,"__esModule",{value:!0});var h=e("./cookies"),d={},p={};n.init=function(){i(),l(),u()}},{"./cookies":1}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e("./style-menu"),r=e("./details-helper"),i=e("./quick-jump");!function(e){"interactive"===document.readyState?e():document.addEventListener("readystatechange",function(){"interactive"===document.readyState&&e()})}(function(){document.body.classList.add("js-enabled"),o.init(),r.init(),i.init()})},{"./details-helper":2,"./quick-jump":4,"./style-menu":5}],4:[function(e,t,n){"use strict";function o(e,t,n){var o=new XMLHttpRequest;o.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()}function r(e){var t=document.querySelector("#page-menu"),n=document.createElement("li");t.insertBefore(n,t.firstChild),d.render(p(v,{onClick:e,title:"Quick Jump"}),t,n)}function i(e,t){return t.length<=e?t:t.slice(0,e)}function s(){return p("table",{class:"keyboard-shortcuts"},p("tr",null,p("th",null,"Key"),p("th",null,"Shortcut")),p("tr",null,p("td",null,p("span",{class:"key"},"s")),p("td",null,"Open this search box")),p("tr",null,p("td",null,p("span",{class:"key"},"esc")),p("td",null,"Close this search box")),p("tr",null,p("td",null,p("span",{class:"key"},"↓"),",",p("span",{class:"key"},"ctrl")," + ",p("span",{class:"key"},"j")),p("td",null,"Move down in search results")),p("tr",null,p("td",null,p("span",{class:"key"},"↑"),",",p("span",{class:"key"},"ctrl")," + ",p("span",{class:"key"},"k")),p("td",null,"Move up in search results")),p("tr",null,p("td",null,p("span",{class:"key"},"↵")),p("td",null,"Go to active search result")))}function a(){return p("p",null,"You can find any exported type, constructor, class, function or pattern defined in this package by (approximate) name.")}function l(e){var t=[p("p",null,"Your search for '",e.searchString,"' produced the following list of results: ",p("code",null,"[]"),"."),p("p",null,p("code",null,"Nothing")," matches your query for '",e.searchString,"'."),p("p",null,p("code",null,"Left \"no matches for '",e.searchString,"'\" :: Either String (NonEmpty SearchResult)"))];return t[(e.searchString||"a").charCodeAt(0)%t.length]}function c(e,t){d.render(p(g,{baseUrl:e||".",showHideTrigger:t||r}),document.body)}var u=this&&this.__extends||function(){var e=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])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();Object.defineProperty(n,"__esModule",{value:!0});var h=e("fuse.js"),d=e("preact"),p=d.h,f=d.Component,v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(e){return p("li",null,p("a",{href:"#",onClick:function(t){t.preventDefault(),e.onClick()}},e.title))},t}(f),g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linkIndex=0,t.focusPlease=!1,t.navigatedByKeyboard=!1,t}return u(t,e),t.prototype.componentWillMount=function(){var e=this;this.setState({searchString:"",isVisible:!1,expanded:{},activeLinkIndex:-1,moduleResults:[]}),o(this.props.baseUrl+"/doc-index.json",function(t){e.setState({fuse:new h(t,{threshold:.25,caseSensitive:!0,includeScore:!0,tokenize:!0,keys:[{name:"name",weight:.7},{name:"module",weight:.3}]}),moduleResults:[]})},function(t){console&&console.error("could not load 'doc-index.json' for searching",t),e.setState({failedLoading:!0})}),document.addEventListener("mousedown",this.hide.bind(this)),document.addEventListener("keydown",function(t){e.state.isVisible&&("Escape"===t.key?e.hide():"ArrowUp"===t.key||"k"===t.key&&t.ctrlKey?(t.preventDefault(),e.navigateLinks(-1)):"ArrowDown"===t.key||"j"===t.key&&t.ctrlKey?(t.preventDefault(),e.navigateLinks(1)):"Enter"===t.key&&e.state.activeLinkIndex>=0&&e.followActiveLink()),"s"===t.key&&"input"!==t.target.tagName.toLowerCase()&&(t.preventDefault(),e.show())})},t.prototype.hide=function(){this.setState({isVisible:!1})},t.prototype.show=function(){this.state.isVisible||(this.focusPlease=!0,this.setState({isVisible:!0,activeLinkIndex:-1}))},t.prototype.toggleVisibility=function(){this.state.isVisible?this.hide():this.show()},t.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})},t.prototype.followActiveLink=function(){this.activeLinkAction&&this.activeLinkAction()},t.prototype.updateResults=function(){var e=this.input&&this.input.value||"",t={};this.state.fuse.search(e).forEach(function(e){var n=e.item.module;(t[n]||(t[n]=[])).push(e)});var n=[];for(var o in t)!function(e){var o=t[e],r=0;o.forEach(function(e){r+=1/e.score}),n.push({module:e,totalScore:1/r,items:o})}(o);n.sort(function(e,t){return e.totalScore-t.totalScore}),this.setState({searchString:e,isVisible:!0,moduleResults:n})},t.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},t.prototype.componentDidMount=function(){this.props.showHideTrigger(this.toggleVisibility.bind(this))},t.prototype.render=function(e,t){var n=this;if(t.failedLoading){var o="file:"==window.location.protocol;return p("div",{id:"search",class:t.isVisible?"":"hidden"},p("div",{id:"search-results"},p("p",{class:"error"},"Failed to load file 'doc-index.json' containing definitions in this package."),o?p("p",{class:"error"},"To use quick jump, load this page with HTTP (from a local static file web server) instead of using the ",p("code",null,"file://")," protocol. (For security reasons, it is not possible to fetch auxiliary files using JS in a HTML page opened with ",p("code",null,"file://"),".)"):[]))}this.linkIndex=0;var r=function(e){e.stopPropagation()},c=i(10,t.moduleResults).map(function(e){return n.renderResultsInModule(e)});return p("div",{id:"search",class:t.isVisible?"":"hidden"},p("div",{id:"search-form",onMouseDown:r},p("input",{placeholder:"Search in package by name",ref:function(e){n.input=e},onFocus:this.show.bind(this),onClick:this.show.bind(this),onInput:this.updateResults.bind(this)})),p("div",{id:"search-results",ref:function(e){n.searchResults=e},onMouseDown:r,onMouseOver:function(e){for(var t=e.target;t&&"function"==typeof t.getAttribute;){var o=t.getAttribute("data-link-index");if("string"==typeof o){var r=parseInt(o,10);n.setState({activeLinkIndex:r});break}t=t.parentNode}}},""===t.searchString?[p(a,null),p(s,null)]:0==c.length?p(l,{searchString:t.searchString}):p("ul",null,c)))},t.prototype.renderResultsInModule=function(e){var t=this,n=e.items,o=e.module,r=this.state.expanded[o]||n.length<=10,s=r?n:i(8,n),a=function(e){return p("li",{class:"search-result"},t.navigationLink(t.props.baseUrl+"/"+e.link,{},p(m,{html:e.display_html})))};return p("li",{class:"search-module"},p("h4",null,o),p("ul",null,s.map(function(e){return a(e.item)}),r?[]:p("li",{class:"more-results"},this.actionLink(function(){var e=Object.assign({},t.state.expanded);e[o]=!0,t.setState({expanded:e})},{},"show "+(n.length-s.length)+" more results from this module"))))},t.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),s=function(){window.location.href=e,n.hide()};return this.menuLink.apply(this,[i,s].concat(o))},t.prototype.actionLink=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=Object.assign({href:"#",onClick:function(t){t.preventDefault(),e()}},t);return this.menuLink.apply(this,[r,e].concat(n))},t.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,p.apply(void 0,["a",s].concat(o))},t}(f),m=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.shouldComponentUpdate=function(e){return this.props.html!==e.html},t.prototype.render=function(e){return p("div",{dangerouslySetInnerHTML:{__html:e.html}})},t}(f);n.init=c,window.quickNav={init:c}},{"fuse.js":6,preact:7}],5:[function(e,t,n){"use strict";function o(e){return(" "+e+" ").replace(g," ")}function r(e){return e.replace(m,"")}function i(e,t){return o(e.className||"").indexOf(" "+t+" ")>=0}function s(e,t){var n=o(e.className||"");n.indexOf(" "+t+" ")<0&&(e.className=r(n+" "+t))}function a(e,t){var n=o(e.className||"");n=n.replace(" "+t+" "," "),e.className=r(n)}function l(e,t,n,o){return null==o&&(o=!i(e,t)),o?(a(e,n),s(e,t)):(a(e,t),s(e,n)),o}function c(e){var t=document.getElementById("page-menu");if(t&&t.firstChild){var n=t.firstChild.cloneNode(!1);n.innerHTML=e,t.appendChild(n)}}function u(){return Array.prototype.slice.call(document.getElementsByTagName("link")).filter(function(e){return-1!=e.rel.indexOf("style")&&e.title})}function h(){var e=u(),t="";e.forEach(function(e){t+="<li><a href='#' onclick=\"setActiveStyleSheet('"+e.title+"'); return false;\">"+e.title+"</a></li>"}),e.length>1&&c("<div id='style-menu-holder'><a href='#' onclick='styleMenu(); return false;'>Style &#9662;</a><ul id='style-menu' class='hide'>"+t+"</ul></div>")}function d(e){for(var t=u(),n=null,o=0;o<t.length;o++){var r=t[o];r.disabled=!0,r.title==e&&(n=r)}n?(n.disabled=!1,v.setCookie("haddock-style",e)):(t[0].disabled=!1,v.clearCookie("haddock-style")),f(!1)}function p(){var e=v.getCookie("haddock-style");e&&d(e)}function f(e){var t=document.getElementById("style-menu");t&&y(t,e)}Object.defineProperty(n,"__esModule",{value:!0});var v=e("./cookies"),g=/\s\s+/g,m=/^\s+|\s+$/g,y=function(e,t){return function(n,o){return l(n,e,t,o)}}("show","hide");n.init=function(){h(),p()}},{"./cookies":1}],6:[function(e,t,n){!function(e,o){"object"==typeof n&&"object"==typeof t?t.exports=o():"function"==typeof define&&define.amd?define("Fuse",[],o):"object"==typeof n?n.Fuse=o():e.Fuse=o()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t,n){"use strict";e.exports=function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(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(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(5),s=n(7),a=n(4),l=function(){function e(t,n){var r=n.location,i=void 0===r?0:r,s=n.distance,l=void 0===s?100:s,c=n.threshold,u=void 0===c?.6:c,h=n.maxPatternLength,d=void 0===h?32:h,p=n.isCaseSensitive,f=void 0!==p&&p,v=n.tokenSeparator,g=void 0===v?/ +/g:v,m=n.findAllMatches,y=void 0!==m&&m,_=n.minMatchCharLength,k=void 0===_?1:_;o(this,e),this.options={location:i,distance:l,threshold:u,maxPatternLength:d,isCaseSensitive:f,tokenSeparator:g,findAllMatches:y,minMatchCharLength:k},this.pattern=this.options.isCaseSensitive?t:t.toLowerCase(),this.pattern.length<=d&&(this.patternAlphabet=a(this.pattern))}return r(e,[{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 i(e,this.pattern,o);var r=this.options,a=r.location,l=r.distance,c=r.threshold,u=r.findAllMatches,h=r.minMatchCharLength;return s(e,this.pattern,this.patternAlphabet,{location:a,distance:l,threshold:c,findAllMatches:u,minMatchCharLength:h})}}]),e}();e.exports=l},function(e,t,n){"use strict";var o=n(0),r=function e(t,n,r){if(n){var i=n.indexOf("."),s=n,a=null;-1!==i&&(s=n.slice(0,i),a=n.slice(i+1));var l=t[s];if(null!==l&&void 0!==l)if(a||"string"!=typeof l&&"number"!=typeof l)if(o(l))for(var c=0,u=l.length;c<u;c+=1)e(l[c],a,r);else a&&e(l,a,r);else r.push(l.toString())}else r.push(t);return r};e.exports=function(e,t){return r(e,t,[])}},function(e,t,n){"use strict";e.exports=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&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||((r=i-1)-o+1>=t&&n.push([o,r]),o=-1)}return e[i-1]&&i-o>=t&&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 o=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:/ +/g,r=new RegExp(t.replace(o,"\\$&").replace(n,"|")),i=e.match(r),s=!!i,a=[];if(s)for(var l=0,c=i.length;l<c;l+=1){var u=i[l];a.push([e.indexOf(u),u.length-1])}return{score:s?.5:1,isMatch:s,matchedIndices:a}}},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 o=n(6),r=n(3);e.exports=function(e,t,n,i){for(var s=i.location,a=void 0===s?0:s,l=i.distance,c=void 0===l?100:l,u=i.threshold,h=void 0===u?.6:u,d=i.findAllMatches,p=void 0!==d&&d,f=i.minMatchCharLength,v=void 0===f?1:f,g=a,m=e.length,y=h,_=e.indexOf(t,g),k=t.length,b=[],x=0;x<m;x+=1)b[x]=0;if(-1!==_){var w=o(t,{errors:0,currentLocation:_,expectedLocation:g,distance:c});if(y=Math.min(w,y),-1!==(_=e.lastIndexOf(t,g+k))){var S=o(t,{errors:0,currentLocation:_,expectedLocation:g,distance:c});y=Math.min(S,y)}}_=-1;for(var L=[],C=1,M=k+m,N=1<<k-1,I=0;I<k;I+=1){for(var A=0,O=M;A<O;)o(t,{errors:I,currentLocation:g+O,expectedLocation:g,distance:c})<=y?A=O:M=O,O=Math.floor((M-A)/2+A);M=O;var E=Math.max(1,g-O+1),T=p?m:Math.min(g+O,m)+k,j=Array(T+2);j[T+1]=(1<<I)-1;for(var P=T;P>=E;P-=1){var R=P-1,U=n[e.charAt(R)];if(U&&(b[R]=1),j[P]=(j[P+1]<<1|1)&U,0!==I&&(j[P]|=(L[P+1]|L[P])<<1|1|L[P+1]),j[P]&N&&(C=o(t,{errors:I,currentLocation:R,expectedLocation:g,distance:c}))<=y){if(y=C,(_=R)<=g)break;E=Math.max(1,2*g-_)}}if(o(t,{errors:I+1,currentLocation:g,expectedLocation:g,distance:c})>y)break;L=j}return{isMatch:_>=0,score:0===C?.001:C,matchedIndices:r(b,v)}}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(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(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(1),s=n(2),a=n(0),l=function(){function e(t,n){var r=n.location,i=void 0===r?0:r,a=n.distance,l=void 0===a?100:a,c=n.threshold,u=void 0===c?.6:c,h=n.maxPatternLength,d=void 0===h?32:h,p=n.caseSensitive,f=void 0!==p&&p,v=n.tokenSeparator,g=void 0===v?/ +/g:v,m=n.findAllMatches,y=void 0!==m&&m,_=n.minMatchCharLength,k=void 0===_?1:_,b=n.id,x=void 0===b?null:b,w=n.keys,S=void 0===w?[]:w,L=n.shouldSort,C=void 0===L||L,M=n.getFn,N=void 0===M?s:M,I=n.sortFn,A=void 0===I?function(e,t){return e.score-t.score}:I,O=n.tokenize,E=void 0!==O&&O,T=n.matchAllTokens,j=void 0!==T&&T,P=n.includeMatches,R=void 0!==P&&P,U=n.includeScore,D=void 0!==U&&U,V=n.verbose,F=void 0!==V&&V;o(this,e),this.options={location:i,distance:l,threshold:u,maxPatternLength:d,isCaseSensitive:f,tokenSeparator:g,findAllMatches:y,minMatchCharLength:k,id:x,keys:S,includeMatches:R,includeScore:D,shouldSort:C,getFn:N,sortFn:A,verbose:F,tokenize:E,matchAllTokens:j},this.setCollection(t)}return r(e,[{key:"setCollection",value:function(e){return this.list=e,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=arguments.length>0&&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=arguments.length>0&&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,d=this.options.keys.length;h<d;h+=1){var p=this.options.keys[h];if("string"!=typeof p){if(a[p.name]={weight:1-p.weight||1},p.weight<=0||p.weight>1)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,l=e.index,c=t.tokenSearchers,u=void 0===c?[]:c,h=t.fullSearcher,d=void 0===h?[]:h,p=t.resultMap,f=void 0===p?{}:p,v=t.results,g=void 0===v?[]:v;if(void 0!==i&&null!==i){var m=!1,y=-1,_=0;if("string"==typeof i){this._log("\nKey: "+(""===n?"-":n));var k=d.search(i);if(this._log('Full text: "'+i+'", score: '+k.score),this.options.tokenize){for(var b=i.split(this.options.tokenSeparator),x=[],w=0;w<u.length;w+=1){var S=u[w];this._log('\nPattern: "'+S.pattern+'"');for(var L=!1,C=0;C<b.length;C+=1){var M=b[C],N=S.search(M),I={};N.isMatch?(I[M]=N.score,m=!0,L=!0,x.push(N.score)):(I[M]=1,this.options.matchAllTokens||x.push(1)),this._log('Token: "'+M+'", score: '+I[M])}L&&(_+=1)}y=x[0];for(var A=x.length,O=1;O<A;O+=1)y+=x[O];y/=A,this._log("Token score average:",y)}var E=k.score;y>-1&&(E=(E+y)/2),this._log("Score average:",E);var T=!this.options.tokenize||!this.options.matchAllTokens||_>=u.length;if(this._log("\nCheck Matches: "+T),(m||k.isMatch)&&T){var j=f[l];j?j.output.push({key:n,arrayIndex:r,value:i,score:E,matchedIndices:k.matchedIndices}):(f[l]={item:s,output:[{key:n,arrayIndex:r,value:i,score:E,matchedIndices:k.matchedIndices}]},g.push(f[l]))}}else if(a(i))for(var P=0,R=i.length;P<R;P+=1)this._analyze({key:n,arrayIndex:P,value:i[P],record:s,index:l},{resultMap:f,results:g,tokenSearchers:u,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=0,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):(r[l].nScore=u,s+=u)}t[n].score=1===a?s/i: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._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")&&i.arrayIndex>-1&&(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(){if(this.options.verbose){var e;(e=console).log.apply(e,arguments)}}}]),e}();e.exports=l}])})},{}],7:[function(e,t,n){!function(){"use strict";function e(){}function n(t,n){var o,r,i,s,a=O;for(s=arguments.length;s-- >2;)A.push(arguments[s]);for(n&&null!=n.children&&(A.length||A.push(n.children),delete n.children);A.length;)if((r=A.pop())&&void 0!==r.pop)for(s=r.length;s--;)A.push(r[s]);else"boolean"==typeof r&&(r=null),(i="function"!=typeof t)&&(null==r?r="":"number"==typeof r?r=String(r):"string"!=typeof r&&(i=!1)),i&&o?a[a.length-1]+=r:a===O?a=[r]:a.push(r),o=i;var l=new e;return l.nodeName=t,l.children=a,l.attributes=null==n?void 0:n,l.key=null==n?void 0:n.key,void 0!==I.vnode&&I.vnode(l),l}function o(e,t){for(var n in t)e[n]=t[n];return e}function r(e){!e.__d&&(e.__d=!0)&&1==j.push(e)&&(I.debounceRendering||E)(i)}function i(){var e,t=j;for(j=[];e=t.pop();)e.__d&&L(e)}function s(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&a(e,t.nodeName):n||e._componentConstructor===t.nodeName}function a(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function l(e){var t=o({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var r in n)void 0===t[r]&&(t[r]=n[r]);return t}function c(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}function u(e){var t=e.parentNode;t&&t.removeChild(e)}function h(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===T.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,p,s):e.removeEventListener(t,p,s),(e.__l||(e.__l={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e)d(e,t,null==o?"":o),null!=o&&!1!==o||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 d(e,t,n){try{e[t]=n}catch(e){}}function p(e){return this.__l[e.type](I.event&&I.event(e)||e)}function f(){for(var e;e=P.pop();)I.afterMount&&I.afterMount(e),e.componentDidMount&&e.componentDidMount()}function v(e,t,n,o,r,i){R++||(U=null!=r&&void 0!==r.ownerSVGElement,D=null!=e&&!("__preactattr_"in e));var s=g(e,t,n,o,i);return r&&s.parentNode!==r&&r.appendChild(s),--R||(D=!1,i||f()),s}function g(e,t,n,o,r){var i=e,s=U;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),y(e,!0))),i.__preactattr_=!0,i;var l=t.nodeName;if("function"==typeof l)return C(e,t,n,o);if(U="svg"===l||"foreignObject"!==l&&U,l=String(l),(!e||!a(e,l))&&(i=c(l,U),e)){for(;e.firstChild;)i.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(i,e),y(e,!0)}var u=i.firstChild,h=i.__preactattr_,d=t.children;if(null==h){h=i.__preactattr_={};for(var p=i.attributes,f=p.length;f--;)h[p[f].name]=p[f].value}return!D&&d&&1===d.length&&"string"==typeof d[0]&&null!=u&&void 0!==u.splitText&&null==u.nextSibling?u.nodeValue!=d[0]&&(u.nodeValue=d[0]):(d&&d.length||null!=u)&&m(i,d,n,o,D||null!=h.dangerouslySetInnerHTML),k(i,t.attributes,h),U=s,i}function m(e,t,n,o,r){var i,a,l,c,h,d=e.childNodes,p=[],f={},v=0,m=0,_=d.length,k=0,b=t?t.length:0;if(0!==_)for(L=0;L<_;L++){var x=d[L],w=x.__preactattr_;null!=(S=b&&w?x._component?x._component.__k:w.key:null)?(v++,f[S]=x):(w||(void 0!==x.splitText?!r||x.nodeValue.trim():r))&&(p[k++]=x)}if(0!==b)for(L=0;L<b;L++){h=null;var S=(c=t[L]).key;if(null!=S)v&&void 0!==f[S]&&(h=f[S],f[S]=void 0,v--);else if(!h&&m<k)for(i=m;i<k;i++)if(void 0!==p[i]&&s(a=p[i],c,r)){h=a,p[i]=void 0,i===k-1&&k--,i===m&&m++;break}h=g(h,c,n,o),l=d[L],h&&h!==e&&h!==l&&(null==l?e.appendChild(h):h===l.nextSibling?u(l):e.insertBefore(h,l))}if(v)for(var L in f)void 0!==f[L]&&y(f[L],!1);for(;m<=k;)void 0!==(h=p[k--])&&y(h,!1)}function y(e,t){var n=e._component;n?M(n):(null!=e.__preactattr_&&e.__preactattr_.ref&&e.__preactattr_.ref(null),!1!==t&&null!=e.__preactattr_||u(e),_(e))}function _(e){for(e=e.lastChild;e;){var t=e.previousSibling;y(e,!0),e=t}}function k(e,t,n){var o;for(o in n)t&&null!=t[o]||null==n[o]||h(e,o,n[o],n[o]=void 0,U);for(o in t)"children"===o||"innerHTML"===o||o in n&&t[o]===("value"===o||"checked"===o?e[o]:n[o])||h(e,o,n[o],n[o]=t[o],U)}function b(e){var t=e.constructor.name;(V[t]||(V[t]=[])).push(e)}function x(e,t,n){var o,r=V[e.name];if(e.prototype&&e.prototype.render?(o=new e(t,n),N.call(o,t,n)):((o=new N(t,n)).constructor=e,o.render=w),r)for(var i=r.length;i--;)if(r[i].constructor===e){o.__b=r[i].__b,r.splice(i,1);break}return o}function w(e,t,n){return this.constructor(e,n)}function S(e,t,n,o,i){e.__x||(e.__x=!0,(e.__r=t.ref)&&delete t.ref,(e.__k=t.key)&&delete t.key,!e.base||i?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===I.syncComponentUpdates&&e.base?r(e):L(e,1,i)),e.__r&&e.__r(e))}function L(e,t,n,r){if(!e.__x){var i,s,a,c=e.props,u=e.state,h=e.context,d=e.__p||c,p=e.__s||u,g=e.__c||h,m=e.base,_=e.__b,k=m||_,b=e._component,w=!1;if(m&&(e.props=d,e.state=p,e.context=g,2!==t&&e.shouldComponentUpdate&&!1===e.shouldComponentUpdate(c,u,h)?w=!0:e.componentWillUpdate&&e.componentWillUpdate(c,u,h),e.props=c,e.state=u,e.context=h),e.__p=e.__s=e.__c=e.__b=null,e.__d=!1,!w){i=e.render(c,u,h),e.getChildContext&&(h=o(o({},h),e.getChildContext()));var C,N,A=i&&i.nodeName;if("function"==typeof A){var O=l(i);(s=b)&&s.constructor===A&&O.key==s.__k?S(s,O,1,h,!1):(C=s,e._component=s=x(A,O,h),s.__b=s.__b||_,s.__u=e,S(s,O,0,h,!1),L(s,1,n,!0)),N=s.base}else a=k,(C=b)&&(a=e._component=null),(k||1===t)&&(a&&(a._component=null),N=v(a,i,h,n||!m,k&&k.parentNode,!0));if(k&&N!==k&&s!==b){var E=k.parentNode;E&&N!==E&&(E.replaceChild(N,k),C||(k._component=null,y(k,!1)))}if(C&&M(C),e.base=N,N&&!r){for(var T=e,j=e;j=j.__u;)(T=j).base=N;N._component=T,N._componentConstructor=T.constructor}}if(!m||n?P.unshift(e):w||(e.componentDidUpdate&&e.componentDidUpdate(d,p,g),I.afterUpdate&&I.afterUpdate(e)),null!=e.__h)for(;e.__h.length;)e.__h.pop().call(e);R||r||f()}}function C(e,t,n,o){for(var r=e&&e._component,i=r,s=e,a=r&&e._componentConstructor===t.nodeName,c=a,u=l(t);r&&!c&&(r=r.__u);)c=r.constructor===t.nodeName;return r&&c&&(!o||r._component)?(S(r,u,3,n,o),e=r.base):(i&&!a&&(M(i),e=s=null),r=x(t.nodeName,u,n),e&&!r.__b&&(r.__b=e,s=null),S(r,u,1,n,o),e=r.base,s&&e!==s&&(s._component=null,y(s,!1))),e}function M(e){I.beforeUnmount&&I.beforeUnmount(e);var t=e.base;e.__x=!0,e.componentWillUnmount&&e.componentWillUnmount(),e.base=null;var n=e._component;n?M(n):t&&(t.__preactattr_&&t.__preactattr_.ref&&t.__preactattr_.ref(null),e.__b=t,u(t),b(e),_(t)),e.__r&&e.__r(null)}function N(e,t){this.__d=!0,this.context=t,this.props=e,this.state=this.state||{}}var I={},A=[],O=[],E="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout,T=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,j=[],P=[],R=0,U=!1,D=!1,V={};o(N.prototype,{setState:function(e,t){var n=this.state;this.__s||(this.__s=o({},n)),o(n,"function"==typeof e?e(n,this.props):e),t&&(this.__h=this.__h||[]).push(t),r(this)},forceUpdate:function(e){e&&(this.__h=this.__h||[]).push(e),L(this,2)},render:function(){}});var F={h:n,createElement:n,cloneElement:function(e,t){return n(e.nodeName,o(o({},e.attributes),t),arguments.length>2?[].slice.call(arguments,2):e.children)},Component:N,render:function(e,t,n){return v(n,e,{},!1,t,!1)},rerender:i,options:I};void 0!==t?t.exports=F:self.preact=F}()},{}]},{},[3]);+!function e(t,n,o){function r(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return r(n||e)},u,u.exports,e,t,n,o)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({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";function o(e){var t=d[e];if(void 0==t)throw new Error("could not find <details> element with id '"+e+"'");return t}function r(e){for(var t=e.target,n=t.id,r=o(n),i=r.element.open,s=0,l=r.toggles;s<l.length;s++){var c=l[s];c.classList.contains("details-toggle-control")&&(c.classList.add(i?"collapser":"expander"),c.classList.remove(i?"expander":"collapser"))}t.open==r.openByDefault?delete p[n]:p[n]=!0,a()}function i(){for(var e=0,t=Array.prototype.slice.call(document.getElementsByTagName("details"));e<t.length;e++){var n=t[e];"string"==typeof n.id&&n.id.length>0&&(d[n.id]={element:n,openByDefault:!!n.open,toggles:[]},n.addEventListener("toggle",r))}}function s(e){var t=o(e).element;t.open=!t.open}function a(){var e=Object.keys(p);document.cookie="toggled="+encodeURIComponent(e.join("+"))}function l(){var e=h.getCookie("toggled");if(e)for(var t=0,n=e.split("+");t<n.length;t++){var o=n[t],r=d[o];p[o]=!0,r&&(r.element.open=!r.element.open)}}function c(e){e.preventDefault();var t=e.currentTarget.getAttribute("data-details-id");if(!t)throw new Error("element with class 'details-toggle' has no 'data-details-id' attribute!");s(t)}function u(){Array.prototype.slice.call(document.getElementsByClassName("details-toggle")).forEach(function(e){var t=e.getAttribute("data-details-id");if(!t)throw new Error("element with class 'details-toggle' has no 'data-details-id' attribute!");var n=o(t);n.toggles.push(e),e.addEventListener("click",c),e.classList.contains("details-toggle-control")&&e.classList.add(n.element.open?"collapser":"expander")})}Object.defineProperty(n,"__esModule",{value:!0});var h=e("./cookies"),d={},p={};n.init=function(){i(),l(),u()}},{"./cookies":1}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e("./style-menu"),r=e("./details-helper"),i=e("./quick-jump");!function(e){"interactive"===document.readyState?e():document.addEventListener("readystatechange",function(){"interactive"===document.readyState&&e()})}(function(){document.body.classList.add("js-enabled"),o.init(),r.init(),i.init()})},{"./details-helper":2,"./quick-jump":4,"./style-menu":5}],4:[function(e,t,n){"use strict";function o(e,t,n){var o=new XMLHttpRequest;o.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()}function r(e){var t=document.querySelector("#page-menu"),n=document.createElement("li");t.insertBefore(n,t.firstChild),d.render(p(v,{onClick:e,title:"Quick Jump"}),t,n)}function i(e,t){return t.length<=e?t:t.slice(0,e)}function s(){return p("table",{class:"keyboard-shortcuts"},p("tr",null,p("th",null,"Key"),p("th",null,"Shortcut")),p("tr",null,p("td",null,p("span",{class:"key"},"s")),p("td",null,"Open this search box")),p("tr",null,p("td",null,p("span",{class:"key"},"esc")),p("td",null,"Close this search box")),p("tr",null,p("td",null,p("span",{class:"key"},"↓"),",",p("span",{class:"key"},"ctrl")," + ",p("span",{class:"key"},"j")),p("td",null,"Move down in search results")),p("tr",null,p("td",null,p("span",{class:"key"},"↑"),",",p("span",{class:"key"},"ctrl")," + ",p("span",{class:"key"},"k")),p("td",null,"Move up in search results")),p("tr",null,p("td",null,p("span",{class:"key"},"↵")),p("td",null,"Go to active search result")))}function a(){return p("p",null,"You can find any exported type, constructor, class, function or pattern defined in this package by (approximate) name.")}function l(e){var t=[p("p",null,"Your search for '",e.searchString,"' produced the following list of results: ",p("code",null,"[]"),"."),p("p",null,p("code",null,"Nothing")," matches your query for '",e.searchString,"'."),p("p",null,p("code",null,"Left \"no matches for '",e.searchString,"'\" :: Either String (NonEmpty SearchResult)"))];return t[(e.searchString||"a").charCodeAt(0)%t.length]}function c(e,t){d.render(p(g,{baseUrl:e||".",showHideTrigger:t||r}),document.body)}var u=this&&this.__extends||function(){var e=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])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();Object.defineProperty(n,"__esModule",{value:!0});var h=e("fuse.js"),d=e("preact"),p=d.h,f=d.Component,v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(e){return p("li",null,p("a",{href:"#",onClick:function(t){t.preventDefault(),e.onClick()}},e.title))},t}(f),g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linkIndex=0,t.focusPlease=!1,t.navigatedByKeyboard=!1,t}return u(t,e),t.prototype.componentWillMount=function(){var e=this;this.setState({searchString:"",isVisible:!1,expanded:{},activeLinkIndex:-1,moduleResults:[]}),o(this.props.baseUrl+"/doc-index.json",function(t){e.setState({fuse:new h(t,{threshold:.25,caseSensitive:!0,includeScore:!0,tokenize:!0,keys:[{name:"name",weight:.7},{name:"module",weight:.3}]}),moduleResults:[]})},function(t){console&&console.error("could not load 'doc-index.json' for searching",t),e.setState({failedLoading:!0})}),document.addEventListener("mousedown",this.hide.bind(this)),document.addEventListener("keydown",function(t){e.state.isVisible&&("Escape"===t.key?e.hide():"ArrowUp"===t.key||"k"===t.key&&t.ctrlKey?(t.preventDefault(),e.navigateLinks(-1)):"ArrowDown"===t.key||"j"===t.key&&t.ctrlKey?(t.preventDefault(),e.navigateLinks(1)):"Enter"===t.key&&e.state.activeLinkIndex>=0&&e.followActiveLink()),"s"===t.key&&"input"!==t.target.tagName.toLowerCase()&&(t.preventDefault(),e.show())})},t.prototype.hide=function(){this.setState({isVisible:!1,searchString:""})},t.prototype.show=function(){this.state.isVisible||(this.focusPlease=!0,this.setState({isVisible:!0,activeLinkIndex:-1}))},t.prototype.toggleVisibility=function(){this.state.isVisible?this.hide():this.show()},t.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})},t.prototype.followActiveLink=function(){this.activeLinkAction&&this.activeLinkAction()},t.prototype.updateResults=function(){var e=this.input&&this.input.value||"",t={};this.state.fuse.search(e).forEach(function(e){var n=e.item.module;(t[n]||(t[n]=[])).push(e)});var n=[];for(var o in t)!function(e){var o=t[e],r=0;o.forEach(function(e){r+=1/e.score}),n.push({module:e,totalScore:1/r,items:o})}(o);n.sort(function(e,t){return e.totalScore-t.totalScore}),this.setState({searchString:e,isVisible:!0,moduleResults:n})},t.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},t.prototype.componentDidMount=function(){this.props.showHideTrigger(this.toggleVisibility.bind(this))},t.prototype.render=function(e,t){var n=this;if(t.failedLoading){var o="file:"==window.location.protocol;return p("div",{id:"search",class:t.isVisible?"":"hidden"},p("div",{id:"search-results"},p("p",{class:"error"},"Failed to load file 'doc-index.json' containing definitions in this package."),o?p("p",{class:"error"},"To use quick jump, load this page with HTTP (from a local static file web server) instead of using the ",p("code",null,"file://")," protocol. (For security reasons, it is not possible to fetch auxiliary files using JS in a HTML page opened with ",p("code",null,"file://"),".)"):[]))}this.linkIndex=0;var r=function(e){e.stopPropagation()},c=i(10,t.moduleResults).map(function(e){return n.renderResultsInModule(e)});return p("div",{id:"search",class:t.isVisible?"":"hidden"},p("div",{id:"search-form",onMouseDown:r},p("input",{placeholder:"Search in package by name",ref:function(e){n.input=e},onFocus:this.show.bind(this),onClick:this.show.bind(this),onInput:this.updateResults.bind(this)})),p("div",{id:"search-results",ref:function(e){n.searchResults=e},onMouseDown:r,onMouseOver:function(e){for(var t=e.target;t&&"function"==typeof t.getAttribute;){var o=t.getAttribute("data-link-index");if("string"==typeof o){var r=parseInt(o,10);n.setState({activeLinkIndex:r});break}t=t.parentNode}}},""===t.searchString?[p(a,null),p(s,null)]:0==c.length?p(l,{searchString:t.searchString}):p("ul",null,c)))},t.prototype.renderResultsInModule=function(e){var t=this,n=e.items,o=e.module,r=this.state.expanded[o]||n.length<=10,s=r?n:i(8,n),a=function(e){return p("li",{class:"search-result"},t.navigationLink(t.props.baseUrl+"/"+e.link,{},p(m,{html:e.display_html})))};return p("li",{class:"search-module"},p("h4",null,o),p("ul",null,s.map(function(e){return a(e.item)}),r?[]:p("li",{class:"more-results"},this.actionLink(function(){var e=Object.assign({},t.state.expanded);e[o]=!0,t.setState({expanded:e})},{},"show "+(n.length-s.length)+" more results from this module"))))},t.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))},t.prototype.actionLink=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=Object.assign({href:"#",onClick:function(t){t.preventDefault(),e()}},t);return this.menuLink.apply(this,[r,e].concat(n))},t.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,p.apply(void 0,["a",s].concat(o))},t}(f),m=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.shouldComponentUpdate=function(e){return this.props.html!==e.html},t.prototype.render=function(e){return p("div",{dangerouslySetInnerHTML:{__html:e.html}})},t}(f);n.init=c,window.quickNav={init:c}},{"fuse.js":6,preact:7}],5:[function(e,t,n){"use strict";function o(e){return(" "+e+" ").replace(g," ")}function r(e){return e.replace(m,"")}function i(e,t){return o(e.className||"").indexOf(" "+t+" ")>=0}function s(e,t){var n=o(e.className||"");n.indexOf(" "+t+" ")<0&&(e.className=r(n+" "+t))}function a(e,t){var n=o(e.className||"");n=n.replace(" "+t+" "," "),e.className=r(n)}function l(e,t,n,o){return null==o&&(o=!i(e,t)),o?(a(e,n),s(e,t)):(a(e,t),s(e,n)),o}function c(e){var t=document.getElementById("page-menu");if(t&&t.firstChild){var n=t.firstChild.cloneNode(!1);n.innerHTML=e,t.appendChild(n)}}function u(){return Array.prototype.slice.call(document.getElementsByTagName("link")).filter(function(e){return-1!=e.rel.indexOf("style")&&e.title})}function h(){var e=u(),t="";e.forEach(function(e){t+="<li><a href='#' onclick=\"setActiveStyleSheet('"+e.title+"'); return false;\">"+e.title+"</a></li>"}),e.length>1&&c("<div id='style-menu-holder'><a href='#' onclick='styleMenu(); return false;'>Style &#9662;</a><ul id='style-menu' class='hide'>"+t+"</ul></div>")}function d(e){for(var t=u(),n=null,o=0;o<t.length;o++){var r=t[o];r.disabled=!0,r.title==e&&(n=r)}n?(n.disabled=!1,v.setCookie("haddock-style",e)):(t[0].disabled=!1,v.clearCookie("haddock-style")),f(!1)}function p(){var e=v.getCookie("haddock-style");e&&d(e)}function f(e){var t=document.getElementById("style-menu");t&&y(t,e)}Object.defineProperty(n,"__esModule",{value:!0});var v=e("./cookies"),g=/\s\s+/g,m=/^\s+|\s+$/g,y=function(e,t){return function(n,o){return l(n,e,t,o)}}("show","hide");n.init=function(){h(),p()}},{"./cookies":1}],6:[function(e,t,n){!function(e,o){"object"==typeof n&&"object"==typeof t?t.exports=o():"function"==typeof define&&define.amd?define("Fuse",[],o):"object"==typeof n?n.Fuse=o():e.Fuse=o()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t,n){"use strict";e.exports=function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(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(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(5),s=n(7),a=n(4),l=function(){function e(t,n){var r=n.location,i=void 0===r?0:r,s=n.distance,l=void 0===s?100:s,c=n.threshold,u=void 0===c?.6:c,h=n.maxPatternLength,d=void 0===h?32:h,p=n.isCaseSensitive,f=void 0!==p&&p,v=n.tokenSeparator,g=void 0===v?/ +/g:v,m=n.findAllMatches,y=void 0!==m&&m,_=n.minMatchCharLength,k=void 0===_?1:_;o(this,e),this.options={location:i,distance:l,threshold:u,maxPatternLength:d,isCaseSensitive:f,tokenSeparator:g,findAllMatches:y,minMatchCharLength:k},this.pattern=this.options.isCaseSensitive?t:t.toLowerCase(),this.pattern.length<=d&&(this.patternAlphabet=a(this.pattern))}return r(e,[{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 i(e,this.pattern,o);var r=this.options,a=r.location,l=r.distance,c=r.threshold,u=r.findAllMatches,h=r.minMatchCharLength;return s(e,this.pattern,this.patternAlphabet,{location:a,distance:l,threshold:c,findAllMatches:u,minMatchCharLength:h})}}]),e}();e.exports=l},function(e,t,n){"use strict";var o=n(0),r=function e(t,n,r){if(n){var i=n.indexOf("."),s=n,a=null;-1!==i&&(s=n.slice(0,i),a=n.slice(i+1));var l=t[s];if(null!==l&&void 0!==l)if(a||"string"!=typeof l&&"number"!=typeof l)if(o(l))for(var c=0,u=l.length;c<u;c+=1)e(l[c],a,r);else a&&e(l,a,r);else r.push(l.toString())}else r.push(t);return r};e.exports=function(e,t){return r(e,t,[])}},function(e,t,n){"use strict";e.exports=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&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||((r=i-1)-o+1>=t&&n.push([o,r]),o=-1)}return e[i-1]&&i-o>=t&&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 o=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:/ +/g,r=new RegExp(t.replace(o,"\\$&").replace(n,"|")),i=e.match(r),s=!!i,a=[];if(s)for(var l=0,c=i.length;l<c;l+=1){var u=i[l];a.push([e.indexOf(u),u.length-1])}return{score:s?.5:1,isMatch:s,matchedIndices:a}}},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 o=n(6),r=n(3);e.exports=function(e,t,n,i){for(var s=i.location,a=void 0===s?0:s,l=i.distance,c=void 0===l?100:l,u=i.threshold,h=void 0===u?.6:u,d=i.findAllMatches,p=void 0!==d&&d,f=i.minMatchCharLength,v=void 0===f?1:f,g=a,m=e.length,y=h,_=e.indexOf(t,g),k=t.length,b=[],x=0;x<m;x+=1)b[x]=0;if(-1!==_){var w=o(t,{errors:0,currentLocation:_,expectedLocation:g,distance:c});if(y=Math.min(w,y),-1!==(_=e.lastIndexOf(t,g+k))){var S=o(t,{errors:0,currentLocation:_,expectedLocation:g,distance:c});y=Math.min(S,y)}}_=-1;for(var L=[],C=1,M=k+m,N=1<<k-1,I=0;I<k;I+=1){for(var A=0,O=M;A<O;)o(t,{errors:I,currentLocation:g+O,expectedLocation:g,distance:c})<=y?A=O:M=O,O=Math.floor((M-A)/2+A);M=O;var E=Math.max(1,g-O+1),T=p?m:Math.min(g+O,m)+k,j=Array(T+2);j[T+1]=(1<<I)-1;for(var P=T;P>=E;P-=1){var R=P-1,U=n[e.charAt(R)];if(U&&(b[R]=1),j[P]=(j[P+1]<<1|1)&U,0!==I&&(j[P]|=(L[P+1]|L[P])<<1|1|L[P+1]),j[P]&N&&(C=o(t,{errors:I,currentLocation:R,expectedLocation:g,distance:c}))<=y){if(y=C,(_=R)<=g)break;E=Math.max(1,2*g-_)}}if(o(t,{errors:I+1,currentLocation:g,expectedLocation:g,distance:c})>y)break;L=j}return{isMatch:_>=0,score:0===C?.001:C,matchedIndices:r(b,v)}}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(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(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(1),s=n(2),a=n(0),l=function(){function e(t,n){var r=n.location,i=void 0===r?0:r,a=n.distance,l=void 0===a?100:a,c=n.threshold,u=void 0===c?.6:c,h=n.maxPatternLength,d=void 0===h?32:h,p=n.caseSensitive,f=void 0!==p&&p,v=n.tokenSeparator,g=void 0===v?/ +/g:v,m=n.findAllMatches,y=void 0!==m&&m,_=n.minMatchCharLength,k=void 0===_?1:_,b=n.id,x=void 0===b?null:b,w=n.keys,S=void 0===w?[]:w,L=n.shouldSort,C=void 0===L||L,M=n.getFn,N=void 0===M?s:M,I=n.sortFn,A=void 0===I?function(e,t){return e.score-t.score}:I,O=n.tokenize,E=void 0!==O&&O,T=n.matchAllTokens,j=void 0!==T&&T,P=n.includeMatches,R=void 0!==P&&P,U=n.includeScore,D=void 0!==U&&U,V=n.verbose,F=void 0!==V&&V;o(this,e),this.options={location:i,distance:l,threshold:u,maxPatternLength:d,isCaseSensitive:f,tokenSeparator:g,findAllMatches:y,minMatchCharLength:k,id:x,keys:S,includeMatches:R,includeScore:D,shouldSort:C,getFn:N,sortFn:A,verbose:F,tokenize:E,matchAllTokens:j},this.setCollection(t)}return r(e,[{key:"setCollection",value:function(e){return this.list=e,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=arguments.length>0&&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=arguments.length>0&&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,d=this.options.keys.length;h<d;h+=1){var p=this.options.keys[h];if("string"!=typeof p){if(a[p.name]={weight:1-p.weight||1},p.weight<=0||p.weight>1)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,l=e.index,c=t.tokenSearchers,u=void 0===c?[]:c,h=t.fullSearcher,d=void 0===h?[]:h,p=t.resultMap,f=void 0===p?{}:p,v=t.results,g=void 0===v?[]:v;if(void 0!==i&&null!==i){var m=!1,y=-1,_=0;if("string"==typeof i){this._log("\nKey: "+(""===n?"-":n));var k=d.search(i);if(this._log('Full text: "'+i+'", score: '+k.score),this.options.tokenize){for(var b=i.split(this.options.tokenSeparator),x=[],w=0;w<u.length;w+=1){var S=u[w];this._log('\nPattern: "'+S.pattern+'"');for(var L=!1,C=0;C<b.length;C+=1){var M=b[C],N=S.search(M),I={};N.isMatch?(I[M]=N.score,m=!0,L=!0,x.push(N.score)):(I[M]=1,this.options.matchAllTokens||x.push(1)),this._log('Token: "'+M+'", score: '+I[M])}L&&(_+=1)}y=x[0];for(var A=x.length,O=1;O<A;O+=1)y+=x[O];y/=A,this._log("Token score average:",y)}var E=k.score;y>-1&&(E=(E+y)/2),this._log("Score average:",E);var T=!this.options.tokenize||!this.options.matchAllTokens||_>=u.length;if(this._log("\nCheck Matches: "+T),(m||k.isMatch)&&T){var j=f[l];j?j.output.push({key:n,arrayIndex:r,value:i,score:E,matchedIndices:k.matchedIndices}):(f[l]={item:s,output:[{key:n,arrayIndex:r,value:i,score:E,matchedIndices:k.matchedIndices}]},g.push(f[l]))}}else if(a(i))for(var P=0,R=i.length;P<R;P+=1)this._analyze({key:n,arrayIndex:P,value:i[P],record:s,index:l},{resultMap:f,results:g,tokenSearchers:u,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=0,a=1,l=0;l<i;l+=1){var c=r[l].score,u=e?e[r[l].key].weight:1,h=c*u;1!==u?a=Math.min(a,h):(r[l].nScore=h,s+=h)}t[n].score=1===a?s/i: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._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")&&i.arrayIndex>-1&&(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(){if(this.options.verbose){var e;(e=console).log.apply(e,arguments)}}}]),e}();e.exports=l}])})},{}],7:[function(e,t,n){!function(){"use strict";function e(){}function n(t,n){var o,r,i,s,a=O;for(s=arguments.length;s-- >2;)A.push(arguments[s]);for(n&&null!=n.children&&(A.length||A.push(n.children),delete n.children);A.length;)if((r=A.pop())&&void 0!==r.pop)for(s=r.length;s--;)A.push(r[s]);else"boolean"==typeof r&&(r=null),(i="function"!=typeof t)&&(null==r?r="":"number"==typeof r?r=String(r):"string"!=typeof r&&(i=!1)),i&&o?a[a.length-1]+=r:a===O?a=[r]:a.push(r),o=i;var l=new e;return l.nodeName=t,l.children=a,l.attributes=null==n?void 0:n,l.key=null==n?void 0:n.key,void 0!==I.vnode&&I.vnode(l),l}function o(e,t){for(var n in t)e[n]=t[n];return e}function r(e){!e.__d&&(e.__d=!0)&&1==j.push(e)&&(I.debounceRendering||E)(i)}function i(){var e,t=j;for(j=[];e=t.pop();)e.__d&&L(e)}function s(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&a(e,t.nodeName):n||e._componentConstructor===t.nodeName}function a(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function l(e){var t=o({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var r in n)void 0===t[r]&&(t[r]=n[r]);return t}function c(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}function u(e){var t=e.parentNode;t&&t.removeChild(e)}function h(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===T.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,p,s):e.removeEventListener(t,p,s),(e.__l||(e.__l={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e)d(e,t,null==o?"":o),null!=o&&!1!==o||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 d(e,t,n){try{e[t]=n}catch(e){}}function p(e){return this.__l[e.type](I.event&&I.event(e)||e)}function f(){for(var e;e=P.pop();)I.afterMount&&I.afterMount(e),e.componentDidMount&&e.componentDidMount()}function v(e,t,n,o,r,i){R++||(U=null!=r&&void 0!==r.ownerSVGElement,D=null!=e&&!("__preactattr_"in e));var s=g(e,t,n,o,i);return r&&s.parentNode!==r&&r.appendChild(s),--R||(D=!1,i||f()),s}function g(e,t,n,o,r){var i=e,s=U;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),y(e,!0))),i.__preactattr_=!0,i;var l=t.nodeName;if("function"==typeof l)return C(e,t,n,o);if(U="svg"===l||"foreignObject"!==l&&U,l=String(l),(!e||!a(e,l))&&(i=c(l,U),e)){for(;e.firstChild;)i.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(i,e),y(e,!0)}var u=i.firstChild,h=i.__preactattr_,d=t.children;if(null==h){h=i.__preactattr_={};for(var p=i.attributes,f=p.length;f--;)h[p[f].name]=p[f].value}return!D&&d&&1===d.length&&"string"==typeof d[0]&&null!=u&&void 0!==u.splitText&&null==u.nextSibling?u.nodeValue!=d[0]&&(u.nodeValue=d[0]):(d&&d.length||null!=u)&&m(i,d,n,o,D||null!=h.dangerouslySetInnerHTML),k(i,t.attributes,h),U=s,i}function m(e,t,n,o,r){var i,a,l,c,h,d=e.childNodes,p=[],f={},v=0,m=0,_=d.length,k=0,b=t?t.length:0;if(0!==_)for(L=0;L<_;L++){var x=d[L],w=x.__preactattr_;null!=(S=b&&w?x._component?x._component.__k:w.key:null)?(v++,f[S]=x):(w||(void 0!==x.splitText?!r||x.nodeValue.trim():r))&&(p[k++]=x)}if(0!==b)for(L=0;L<b;L++){h=null;var S=(c=t[L]).key;if(null!=S)v&&void 0!==f[S]&&(h=f[S],f[S]=void 0,v--);else if(!h&&m<k)for(i=m;i<k;i++)if(void 0!==p[i]&&s(a=p[i],c,r)){h=a,p[i]=void 0,i===k-1&&k--,i===m&&m++;break}h=g(h,c,n,o),l=d[L],h&&h!==e&&h!==l&&(null==l?e.appendChild(h):h===l.nextSibling?u(l):e.insertBefore(h,l))}if(v)for(var L in f)void 0!==f[L]&&y(f[L],!1);for(;m<=k;)void 0!==(h=p[k--])&&y(h,!1)}function y(e,t){var n=e._component;n?M(n):(null!=e.__preactattr_&&e.__preactattr_.ref&&e.__preactattr_.ref(null),!1!==t&&null!=e.__preactattr_||u(e),_(e))}function _(e){for(e=e.lastChild;e;){var t=e.previousSibling;y(e,!0),e=t}}function k(e,t,n){var o;for(o in n)t&&null!=t[o]||null==n[o]||h(e,o,n[o],n[o]=void 0,U);for(o in t)"children"===o||"innerHTML"===o||o in n&&t[o]===("value"===o||"checked"===o?e[o]:n[o])||h(e,o,n[o],n[o]=t[o],U)}function b(e){var t=e.constructor.name;(V[t]||(V[t]=[])).push(e)}function x(e,t,n){var o,r=V[e.name];if(e.prototype&&e.prototype.render?(o=new e(t,n),N.call(o,t,n)):((o=new N(t,n)).constructor=e,o.render=w),r)for(var i=r.length;i--;)if(r[i].constructor===e){o.__b=r[i].__b,r.splice(i,1);break}return o}function w(e,t,n){return this.constructor(e,n)}function S(e,t,n,o,i){e.__x||(e.__x=!0,(e.__r=t.ref)&&delete t.ref,(e.__k=t.key)&&delete t.key,!e.base||i?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===I.syncComponentUpdates&&e.base?r(e):L(e,1,i)),e.__r&&e.__r(e))}function L(e,t,n,r){if(!e.__x){var i,s,a,c=e.props,u=e.state,h=e.context,d=e.__p||c,p=e.__s||u,g=e.__c||h,m=e.base,_=e.__b,k=m||_,b=e._component,w=!1;if(m&&(e.props=d,e.state=p,e.context=g,2!==t&&e.shouldComponentUpdate&&!1===e.shouldComponentUpdate(c,u,h)?w=!0:e.componentWillUpdate&&e.componentWillUpdate(c,u,h),e.props=c,e.state=u,e.context=h),e.__p=e.__s=e.__c=e.__b=null,e.__d=!1,!w){i=e.render(c,u,h),e.getChildContext&&(h=o(o({},h),e.getChildContext()));var C,N,A=i&&i.nodeName;if("function"==typeof A){var O=l(i);(s=b)&&s.constructor===A&&O.key==s.__k?S(s,O,1,h,!1):(C=s,e._component=s=x(A,O,h),s.__b=s.__b||_,s.__u=e,S(s,O,0,h,!1),L(s,1,n,!0)),N=s.base}else a=k,(C=b)&&(a=e._component=null),(k||1===t)&&(a&&(a._component=null),N=v(a,i,h,n||!m,k&&k.parentNode,!0));if(k&&N!==k&&s!==b){var E=k.parentNode;E&&N!==E&&(E.replaceChild(N,k),C||(k._component=null,y(k,!1)))}if(C&&M(C),e.base=N,N&&!r){for(var T=e,j=e;j=j.__u;)(T=j).base=N;N._component=T,N._componentConstructor=T.constructor}}if(!m||n?P.unshift(e):w||(e.componentDidUpdate&&e.componentDidUpdate(d,p,g),I.afterUpdate&&I.afterUpdate(e)),null!=e.__h)for(;e.__h.length;)e.__h.pop().call(e);R||r||f()}}function C(e,t,n,o){for(var r=e&&e._component,i=r,s=e,a=r&&e._componentConstructor===t.nodeName,c=a,u=l(t);r&&!c&&(r=r.__u);)c=r.constructor===t.nodeName;return r&&c&&(!o||r._component)?(S(r,u,3,n,o),e=r.base):(i&&!a&&(M(i),e=s=null),r=x(t.nodeName,u,n),e&&!r.__b&&(r.__b=e,s=null),S(r,u,1,n,o),e=r.base,s&&e!==s&&(s._component=null,y(s,!1))),e}function M(e){I.beforeUnmount&&I.beforeUnmount(e);var t=e.base;e.__x=!0,e.componentWillUnmount&&e.componentWillUnmount(),e.base=null;var n=e._component;n?M(n):t&&(t.__preactattr_&&t.__preactattr_.ref&&t.__preactattr_.ref(null),e.__b=t,u(t),b(e),_(t)),e.__r&&e.__r(null)}function N(e,t){this.__d=!0,this.context=t,this.props=e,this.state=this.state||{}}var I={},A=[],O=[],E="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout,T=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,j=[],P=[],R=0,U=!1,D=!1,V={};o(N.prototype,{setState:function(e,t){var n=this.state;this.__s||(this.__s=o({},n)),o(n,"function"==typeof e?e(n,this.props):e),t&&(this.__h=this.__h||[]).push(t),r(this)},forceUpdate:function(e){e&&(this.__h=this.__h||[]).push(e),L(this,2)},render:function(){}});var F={h:n,createElement:n,cloneElement:function(e,t){return n(e.nodeName,o(o({},e.attributes),t),arguments.length>2?[].slice.call(arguments,2):e.children)},Component:N,render:function(e,t,n){return v(n,e,{},!1,t,!1)},rerender:i,options:I};void 0!==t?t.exports=F:self.preact=F}()},{}]},{},[3]); //# sourceMappingURL=haddock-bundle.min.js.map
resources/html/quick-jump.min.js view
@@ -1,2 +1,2 @@-!function e(t,n,o){function r(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return r(n||e)},u,u.exports,e,t,n,o)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(e,t,n){"use strict";function o(e,t,n){var o=new XMLHttpRequest;o.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()}function r(e){var t=document.querySelector("#page-menu"),n=document.createElement("li");t.insertBefore(n,t.firstChild),p.render(d(v,{onClick:e,title:"Quick Jump"}),t,n)}function i(e,t){return t.length<=e?t:t.slice(0,e)}function s(){return d("table",{class:"keyboard-shortcuts"},d("tr",null,d("th",null,"Key"),d("th",null,"Shortcut")),d("tr",null,d("td",null,d("span",{class:"key"},"s")),d("td",null,"Open this search box")),d("tr",null,d("td",null,d("span",{class:"key"},"esc")),d("td",null,"Close this search box")),d("tr",null,d("td",null,d("span",{class:"key"},"↓"),",",d("span",{class:"key"},"ctrl")," + ",d("span",{class:"key"},"j")),d("td",null,"Move down in search results")),d("tr",null,d("td",null,d("span",{class:"key"},"↑"),",",d("span",{class:"key"},"ctrl")," + ",d("span",{class:"key"},"k")),d("td",null,"Move up in search results")),d("tr",null,d("td",null,d("span",{class:"key"},"↵")),d("td",null,"Go to active search result")))}function a(){return d("p",null,"You can find any exported type, constructor, class, function or pattern defined in this package by (approximate) name.")}function l(e){var t=[d("p",null,"Your search for '",e.searchString,"' produced the following list of results: ",d("code",null,"[]"),"."),d("p",null,d("code",null,"Nothing")," matches your query for '",e.searchString,"'."),d("p",null,d("code",null,"Left \"no matches for '",e.searchString,"'\" :: Either String (NonEmpty SearchResult)"))];return t[(e.searchString||"a").charCodeAt(0)%t.length]}function c(e,t){p.render(d(_,{baseUrl:e||".",showHideTrigger:t||r}),document.body)}var u=this&&this.__extends||function(){var e=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])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();Object.defineProperty(n,"__esModule",{value:!0});var h=e("fuse.js"),p=e("preact"),d=p.h,f=p.Component,v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(e){return d("li",null,d("a",{href:"#",onClick:function(t){t.preventDefault(),e.onClick()}},e.title))},t}(f),_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linkIndex=0,t.focusPlease=!1,t.navigatedByKeyboard=!1,t}return u(t,e),t.prototype.componentWillMount=function(){var e=this;this.setState({searchString:"",isVisible:!1,expanded:{},activeLinkIndex:-1,moduleResults:[]}),o(this.props.baseUrl+"/doc-index.json",function(t){e.setState({fuse:new h(t,{threshold:.25,caseSensitive:!0,includeScore:!0,tokenize:!0,keys:[{name:"name",weight:.7},{name:"module",weight:.3}]}),moduleResults:[]})},function(t){console&&console.error("could not load 'doc-index.json' for searching",t),e.setState({failedLoading:!0})}),document.addEventListener("mousedown",this.hide.bind(this)),document.addEventListener("keydown",function(t){e.state.isVisible&&("Escape"===t.key?e.hide():"ArrowUp"===t.key||"k"===t.key&&t.ctrlKey?(t.preventDefault(),e.navigateLinks(-1)):"ArrowDown"===t.key||"j"===t.key&&t.ctrlKey?(t.preventDefault(),e.navigateLinks(1)):"Enter"===t.key&&e.state.activeLinkIndex>=0&&e.followActiveLink()),"s"===t.key&&"input"!==t.target.tagName.toLowerCase()&&(t.preventDefault(),e.show())})},t.prototype.hide=function(){this.setState({isVisible:!1})},t.prototype.show=function(){this.state.isVisible||(this.focusPlease=!0,this.setState({isVisible:!0,activeLinkIndex:-1}))},t.prototype.toggleVisibility=function(){this.state.isVisible?this.hide():this.show()},t.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})},t.prototype.followActiveLink=function(){this.activeLinkAction&&this.activeLinkAction()},t.prototype.updateResults=function(){var e=this.input&&this.input.value||"",t={};this.state.fuse.search(e).forEach(function(e){var n=e.item.module;(t[n]||(t[n]=[])).push(e)});var n=[];for(var o in t)!function(e){var o=t[e],r=0;o.forEach(function(e){r+=1/e.score}),n.push({module:e,totalScore:1/r,items:o})}(o);n.sort(function(e,t){return e.totalScore-t.totalScore}),this.setState({searchString:e,isVisible:!0,moduleResults:n})},t.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},t.prototype.componentDidMount=function(){this.props.showHideTrigger(this.toggleVisibility.bind(this))},t.prototype.render=function(e,t){var n=this;if(t.failedLoading){var o="file:"==window.location.protocol;return d("div",{id:"search",class:t.isVisible?"":"hidden"},d("div",{id:"search-results"},d("p",{class:"error"},"Failed to load file 'doc-index.json' containing definitions in this package."),o?d("p",{class:"error"},"To use quick jump, load this page with HTTP (from a local static file web server) instead of using the ",d("code",null,"file://")," protocol. (For security reasons, it is not possible to fetch auxiliary files using JS in a HTML page opened with ",d("code",null,"file://"),".)"):[]))}this.linkIndex=0;var r=function(e){e.stopPropagation()},c=i(10,t.moduleResults).map(function(e){return n.renderResultsInModule(e)});return d("div",{id:"search",class:t.isVisible?"":"hidden"},d("div",{id:"search-form",onMouseDown:r},d("input",{placeholder:"Search in package by name",ref:function(e){n.input=e},onFocus:this.show.bind(this),onClick:this.show.bind(this),onInput:this.updateResults.bind(this)})),d("div",{id:"search-results",ref:function(e){n.searchResults=e},onMouseDown:r,onMouseOver:function(e){for(var t=e.target;t&&"function"==typeof t.getAttribute;){var o=t.getAttribute("data-link-index");if("string"==typeof o){var r=parseInt(o,10);n.setState({activeLinkIndex:r});break}t=t.parentNode}}},""===t.searchString?[d(a,null),d(s,null)]:0==c.length?d(l,{searchString:t.searchString}):d("ul",null,c)))},t.prototype.renderResultsInModule=function(e){var t=this,n=e.items,o=e.module,r=this.state.expanded[o]||n.length<=10,s=r?n:i(8,n),a=function(e){return d("li",{class:"search-result"},t.navigationLink(t.props.baseUrl+"/"+e.link,{},d(g,{html:e.display_html})))};return d("li",{class:"search-module"},d("h4",null,o),d("ul",null,s.map(function(e){return a(e.item)}),r?[]:d("li",{class:"more-results"},this.actionLink(function(){var e=Object.assign({},t.state.expanded);e[o]=!0,t.setState({expanded:e})},{},"show "+(n.length-s.length)+" more results from this module"))))},t.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),s=function(){window.location.href=e,n.hide()};return this.menuLink.apply(this,[i,s].concat(o))},t.prototype.actionLink=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=Object.assign({href:"#",onClick:function(t){t.preventDefault(),e()}},t);return this.menuLink.apply(this,[r,e].concat(n))},t.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,d.apply(void 0,["a",s].concat(o))},t}(f),g=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.shouldComponentUpdate=function(e){return this.props.html!==e.html},t.prototype.render=function(e){return d("div",{dangerouslySetInnerHTML:{__html:e.html}})},t}(f);n.init=c,window.quickNav={init:c}},{"fuse.js":2,preact:3}],2:[function(e,t,n){!function(e,o){"object"==typeof n&&"object"==typeof t?t.exports=o():"function"==typeof define&&define.amd?define("Fuse",[],o):"object"==typeof n?n.Fuse=o():e.Fuse=o()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t,n){"use strict";e.exports=function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(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(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(5),s=n(7),a=n(4),l=function(){function e(t,n){var r=n.location,i=void 0===r?0:r,s=n.distance,l=void 0===s?100:s,c=n.threshold,u=void 0===c?.6:c,h=n.maxPatternLength,p=void 0===h?32:h,d=n.isCaseSensitive,f=void 0!==d&&d,v=n.tokenSeparator,_=void 0===v?/ +/g:v,g=n.findAllMatches,m=void 0!==g&&g,y=n.minMatchCharLength,k=void 0===y?1:y;o(this,e),this.options={location:i,distance:l,threshold:u,maxPatternLength:p,isCaseSensitive:f,tokenSeparator:_,findAllMatches:m,minMatchCharLength:k},this.pattern=this.options.isCaseSensitive?t:t.toLowerCase(),this.pattern.length<=p&&(this.patternAlphabet=a(this.pattern))}return r(e,[{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 i(e,this.pattern,o);var r=this.options,a=r.location,l=r.distance,c=r.threshold,u=r.findAllMatches,h=r.minMatchCharLength;return s(e,this.pattern,this.patternAlphabet,{location:a,distance:l,threshold:c,findAllMatches:u,minMatchCharLength:h})}}]),e}();e.exports=l},function(e,t,n){"use strict";var o=n(0),r=function e(t,n,r){if(n){var i=n.indexOf("."),s=n,a=null;-1!==i&&(s=n.slice(0,i),a=n.slice(i+1));var l=t[s];if(null!==l&&void 0!==l)if(a||"string"!=typeof l&&"number"!=typeof l)if(o(l))for(var c=0,u=l.length;c<u;c+=1)e(l[c],a,r);else a&&e(l,a,r);else r.push(l.toString())}else r.push(t);return r};e.exports=function(e,t){return r(e,t,[])}},function(e,t,n){"use strict";e.exports=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&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||((r=i-1)-o+1>=t&&n.push([o,r]),o=-1)}return e[i-1]&&i-o>=t&&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 o=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:/ +/g,r=new RegExp(t.replace(o,"\\$&").replace(n,"|")),i=e.match(r),s=!!i,a=[];if(s)for(var l=0,c=i.length;l<c;l+=1){var u=i[l];a.push([e.indexOf(u),u.length-1])}return{score:s?.5:1,isMatch:s,matchedIndices:a}}},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 o=n(6),r=n(3);e.exports=function(e,t,n,i){for(var s=i.location,a=void 0===s?0:s,l=i.distance,c=void 0===l?100:l,u=i.threshold,h=void 0===u?.6:u,p=i.findAllMatches,d=void 0!==p&&p,f=i.minMatchCharLength,v=void 0===f?1:f,_=a,g=e.length,m=h,y=e.indexOf(t,_),k=t.length,b=[],x=0;x<g;x+=1)b[x]=0;if(-1!==y){var w=o(t,{errors:0,currentLocation:y,expectedLocation:_,distance:c});if(m=Math.min(w,m),-1!==(y=e.lastIndexOf(t,_+k))){var S=o(t,{errors:0,currentLocation:y,expectedLocation:_,distance:c});m=Math.min(S,m)}}y=-1;for(var L=[],C=1,M=k+g,N=1<<k-1,I=0;I<k;I+=1){for(var A=0,T=M;A<T;)o(t,{errors:I,currentLocation:_+T,expectedLocation:_,distance:c})<=m?A=T:M=T,T=Math.floor((M-A)/2+A);M=T;var O=Math.max(1,_-T+1),j=d?g:Math.min(_+T,g)+k,P=Array(j+2);P[j+1]=(1<<I)-1;for(var E=j;E>=O;E-=1){var R=E-1,U=n[e.charAt(R)];if(U&&(b[R]=1),P[E]=(P[E+1]<<1|1)&U,0!==I&&(P[E]|=(L[E+1]|L[E])<<1|1|L[E+1]),P[E]&N&&(C=o(t,{errors:I,currentLocation:R,expectedLocation:_,distance:c}))<=m){if(m=C,(y=R)<=_)break;O=Math.max(1,2*_-y)}}if(o(t,{errors:I+1,currentLocation:_,expectedLocation:_,distance:c})>m)break;L=P}return{isMatch:y>=0,score:0===C?.001:C,matchedIndices:r(b,v)}}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(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(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(1),s=n(2),a=n(0),l=function(){function e(t,n){var r=n.location,i=void 0===r?0:r,a=n.distance,l=void 0===a?100:a,c=n.threshold,u=void 0===c?.6:c,h=n.maxPatternLength,p=void 0===h?32:h,d=n.caseSensitive,f=void 0!==d&&d,v=n.tokenSeparator,_=void 0===v?/ +/g:v,g=n.findAllMatches,m=void 0!==g&&g,y=n.minMatchCharLength,k=void 0===y?1:y,b=n.id,x=void 0===b?null:b,w=n.keys,S=void 0===w?[]:w,L=n.shouldSort,C=void 0===L||L,M=n.getFn,N=void 0===M?s:M,I=n.sortFn,A=void 0===I?function(e,t){return e.score-t.score}:I,T=n.tokenize,O=void 0!==T&&T,j=n.matchAllTokens,P=void 0!==j&&j,E=n.includeMatches,R=void 0!==E&&E,U=n.includeScore,D=void 0!==U&&U,V=n.verbose,F=void 0!==V&&V;o(this,e),this.options={location:i,distance:l,threshold:u,maxPatternLength:p,isCaseSensitive:f,tokenSeparator:_,findAllMatches:m,minMatchCharLength:k,id:x,keys:S,includeMatches:R,includeScore:D,shouldSort:C,getFn:N,sortFn:A,verbose:F,tokenize:O,matchAllTokens:P},this.setCollection(t)}return r(e,[{key:"setCollection",value:function(e){return this.list=e,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=arguments.length>0&&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=arguments.length>0&&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||d.weight>1)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,l=e.index,c=t.tokenSearchers,u=void 0===c?[]:c,h=t.fullSearcher,p=void 0===h?[]:h,d=t.resultMap,f=void 0===d?{}:d,v=t.results,_=void 0===v?[]:v;if(void 0!==i&&null!==i){var g=!1,m=-1,y=0;if("string"==typeof i){this._log("\nKey: "+(""===n?"-":n));var k=p.search(i);if(this._log('Full text: "'+i+'", score: '+k.score),this.options.tokenize){for(var b=i.split(this.options.tokenSeparator),x=[],w=0;w<u.length;w+=1){var S=u[w];this._log('\nPattern: "'+S.pattern+'"');for(var L=!1,C=0;C<b.length;C+=1){var M=b[C],N=S.search(M),I={};N.isMatch?(I[M]=N.score,g=!0,L=!0,x.push(N.score)):(I[M]=1,this.options.matchAllTokens||x.push(1)),this._log('Token: "'+M+'", score: '+I[M])}L&&(y+=1)}m=x[0];for(var A=x.length,T=1;T<A;T+=1)m+=x[T];m/=A,this._log("Token score average:",m)}var O=k.score;m>-1&&(O=(O+m)/2),this._log("Score average:",O);var j=!this.options.tokenize||!this.options.matchAllTokens||y>=u.length;if(this._log("\nCheck Matches: "+j),(g||k.isMatch)&&j){var P=f[l];P?P.output.push({key:n,arrayIndex:r,value:i,score:O,matchedIndices:k.matchedIndices}):(f[l]={item:s,output:[{key:n,arrayIndex:r,value:i,score:O,matchedIndices:k.matchedIndices}]},_.push(f[l]))}}else if(a(i))for(var E=0,R=i.length;E<R;E+=1)this._analyze({key:n,arrayIndex:E,value:i[E],record:s,index:l},{resultMap:f,results:_,tokenSearchers:u,fullSearcher:p})}}},{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=0,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):(r[l].nScore=u,s+=u)}t[n].score=1===a?s/i: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._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")&&i.arrayIndex>-1&&(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(){if(this.options.verbose){var e;(e=console).log.apply(e,arguments)}}}]),e}();e.exports=l}])})},{}],3:[function(e,t,n){!function(){"use strict";function e(){}function n(t,n){var o,r,i,s,a=T;for(s=arguments.length;s-- >2;)A.push(arguments[s]);for(n&&null!=n.children&&(A.length||A.push(n.children),delete n.children);A.length;)if((r=A.pop())&&void 0!==r.pop)for(s=r.length;s--;)A.push(r[s]);else"boolean"==typeof r&&(r=null),(i="function"!=typeof t)&&(null==r?r="":"number"==typeof r?r=String(r):"string"!=typeof r&&(i=!1)),i&&o?a[a.length-1]+=r:a===T?a=[r]:a.push(r),o=i;var l=new e;return l.nodeName=t,l.children=a,l.attributes=null==n?void 0:n,l.key=null==n?void 0:n.key,void 0!==I.vnode&&I.vnode(l),l}function o(e,t){for(var n in t)e[n]=t[n];return e}function r(e){!e.__d&&(e.__d=!0)&&1==P.push(e)&&(I.debounceRendering||O)(i)}function i(){var e,t=P;for(P=[];e=t.pop();)e.__d&&L(e)}function s(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&a(e,t.nodeName):n||e._componentConstructor===t.nodeName}function a(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function l(e){var t=o({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var r in n)void 0===t[r]&&(t[r]=n[r]);return t}function c(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}function u(e){var t=e.parentNode;t&&t.removeChild(e)}function h(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===j.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,d,s):e.removeEventListener(t,d,s),(e.__l||(e.__l={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e)p(e,t,null==o?"":o),null!=o&&!1!==o||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 p(e,t,n){try{e[t]=n}catch(e){}}function d(e){return this.__l[e.type](I.event&&I.event(e)||e)}function f(){for(var e;e=E.pop();)I.afterMount&&I.afterMount(e),e.componentDidMount&&e.componentDidMount()}function v(e,t,n,o,r,i){R++||(U=null!=r&&void 0!==r.ownerSVGElement,D=null!=e&&!("__preactattr_"in e));var s=_(e,t,n,o,i);return r&&s.parentNode!==r&&r.appendChild(s),--R||(D=!1,i||f()),s}function _(e,t,n,o,r){var i=e,s=U;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),m(e,!0))),i.__preactattr_=!0,i;var l=t.nodeName;if("function"==typeof l)return C(e,t,n,o);if(U="svg"===l||"foreignObject"!==l&&U,l=String(l),(!e||!a(e,l))&&(i=c(l,U),e)){for(;e.firstChild;)i.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(i,e),m(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!D&&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)&&g(i,p,n,o,D||null!=h.dangerouslySetInnerHTML),k(i,t.attributes,h),U=s,i}function g(e,t,n,o,r){var i,a,l,c,h,p=e.childNodes,d=[],f={},v=0,g=0,y=p.length,k=0,b=t?t.length:0;if(0!==y)for(L=0;L<y;L++){var x=p[L],w=x.__preactattr_;null!=(S=b&&w?x._component?x._component.__k:w.key:null)?(v++,f[S]=x):(w||(void 0!==x.splitText?!r||x.nodeValue.trim():r))&&(d[k++]=x)}if(0!==b)for(L=0;L<b;L++){h=null;var S=(c=t[L]).key;if(null!=S)v&&void 0!==f[S]&&(h=f[S],f[S]=void 0,v--);else if(!h&&g<k)for(i=g;i<k;i++)if(void 0!==d[i]&&s(a=d[i],c,r)){h=a,d[i]=void 0,i===k-1&&k--,i===g&&g++;break}h=_(h,c,n,o),l=p[L],h&&h!==e&&h!==l&&(null==l?e.appendChild(h):h===l.nextSibling?u(l):e.insertBefore(h,l))}if(v)for(var L in f)void 0!==f[L]&&m(f[L],!1);for(;g<=k;)void 0!==(h=d[k--])&&m(h,!1)}function m(e,t){var n=e._component;n?M(n):(null!=e.__preactattr_&&e.__preactattr_.ref&&e.__preactattr_.ref(null),!1!==t&&null!=e.__preactattr_||u(e),y(e))}function y(e){for(e=e.lastChild;e;){var t=e.previousSibling;m(e,!0),e=t}}function k(e,t,n){var o;for(o in n)t&&null!=t[o]||null==n[o]||h(e,o,n[o],n[o]=void 0,U);for(o in t)"children"===o||"innerHTML"===o||o in n&&t[o]===("value"===o||"checked"===o?e[o]:n[o])||h(e,o,n[o],n[o]=t[o],U)}function b(e){var t=e.constructor.name;(V[t]||(V[t]=[])).push(e)}function x(e,t,n){var o,r=V[e.name];if(e.prototype&&e.prototype.render?(o=new e(t,n),N.call(o,t,n)):((o=new N(t,n)).constructor=e,o.render=w),r)for(var i=r.length;i--;)if(r[i].constructor===e){o.__b=r[i].__b,r.splice(i,1);break}return o}function w(e,t,n){return this.constructor(e,n)}function S(e,t,n,o,i){e.__x||(e.__x=!0,(e.__r=t.ref)&&delete t.ref,(e.__k=t.key)&&delete t.key,!e.base||i?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===I.syncComponentUpdates&&e.base?r(e):L(e,1,i)),e.__r&&e.__r(e))}function L(e,t,n,r){if(!e.__x){var i,s,a,c=e.props,u=e.state,h=e.context,p=e.__p||c,d=e.__s||u,_=e.__c||h,g=e.base,y=e.__b,k=g||y,b=e._component,w=!1;if(g&&(e.props=p,e.state=d,e.context=_,2!==t&&e.shouldComponentUpdate&&!1===e.shouldComponentUpdate(c,u,h)?w=!0:e.componentWillUpdate&&e.componentWillUpdate(c,u,h),e.props=c,e.state=u,e.context=h),e.__p=e.__s=e.__c=e.__b=null,e.__d=!1,!w){i=e.render(c,u,h),e.getChildContext&&(h=o(o({},h),e.getChildContext()));var C,N,A=i&&i.nodeName;if("function"==typeof A){var T=l(i);(s=b)&&s.constructor===A&&T.key==s.__k?S(s,T,1,h,!1):(C=s,e._component=s=x(A,T,h),s.__b=s.__b||y,s.__u=e,S(s,T,0,h,!1),L(s,1,n,!0)),N=s.base}else a=k,(C=b)&&(a=e._component=null),(k||1===t)&&(a&&(a._component=null),N=v(a,i,h,n||!g,k&&k.parentNode,!0));if(k&&N!==k&&s!==b){var O=k.parentNode;O&&N!==O&&(O.replaceChild(N,k),C||(k._component=null,m(k,!1)))}if(C&&M(C),e.base=N,N&&!r){for(var j=e,P=e;P=P.__u;)(j=P).base=N;N._component=j,N._componentConstructor=j.constructor}}if(!g||n?E.unshift(e):w||(e.componentDidUpdate&&e.componentDidUpdate(p,d,_),I.afterUpdate&&I.afterUpdate(e)),null!=e.__h)for(;e.__h.length;)e.__h.pop().call(e);R||r||f()}}function C(e,t,n,o){for(var r=e&&e._component,i=r,s=e,a=r&&e._componentConstructor===t.nodeName,c=a,u=l(t);r&&!c&&(r=r.__u);)c=r.constructor===t.nodeName;return r&&c&&(!o||r._component)?(S(r,u,3,n,o),e=r.base):(i&&!a&&(M(i),e=s=null),r=x(t.nodeName,u,n),e&&!r.__b&&(r.__b=e,s=null),S(r,u,1,n,o),e=r.base,s&&e!==s&&(s._component=null,m(s,!1))),e}function M(e){I.beforeUnmount&&I.beforeUnmount(e);var t=e.base;e.__x=!0,e.componentWillUnmount&&e.componentWillUnmount(),e.base=null;var n=e._component;n?M(n):t&&(t.__preactattr_&&t.__preactattr_.ref&&t.__preactattr_.ref(null),e.__b=t,u(t),b(e),y(t)),e.__r&&e.__r(null)}function N(e,t){this.__d=!0,this.context=t,this.props=e,this.state=this.state||{}}var I={},A=[],T=[],O="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout,j=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,P=[],E=[],R=0,U=!1,D=!1,V={};o(N.prototype,{setState:function(e,t){var n=this.state;this.__s||(this.__s=o({},n)),o(n,"function"==typeof e?e(n,this.props):e),t&&(this.__h=this.__h||[]).push(t),r(this)},forceUpdate:function(e){e&&(this.__h=this.__h||[]).push(e),L(this,2)},render:function(){}});var F={h:n,createElement:n,cloneElement:function(e,t){return n(e.nodeName,o(o({},e.attributes),t),arguments.length>2?[].slice.call(arguments,2):e.children)},Component:N,render:function(e,t,n){return v(n,e,{},!1,t,!1)},rerender:i,options:I};void 0!==t?t.exports=F:self.preact=F}()},{}]},{},[1]);+!function e(t,n,o){function r(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return r(n||e)},u,u.exports,e,t,n,o)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(e,t,n){"use strict";function o(e,t,n){var o=new XMLHttpRequest;o.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()}function r(e){var t=document.querySelector("#page-menu"),n=document.createElement("li");t.insertBefore(n,t.firstChild),p.render(d(v,{onClick:e,title:"Quick Jump"}),t,n)}function i(e,t){return t.length<=e?t:t.slice(0,e)}function s(){return d("table",{class:"keyboard-shortcuts"},d("tr",null,d("th",null,"Key"),d("th",null,"Shortcut")),d("tr",null,d("td",null,d("span",{class:"key"},"s")),d("td",null,"Open this search box")),d("tr",null,d("td",null,d("span",{class:"key"},"esc")),d("td",null,"Close this search box")),d("tr",null,d("td",null,d("span",{class:"key"},"↓"),",",d("span",{class:"key"},"ctrl")," + ",d("span",{class:"key"},"j")),d("td",null,"Move down in search results")),d("tr",null,d("td",null,d("span",{class:"key"},"↑"),",",d("span",{class:"key"},"ctrl")," + ",d("span",{class:"key"},"k")),d("td",null,"Move up in search results")),d("tr",null,d("td",null,d("span",{class:"key"},"↵")),d("td",null,"Go to active search result")))}function a(){return d("p",null,"You can find any exported type, constructor, class, function or pattern defined in this package by (approximate) name.")}function l(e){var t=[d("p",null,"Your search for '",e.searchString,"' produced the following list of results: ",d("code",null,"[]"),"."),d("p",null,d("code",null,"Nothing")," matches your query for '",e.searchString,"'."),d("p",null,d("code",null,"Left \"no matches for '",e.searchString,"'\" :: Either String (NonEmpty SearchResult)"))];return t[(e.searchString||"a").charCodeAt(0)%t.length]}function c(e,t){p.render(d(_,{baseUrl:e||".",showHideTrigger:t||r}),document.body)}var u=this&&this.__extends||function(){var e=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])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();Object.defineProperty(n,"__esModule",{value:!0});var h=e("fuse.js"),p=e("preact"),d=p.h,f=p.Component,v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(e){return d("li",null,d("a",{href:"#",onClick:function(t){t.preventDefault(),e.onClick()}},e.title))},t}(f),_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linkIndex=0,t.focusPlease=!1,t.navigatedByKeyboard=!1,t}return u(t,e),t.prototype.componentWillMount=function(){var e=this;this.setState({searchString:"",isVisible:!1,expanded:{},activeLinkIndex:-1,moduleResults:[]}),o(this.props.baseUrl+"/doc-index.json",function(t){e.setState({fuse:new h(t,{threshold:.25,caseSensitive:!0,includeScore:!0,tokenize:!0,keys:[{name:"name",weight:.7},{name:"module",weight:.3}]}),moduleResults:[]})},function(t){console&&console.error("could not load 'doc-index.json' for searching",t),e.setState({failedLoading:!0})}),document.addEventListener("mousedown",this.hide.bind(this)),document.addEventListener("keydown",function(t){e.state.isVisible&&("Escape"===t.key?e.hide():"ArrowUp"===t.key||"k"===t.key&&t.ctrlKey?(t.preventDefault(),e.navigateLinks(-1)):"ArrowDown"===t.key||"j"===t.key&&t.ctrlKey?(t.preventDefault(),e.navigateLinks(1)):"Enter"===t.key&&e.state.activeLinkIndex>=0&&e.followActiveLink()),"s"===t.key&&"input"!==t.target.tagName.toLowerCase()&&(t.preventDefault(),e.show())})},t.prototype.hide=function(){this.setState({isVisible:!1,searchString:""})},t.prototype.show=function(){this.state.isVisible||(this.focusPlease=!0,this.setState({isVisible:!0,activeLinkIndex:-1}))},t.prototype.toggleVisibility=function(){this.state.isVisible?this.hide():this.show()},t.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})},t.prototype.followActiveLink=function(){this.activeLinkAction&&this.activeLinkAction()},t.prototype.updateResults=function(){var e=this.input&&this.input.value||"",t={};this.state.fuse.search(e).forEach(function(e){var n=e.item.module;(t[n]||(t[n]=[])).push(e)});var n=[];for(var o in t)!function(e){var o=t[e],r=0;o.forEach(function(e){r+=1/e.score}),n.push({module:e,totalScore:1/r,items:o})}(o);n.sort(function(e,t){return e.totalScore-t.totalScore}),this.setState({searchString:e,isVisible:!0,moduleResults:n})},t.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},t.prototype.componentDidMount=function(){this.props.showHideTrigger(this.toggleVisibility.bind(this))},t.prototype.render=function(e,t){var n=this;if(t.failedLoading){var o="file:"==window.location.protocol;return d("div",{id:"search",class:t.isVisible?"":"hidden"},d("div",{id:"search-results"},d("p",{class:"error"},"Failed to load file 'doc-index.json' containing definitions in this package."),o?d("p",{class:"error"},"To use quick jump, load this page with HTTP (from a local static file web server) instead of using the ",d("code",null,"file://")," protocol. (For security reasons, it is not possible to fetch auxiliary files using JS in a HTML page opened with ",d("code",null,"file://"),".)"):[]))}this.linkIndex=0;var r=function(e){e.stopPropagation()},c=i(10,t.moduleResults).map(function(e){return n.renderResultsInModule(e)});return d("div",{id:"search",class:t.isVisible?"":"hidden"},d("div",{id:"search-form",onMouseDown:r},d("input",{placeholder:"Search in package by name",ref:function(e){n.input=e},onFocus:this.show.bind(this),onClick:this.show.bind(this),onInput:this.updateResults.bind(this)})),d("div",{id:"search-results",ref:function(e){n.searchResults=e},onMouseDown:r,onMouseOver:function(e){for(var t=e.target;t&&"function"==typeof t.getAttribute;){var o=t.getAttribute("data-link-index");if("string"==typeof o){var r=parseInt(o,10);n.setState({activeLinkIndex:r});break}t=t.parentNode}}},""===t.searchString?[d(a,null),d(s,null)]:0==c.length?d(l,{searchString:t.searchString}):d("ul",null,c)))},t.prototype.renderResultsInModule=function(e){var t=this,n=e.items,o=e.module,r=this.state.expanded[o]||n.length<=10,s=r?n:i(8,n),a=function(e){return d("li",{class:"search-result"},t.navigationLink(t.props.baseUrl+"/"+e.link,{},d(g,{html:e.display_html})))};return d("li",{class:"search-module"},d("h4",null,o),d("ul",null,s.map(function(e){return a(e.item)}),r?[]:d("li",{class:"more-results"},this.actionLink(function(){var e=Object.assign({},t.state.expanded);e[o]=!0,t.setState({expanded:e})},{},"show "+(n.length-s.length)+" more results from this module"))))},t.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))},t.prototype.actionLink=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=Object.assign({href:"#",onClick:function(t){t.preventDefault(),e()}},t);return this.menuLink.apply(this,[r,e].concat(n))},t.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,d.apply(void 0,["a",s].concat(o))},t}(f),g=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.shouldComponentUpdate=function(e){return this.props.html!==e.html},t.prototype.render=function(e){return d("div",{dangerouslySetInnerHTML:{__html:e.html}})},t}(f);n.init=c,window.quickNav={init:c}},{"fuse.js":2,preact:3}],2:[function(e,t,n){!function(e,o){"object"==typeof n&&"object"==typeof t?t.exports=o():"function"==typeof define&&define.amd?define("Fuse",[],o):"object"==typeof n?n.Fuse=o():e.Fuse=o()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t,n){"use strict";e.exports=function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(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(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(5),s=n(7),a=n(4),l=function(){function e(t,n){var r=n.location,i=void 0===r?0:r,s=n.distance,l=void 0===s?100:s,c=n.threshold,u=void 0===c?.6:c,h=n.maxPatternLength,p=void 0===h?32:h,d=n.isCaseSensitive,f=void 0!==d&&d,v=n.tokenSeparator,_=void 0===v?/ +/g:v,g=n.findAllMatches,m=void 0!==g&&g,y=n.minMatchCharLength,k=void 0===y?1:y;o(this,e),this.options={location:i,distance:l,threshold:u,maxPatternLength:p,isCaseSensitive:f,tokenSeparator:_,findAllMatches:m,minMatchCharLength:k},this.pattern=this.options.isCaseSensitive?t:t.toLowerCase(),this.pattern.length<=p&&(this.patternAlphabet=a(this.pattern))}return r(e,[{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 i(e,this.pattern,o);var r=this.options,a=r.location,l=r.distance,c=r.threshold,u=r.findAllMatches,h=r.minMatchCharLength;return s(e,this.pattern,this.patternAlphabet,{location:a,distance:l,threshold:c,findAllMatches:u,minMatchCharLength:h})}}]),e}();e.exports=l},function(e,t,n){"use strict";var o=n(0),r=function e(t,n,r){if(n){var i=n.indexOf("."),s=n,a=null;-1!==i&&(s=n.slice(0,i),a=n.slice(i+1));var l=t[s];if(null!==l&&void 0!==l)if(a||"string"!=typeof l&&"number"!=typeof l)if(o(l))for(var c=0,u=l.length;c<u;c+=1)e(l[c],a,r);else a&&e(l,a,r);else r.push(l.toString())}else r.push(t);return r};e.exports=function(e,t){return r(e,t,[])}},function(e,t,n){"use strict";e.exports=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&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||((r=i-1)-o+1>=t&&n.push([o,r]),o=-1)}return e[i-1]&&i-o>=t&&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 o=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:/ +/g,r=new RegExp(t.replace(o,"\\$&").replace(n,"|")),i=e.match(r),s=!!i,a=[];if(s)for(var l=0,c=i.length;l<c;l+=1){var u=i[l];a.push([e.indexOf(u),u.length-1])}return{score:s?.5:1,isMatch:s,matchedIndices:a}}},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 o=n(6),r=n(3);e.exports=function(e,t,n,i){for(var s=i.location,a=void 0===s?0:s,l=i.distance,c=void 0===l?100:l,u=i.threshold,h=void 0===u?.6:u,p=i.findAllMatches,d=void 0!==p&&p,f=i.minMatchCharLength,v=void 0===f?1:f,_=a,g=e.length,m=h,y=e.indexOf(t,_),k=t.length,b=[],x=0;x<g;x+=1)b[x]=0;if(-1!==y){var w=o(t,{errors:0,currentLocation:y,expectedLocation:_,distance:c});if(m=Math.min(w,m),-1!==(y=e.lastIndexOf(t,_+k))){var S=o(t,{errors:0,currentLocation:y,expectedLocation:_,distance:c});m=Math.min(S,m)}}y=-1;for(var L=[],C=1,M=k+g,N=1<<k-1,I=0;I<k;I+=1){for(var A=0,T=M;A<T;)o(t,{errors:I,currentLocation:_+T,expectedLocation:_,distance:c})<=m?A=T:M=T,T=Math.floor((M-A)/2+A);M=T;var O=Math.max(1,_-T+1),j=d?g:Math.min(_+T,g)+k,P=Array(j+2);P[j+1]=(1<<I)-1;for(var E=j;E>=O;E-=1){var R=E-1,U=n[e.charAt(R)];if(U&&(b[R]=1),P[E]=(P[E+1]<<1|1)&U,0!==I&&(P[E]|=(L[E+1]|L[E])<<1|1|L[E+1]),P[E]&N&&(C=o(t,{errors:I,currentLocation:R,expectedLocation:_,distance:c}))<=m){if(m=C,(y=R)<=_)break;O=Math.max(1,2*_-y)}}if(o(t,{errors:I+1,currentLocation:_,expectedLocation:_,distance:c})>m)break;L=P}return{isMatch:y>=0,score:0===C?.001:C,matchedIndices:r(b,v)}}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(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(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(1),s=n(2),a=n(0),l=function(){function e(t,n){var r=n.location,i=void 0===r?0:r,a=n.distance,l=void 0===a?100:a,c=n.threshold,u=void 0===c?.6:c,h=n.maxPatternLength,p=void 0===h?32:h,d=n.caseSensitive,f=void 0!==d&&d,v=n.tokenSeparator,_=void 0===v?/ +/g:v,g=n.findAllMatches,m=void 0!==g&&g,y=n.minMatchCharLength,k=void 0===y?1:y,b=n.id,x=void 0===b?null:b,w=n.keys,S=void 0===w?[]:w,L=n.shouldSort,C=void 0===L||L,M=n.getFn,N=void 0===M?s:M,I=n.sortFn,A=void 0===I?function(e,t){return e.score-t.score}:I,T=n.tokenize,O=void 0!==T&&T,j=n.matchAllTokens,P=void 0!==j&&j,E=n.includeMatches,R=void 0!==E&&E,U=n.includeScore,D=void 0!==U&&U,V=n.verbose,F=void 0!==V&&V;o(this,e),this.options={location:i,distance:l,threshold:u,maxPatternLength:p,isCaseSensitive:f,tokenSeparator:_,findAllMatches:m,minMatchCharLength:k,id:x,keys:S,includeMatches:R,includeScore:D,shouldSort:C,getFn:N,sortFn:A,verbose:F,tokenize:O,matchAllTokens:P},this.setCollection(t)}return r(e,[{key:"setCollection",value:function(e){return this.list=e,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=arguments.length>0&&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=arguments.length>0&&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||d.weight>1)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,l=e.index,c=t.tokenSearchers,u=void 0===c?[]:c,h=t.fullSearcher,p=void 0===h?[]:h,d=t.resultMap,f=void 0===d?{}:d,v=t.results,_=void 0===v?[]:v;if(void 0!==i&&null!==i){var g=!1,m=-1,y=0;if("string"==typeof i){this._log("\nKey: "+(""===n?"-":n));var k=p.search(i);if(this._log('Full text: "'+i+'", score: '+k.score),this.options.tokenize){for(var b=i.split(this.options.tokenSeparator),x=[],w=0;w<u.length;w+=1){var S=u[w];this._log('\nPattern: "'+S.pattern+'"');for(var L=!1,C=0;C<b.length;C+=1){var M=b[C],N=S.search(M),I={};N.isMatch?(I[M]=N.score,g=!0,L=!0,x.push(N.score)):(I[M]=1,this.options.matchAllTokens||x.push(1)),this._log('Token: "'+M+'", score: '+I[M])}L&&(y+=1)}m=x[0];for(var A=x.length,T=1;T<A;T+=1)m+=x[T];m/=A,this._log("Token score average:",m)}var O=k.score;m>-1&&(O=(O+m)/2),this._log("Score average:",O);var j=!this.options.tokenize||!this.options.matchAllTokens||y>=u.length;if(this._log("\nCheck Matches: "+j),(g||k.isMatch)&&j){var P=f[l];P?P.output.push({key:n,arrayIndex:r,value:i,score:O,matchedIndices:k.matchedIndices}):(f[l]={item:s,output:[{key:n,arrayIndex:r,value:i,score:O,matchedIndices:k.matchedIndices}]},_.push(f[l]))}}else if(a(i))for(var E=0,R=i.length;E<R;E+=1)this._analyze({key:n,arrayIndex:E,value:i[E],record:s,index:l},{resultMap:f,results:_,tokenSearchers:u,fullSearcher:p})}}},{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=0,a=1,l=0;l<i;l+=1){var c=r[l].score,u=e?e[r[l].key].weight:1,h=c*u;1!==u?a=Math.min(a,h):(r[l].nScore=h,s+=h)}t[n].score=1===a?s/i: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._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")&&i.arrayIndex>-1&&(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(){if(this.options.verbose){var e;(e=console).log.apply(e,arguments)}}}]),e}();e.exports=l}])})},{}],3:[function(e,t,n){!function(){"use strict";function e(){}function n(t,n){var o,r,i,s,a=T;for(s=arguments.length;s-- >2;)A.push(arguments[s]);for(n&&null!=n.children&&(A.length||A.push(n.children),delete n.children);A.length;)if((r=A.pop())&&void 0!==r.pop)for(s=r.length;s--;)A.push(r[s]);else"boolean"==typeof r&&(r=null),(i="function"!=typeof t)&&(null==r?r="":"number"==typeof r?r=String(r):"string"!=typeof r&&(i=!1)),i&&o?a[a.length-1]+=r:a===T?a=[r]:a.push(r),o=i;var l=new e;return l.nodeName=t,l.children=a,l.attributes=null==n?void 0:n,l.key=null==n?void 0:n.key,void 0!==I.vnode&&I.vnode(l),l}function o(e,t){for(var n in t)e[n]=t[n];return e}function r(e){!e.__d&&(e.__d=!0)&&1==P.push(e)&&(I.debounceRendering||O)(i)}function i(){var e,t=P;for(P=[];e=t.pop();)e.__d&&L(e)}function s(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&a(e,t.nodeName):n||e._componentConstructor===t.nodeName}function a(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function l(e){var t=o({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var r in n)void 0===t[r]&&(t[r]=n[r]);return t}function c(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}function u(e){var t=e.parentNode;t&&t.removeChild(e)}function h(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===j.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,d,s):e.removeEventListener(t,d,s),(e.__l||(e.__l={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e)p(e,t,null==o?"":o),null!=o&&!1!==o||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 p(e,t,n){try{e[t]=n}catch(e){}}function d(e){return this.__l[e.type](I.event&&I.event(e)||e)}function f(){for(var e;e=E.pop();)I.afterMount&&I.afterMount(e),e.componentDidMount&&e.componentDidMount()}function v(e,t,n,o,r,i){R++||(U=null!=r&&void 0!==r.ownerSVGElement,D=null!=e&&!("__preactattr_"in e));var s=_(e,t,n,o,i);return r&&s.parentNode!==r&&r.appendChild(s),--R||(D=!1,i||f()),s}function _(e,t,n,o,r){var i=e,s=U;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),m(e,!0))),i.__preactattr_=!0,i;var l=t.nodeName;if("function"==typeof l)return C(e,t,n,o);if(U="svg"===l||"foreignObject"!==l&&U,l=String(l),(!e||!a(e,l))&&(i=c(l,U),e)){for(;e.firstChild;)i.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(i,e),m(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!D&&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)&&g(i,p,n,o,D||null!=h.dangerouslySetInnerHTML),k(i,t.attributes,h),U=s,i}function g(e,t,n,o,r){var i,a,l,c,h,p=e.childNodes,d=[],f={},v=0,g=0,y=p.length,k=0,b=t?t.length:0;if(0!==y)for(L=0;L<y;L++){var x=p[L],w=x.__preactattr_;null!=(S=b&&w?x._component?x._component.__k:w.key:null)?(v++,f[S]=x):(w||(void 0!==x.splitText?!r||x.nodeValue.trim():r))&&(d[k++]=x)}if(0!==b)for(L=0;L<b;L++){h=null;var S=(c=t[L]).key;if(null!=S)v&&void 0!==f[S]&&(h=f[S],f[S]=void 0,v--);else if(!h&&g<k)for(i=g;i<k;i++)if(void 0!==d[i]&&s(a=d[i],c,r)){h=a,d[i]=void 0,i===k-1&&k--,i===g&&g++;break}h=_(h,c,n,o),l=p[L],h&&h!==e&&h!==l&&(null==l?e.appendChild(h):h===l.nextSibling?u(l):e.insertBefore(h,l))}if(v)for(var L in f)void 0!==f[L]&&m(f[L],!1);for(;g<=k;)void 0!==(h=d[k--])&&m(h,!1)}function m(e,t){var n=e._component;n?M(n):(null!=e.__preactattr_&&e.__preactattr_.ref&&e.__preactattr_.ref(null),!1!==t&&null!=e.__preactattr_||u(e),y(e))}function y(e){for(e=e.lastChild;e;){var t=e.previousSibling;m(e,!0),e=t}}function k(e,t,n){var o;for(o in n)t&&null!=t[o]||null==n[o]||h(e,o,n[o],n[o]=void 0,U);for(o in t)"children"===o||"innerHTML"===o||o in n&&t[o]===("value"===o||"checked"===o?e[o]:n[o])||h(e,o,n[o],n[o]=t[o],U)}function b(e){var t=e.constructor.name;(V[t]||(V[t]=[])).push(e)}function x(e,t,n){var o,r=V[e.name];if(e.prototype&&e.prototype.render?(o=new e(t,n),N.call(o,t,n)):((o=new N(t,n)).constructor=e,o.render=w),r)for(var i=r.length;i--;)if(r[i].constructor===e){o.__b=r[i].__b,r.splice(i,1);break}return o}function w(e,t,n){return this.constructor(e,n)}function S(e,t,n,o,i){e.__x||(e.__x=!0,(e.__r=t.ref)&&delete t.ref,(e.__k=t.key)&&delete t.key,!e.base||i?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===I.syncComponentUpdates&&e.base?r(e):L(e,1,i)),e.__r&&e.__r(e))}function L(e,t,n,r){if(!e.__x){var i,s,a,c=e.props,u=e.state,h=e.context,p=e.__p||c,d=e.__s||u,_=e.__c||h,g=e.base,y=e.__b,k=g||y,b=e._component,w=!1;if(g&&(e.props=p,e.state=d,e.context=_,2!==t&&e.shouldComponentUpdate&&!1===e.shouldComponentUpdate(c,u,h)?w=!0:e.componentWillUpdate&&e.componentWillUpdate(c,u,h),e.props=c,e.state=u,e.context=h),e.__p=e.__s=e.__c=e.__b=null,e.__d=!1,!w){i=e.render(c,u,h),e.getChildContext&&(h=o(o({},h),e.getChildContext()));var C,N,A=i&&i.nodeName;if("function"==typeof A){var T=l(i);(s=b)&&s.constructor===A&&T.key==s.__k?S(s,T,1,h,!1):(C=s,e._component=s=x(A,T,h),s.__b=s.__b||y,s.__u=e,S(s,T,0,h,!1),L(s,1,n,!0)),N=s.base}else a=k,(C=b)&&(a=e._component=null),(k||1===t)&&(a&&(a._component=null),N=v(a,i,h,n||!g,k&&k.parentNode,!0));if(k&&N!==k&&s!==b){var O=k.parentNode;O&&N!==O&&(O.replaceChild(N,k),C||(k._component=null,m(k,!1)))}if(C&&M(C),e.base=N,N&&!r){for(var j=e,P=e;P=P.__u;)(j=P).base=N;N._component=j,N._componentConstructor=j.constructor}}if(!g||n?E.unshift(e):w||(e.componentDidUpdate&&e.componentDidUpdate(p,d,_),I.afterUpdate&&I.afterUpdate(e)),null!=e.__h)for(;e.__h.length;)e.__h.pop().call(e);R||r||f()}}function C(e,t,n,o){for(var r=e&&e._component,i=r,s=e,a=r&&e._componentConstructor===t.nodeName,c=a,u=l(t);r&&!c&&(r=r.__u);)c=r.constructor===t.nodeName;return r&&c&&(!o||r._component)?(S(r,u,3,n,o),e=r.base):(i&&!a&&(M(i),e=s=null),r=x(t.nodeName,u,n),e&&!r.__b&&(r.__b=e,s=null),S(r,u,1,n,o),e=r.base,s&&e!==s&&(s._component=null,m(s,!1))),e}function M(e){I.beforeUnmount&&I.beforeUnmount(e);var t=e.base;e.__x=!0,e.componentWillUnmount&&e.componentWillUnmount(),e.base=null;var n=e._component;n?M(n):t&&(t.__preactattr_&&t.__preactattr_.ref&&t.__preactattr_.ref(null),e.__b=t,u(t),b(e),y(t)),e.__r&&e.__r(null)}function N(e,t){this.__d=!0,this.context=t,this.props=e,this.state=this.state||{}}var I={},A=[],T=[],O="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout,j=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,P=[],E=[],R=0,U=!1,D=!1,V={};o(N.prototype,{setState:function(e,t){var n=this.state;this.__s||(this.__s=o({},n)),o(n,"function"==typeof e?e(n,this.props):e),t&&(this.__h=this.__h||[]).push(t),r(this)},forceUpdate:function(e){e&&(this.__h=this.__h||[]).push(e),L(this,2)},render:function(){}});var F={h:n,createElement:n,cloneElement:function(e,t){return n(e.nodeName,o(o({},e.attributes),t),arguments.length>2?[].slice.call(arguments,2):e.children)},Component:N,render:function(e,t,n){return v(n,e,{},!1,t,!1)},rerender:i,options:I};void 0!==t?t.exports=F:self.preact=F}()},{}]},{},[1]); //# sourceMappingURL=quick-jump.min.js.map
src/Haddock.hs view
@@ -75,6 +75,7 @@ import Panic (handleGhcException) import Module import FastString+import qualified DynamicLoading  -------------------------------------------------------------------------------- -- * Exception handling@@ -437,7 +438,10 @@   -- that may need to be re-linked: Haddock doesn't do any   -- dynamic or static linking at all!   _ <- setSessionDynFlags dynflags''-  ghcActs dynflags''+  hscenv <- GHC.getSession+  dynflags''' <- liftIO (DynamicLoading.initializePlugins hscenv dynflags'')+  _ <- setSessionDynFlags dynflags'''+  ghcActs dynflags'''   where      -- ignore sublists of flags that start with "+RTS" and end in "-RTS"
src/Haddock/Backends/Hoogle.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE TypeFamilies #-} ----------------------------------------------------------------------------- -- | -- Module      :  Haddock.Backends.Hoogle@@ -45,13 +46,15 @@  ppHoogle :: DynFlags -> String -> Version -> String -> Maybe (Doc RdrName) -> [Interface] -> FilePath -> IO () ppHoogle dflags package version synopsis prologue ifaces odir = do-    let filename = package ++ ".txt"+    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 +++                   docWith dflags' (drop 2 $ dropWhile (/= ':') synopsis) prologue ++                    ["@package " ++ package] ++                    ["@version " ++ showVersion version                    | not (null (versionBranch version)) ] ++-                   concat [ppModule dflags i | i <- ifaces, OptHide `notElem` ifaceOptions i]+                   concat [ppModule dflags' i | i <- ifaces, OptHide `notElem` ifaceOptions i]     createDirectoryIfMissing True odir     h <- openFile (odir </> filename) WriteMode     hSetEncoding h utf8@@ -73,23 +76,22 @@ dropHsDocTy = f     where         g (L src x) = L src (f x)-        f (HsForAllTy a e) = HsForAllTy a (g e)-        f (HsQualTy a e) = HsQualTy a (g e)-        f (HsBangTy a b) = HsBangTy a (g b)-        f (HsAppTy a b) = HsAppTy (g a) (g b)-        f (HsFunTy a b) = HsFunTy (g a) (g b)-        f (HsListTy a) = HsListTy (g a)-        f (HsPArrTy a) = HsPArrTy (g a)-        f (HsTupleTy a b) = HsTupleTy a (map g b)-        f (HsOpTy a b c) = HsOpTy (g a) b (g c)-        f (HsParTy a) = HsParTy (g a)-        f (HsKindSig a b) = HsKindSig (g a) b-        f (HsDocTy a _) = f $ unL a+        f (HsForAllTy x a e) = HsForAllTy x a (g e)+        f (HsQualTy x a e) = HsQualTy x a (g e)+        f (HsBangTy x a b) = HsBangTy x a (g b)+        f (HsAppTy x a b) = HsAppTy x (g a) (g b)+        f (HsFunTy x a b) = HsFunTy x (g a) (g b)+        f (HsListTy x a) = HsListTy x (g a)+        f (HsTupleTy x a b) = HsTupleTy x a (map g b)+        f (HsOpTy x a b c) = HsOpTy x (g a) b (g c)+        f (HsParTy x a) = HsParTy x (g a)+        f (HsKindSig x a b) = HsKindSig x (g a) b+        f (HsDocTy _ a _) = f $ unL a         f x = x -outHsType :: (SourceTextX a, OutputableBndrId a)+outHsType :: (a ~ GhcPass p, OutputableBndrId a)           => DynFlags -> HsType a -> String-outHsType dflags = out dflags . dropHsDocTy+outHsType dflags = out dflags . reparenType . dropHsDocTy   dropComment :: String -> String@@ -123,28 +125,25 @@                            , expItemMbDoc   = (dc, _)                            , expItemSubDocs = subdocs                            , expItemFixities = fixities-                           } = ppDocumentation dflags dc ++ f decl+                           } = ppDocumentation dflags dc ++ f decl ++ ppFixities     where-        f (TyClD d@DataDecl{})  = ppData dflags d subdocs-        f (TyClD d@SynDecl{})   = ppSynonym dflags d-        f (TyClD d@ClassDecl{}) = ppClass dflags d subdocs-        f (ForD (ForeignImport name typ _ _)) = [pp_sig dflags [name] (hsSigType typ)]-        f (ForD (ForeignExport name typ _ _)) = [pp_sig dflags [name] (hsSigType typ)]-        f (SigD sig) = ppSig dflags sig ++ ppFixities+        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] (hsSigType typ)]+        f (ForD _ (ForeignExport _ name typ _)) = [pp_sig dflags [name] (hsSigType typ)]+        f (SigD _ sig) = ppSig dflags sig         f _ = []          ppFixities = concatMap (ppFixity dflags) fixities ppExport _ _ = []  ppSigWithDoc :: DynFlags -> Sig GhcRn -> [(Name, DocForDecl Name)] -> [String]-ppSigWithDoc dflags (TypeSig names sig) subdocs+ppSigWithDoc dflags (TypeSig _ names sig) subdocs     = concatMap mkDocSig names     where-        mkDocSig n = concatMap (ppDocumentation dflags) (getDoc n)-                     ++ [pp_sig dflags [n] (hsSigWcType sig)]--        getDoc :: Located Name -> [Documentation Name]-        getDoc n = maybe [] (return . fst) (lookup (unL n) subdocs)+        mkDocSig n = mkSubdoc dflags n subdocs [pp_sig dflags [n] (hsSigWcType sig)]  ppSigWithDoc _ _ _ = [] @@ -172,10 +171,14 @@         ppTyFams             | null $ tcdATs decl = ""             | otherwise = (" " ++) . showSDocUnqual dflags . whereWrapper $ concat-                [ map ppr (tcdATs decl)+                [ map pprTyFam (tcdATs decl)                 , map (ppr . tyFamEqnToSyn . unLoc) (tcdATDefs decl)                 ] +        pprTyFam :: LFamilyDecl GhcRn -> SDoc+        pprTyFam (L _ at) = vcat' $ map text $+            mkSubdoc dflags (fdLName at) subdocs (ppFam dflags at)+         whereWrapper elems = vcat'             [ text "where" <+> lbrace             , nest 4 . vcat . map (Outputable.<> semi) $ elems@@ -188,9 +191,19 @@             , tcdTyVars = feqn_pats tfe             , tcdFixity = feqn_fixity tfe             , tcdRhs    = feqn_rhs tfe-            , tcdFVs    = emptyNameSet+            , tcdSExt   = emptyNameSet             } +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+ppFam _ XFamilyDecl {} = panic "ppFam"  ppInstance :: DynFlags -> ClsInst -> [String] ppInstance dflags x =@@ -213,13 +226,12 @@       concatMap (ppCtor dflags decl subdocs . unL) (dd_cons defn)     where -        -- GHC gives out "data Bar =", we want to delete the equals-        -- also writes data : a b, when we want data (:) a b-        showData d = unwords $ map f $ if last xs == "=" then init xs else xs+        -- GHC gives out "data Bar =", we want to delete the equals.+        -- There's no need to worry about parenthesizing infix data type names,+        -- since this Outputable instance for TyClDecl gets this right already.+        showData d = unwords $ if last xs == "=" then init xs else xs             where                 xs = words $ out dflags d-                nam = out dflags $ tyClDeclLName d-                f w = if w == nam then operator nam else w ppData _ _ _ = panic "ppData"  -- | for constructors, and named-fields...@@ -231,17 +243,17 @@ ppCtor :: DynFlags -> TyClDecl GhcRn -> [(Name, DocForDecl Name)] -> ConDecl GhcRn -> [String] ppCtor dflags dat subdocs con@ConDeclH98 {}   -- AZ:TODO get rid of the concatMap-   = concatMap (lookupCon dflags subdocs) [con_name con] ++ f (getConDetails con)+   = concatMap (lookupCon dflags subdocs) [con_name con] ++ f (getConArgs con)     where         f (PrefixCon args) = [typeSig name $ args ++ [resType]]         f (InfixCon a1 a2) = f $ PrefixCon [a1,a2]         f (RecCon (L _ recs)) = f (PrefixCon $ map cd_fld_type (map unLoc recs)) ++ concat-                          [(concatMap (lookupCon dflags subdocs . noLoc . selectorFieldOcc . unLoc) (cd_fld_names r)) ++-                           [out dflags (map (selectorFieldOcc . unLoc) $ cd_fld_names r) `typeSig` [resType, cd_fld_type r]]+                          [(concatMap (lookupCon dflags subdocs . noLoc . extFieldOcc . unLoc) (cd_fld_names r)) +++                           [out dflags (map (extFieldOcc . unLoc) $ cd_fld_names r) `typeSig` [resType, cd_fld_type r]]                           | r <- map unLoc recs] -        funs = foldr1 (\x y -> reL $ HsFunTy x y)-        apps = foldl1 (\x y -> reL $ HsAppTy x y)+        funs = foldr1 (\x y -> reL $ HsFunTy NoExt x y)+        apps = foldl1 (\x y -> reL $ HsAppTy NoExt x y)          typeSig nm flds = operator nm ++ " :: " ++ outHsType dflags (unL $ funs flds) @@ -249,20 +261,20 @@         -- docs for con_names on why it is a list to begin with.         name = commaSeparate dflags . map unL $ getConNames con -        resType = apps $ map (reL . HsTyVar NotPromoted . reL) $-                        (tcdName dat) : [hsTyVarName v | L _ v@(UserTyVar _) <- hsQTvExplicit $ tyClDeclTyVars dat]+        resType = apps $ map (reL . HsTyVar NoExt NotPromoted . reL) $+                        (tcdName dat) : [hsTyVarName v | L _ v@(UserTyVar _ _) <- hsQTvExplicit $ tyClDeclTyVars dat] -ppCtor dflags _dat subdocs con@ConDeclGADT {}+ppCtor dflags _dat subdocs con@(ConDeclGADT { })    = concatMap (lookupCon dflags subdocs) (getConNames con) ++ f     where-        f = [typeSig name (hsib_body $ con_type con)]+        f = [typeSig name (getGADTConTypeG con)]          typeSig nm ty = operator nm ++ " :: " ++ outHsType dflags (unL ty)         name = out dflags $ map unL $ getConNames con-+ppCtor _ _ _ XConDecl {} = panic "haddock:ppCtor"  ppFixity :: DynFlags -> (Name, Fixity) -> [String]-ppFixity dflags (name, fixity) = [out dflags ((FixitySig [noLoc name] fixity) :: FixitySig GhcRn)]+ppFixity dflags (name, fixity) = [out dflags ((FixitySig noExt [noLoc name] fixity) :: FixitySig GhcRn)]   ---------------------------------------------------------------------@@ -285,6 +297,10 @@     lines header ++ ["" | header /= "" && isJust d] ++     maybe [] (showTags . markup (markupTag dflags)) d +mkSubdoc :: DynFlags -> Located Name -> [(Name, DocForDecl Name)] -> [String] -> [String]+mkSubdoc dflags n subdocs s = concatMap (ppDocumentation dflags) getDoc ++ s+ where+   getDoc = maybe [] (return . fst) (lookup (unL n) subdocs)  data Tag = TagL Char [Tags] | TagP Tags | TagPre Tags | TagInline String Tags | Str String            deriving Show
src/Haddock/Backends/Hyperlinker/Ast.hs view
@@ -13,6 +13,7 @@  import qualified GHC import qualified SrcLoc+import qualified Outputable as GHC  import Control.Applicative import Control.Monad (guard)@@ -79,9 +80,9 @@     everythingInRenamedSource (var `Syb.combine` rec)   where     var term = case cast term of-        (Just ((GHC.L sspan (GHC.HsVar name)) :: GHC.LHsExpr GHC.GhcRn)) ->+        (Just ((GHC.L sspan (GHC.HsVar _ name)) :: GHC.LHsExpr GHC.GhcRn)) ->             pure (sspan, RtkVar (GHC.unLoc name))-        (Just (GHC.L _ (GHC.RecordCon (GHC.L sspan name) _ _ _))) ->+        (Just (GHC.L _ (GHC.RecordCon _ (GHC.L sspan name) _))) ->             pure (sspan, RtkVar name)         _ -> empty     rec term = case cast term of@@ -95,9 +96,9 @@   where     ty :: forall a. Data a => a -> [(GHC.SrcSpan, TokenDetails)]     ty term = case cast term of-        (Just ((GHC.L sspan (GHC.HsTyVar _ name)) :: GHC.LHsType GHC.GhcRn)) ->+        (Just ((GHC.L sspan (GHC.HsTyVar _ _ name)) :: GHC.LHsType GHC.GhcRn)) ->             pure (sspan, RtkType (GHC.unLoc name))-        (Just ((GHC.L sspan (GHC.HsOpTy l name r)) :: GHC.LHsType GHC.GhcRn)) ->+        (Just ((GHC.L sspan (GHC.HsOpTy _ l name r)) :: GHC.LHsType GHC.GhcRn)) ->             (sspan, RtkType (GHC.unLoc name)):(ty l ++ ty r)         _ -> empty @@ -112,20 +113,20 @@       (fun `Syb.combine` pat `Syb.combine` tvar)   where     fun term = case cast term of-        (Just (GHC.FunBind (GHC.L sspan name) _ _ _ _ :: GHC.HsBind GHC.GhcRn)) ->+        (Just (GHC.FunBind _ (GHC.L sspan name) _ _ _ :: GHC.HsBind GHC.GhcRn)) ->             pure (sspan, RtkBind name)-        (Just (GHC.PatSynBind (GHC.PSB (GHC.L sspan name) _ args _ _))) ->+        (Just (GHC.PatSynBind _ (GHC.PSB _ (GHC.L sspan name) args _ _))) ->             pure (sspan, RtkBind name) ++ everythingInRenamedSource patsyn_binds args         _ -> empty     patsyn_binds term = case cast term of         (Just (GHC.L sspan (name :: GHC.Name))) -> pure (sspan, RtkVar name)         _ -> empty     pat term = case cast term of-        (Just ((GHC.L sspan (GHC.VarPat name)) :: GHC.LPat GHC.GhcRn)) ->+        (Just ((GHC.L sspan (GHC.VarPat _ name)) :: GHC.LPat GHC.GhcRn)) ->             pure (sspan, RtkBind (GHC.unLoc name))         (Just (GHC.L _ (GHC.ConPatIn (GHC.L sspan name) recs))) ->             [(sspan, RtkVar name)] ++ everythingInRenamedSource rec recs-        (Just (GHC.L _ (GHC.AsPat (GHC.L sspan name) _))) ->+        (Just (GHC.L _ (GHC.AsPat _ (GHC.L sspan name) _))) ->             pure (sspan, RtkBind name)         _ -> empty     rec term = case cast term of@@ -133,9 +134,9 @@             pure (sspan, RtkVar name)         _ -> empty     tvar term = case cast term of-        (Just ((GHC.L sspan (GHC.UserTyVar name)) :: GHC.LHsTyVarBndr GHC.GhcRn)) ->+        (Just ((GHC.L sspan (GHC.UserTyVar _ name)) :: GHC.LHsTyVarBndr GHC.GhcRn)) ->             pure (sspan, RtkBind (GHC.unLoc name))-        (Just (GHC.L _ (GHC.KindedTyVar (GHC.L sspan name) _))) ->+        (Just (GHC.L _ (GHC.KindedTyVar _ (GHC.L sspan name) _))) ->             pure (sspan, RtkBind name)         _ -> empty @@ -150,16 +151,17 @@   where     typ (GHC.L _ t) = case t of         GHC.DataDecl { tcdLName = name } -> pure . decl $ name-        GHC.SynDecl name _ _ _ _ -> pure . decl $ name-        GHC.FamDecl fam -> pure . decl $ GHC.fdLName fam+        GHC.SynDecl _ name _ _ _ -> pure . decl $ name+        GHC.FamDecl _ fam -> pure . decl $ GHC.fdLName fam         GHC.ClassDecl{..} ->           [decl tcdLName]             ++ concatMap sig tcdSigs             ++ concatMap tyfam tcdATs+        GHC.XTyClDecl {} -> GHC.panic "haddock:decls"     fun term = case cast term of-        (Just (GHC.FunBind (GHC.L sspan name) _ _ _ _ :: GHC.HsBind GHC.GhcRn))+        (Just (GHC.FunBind _ (GHC.L sspan name) _ _ _ :: GHC.HsBind GHC.GhcRn))             | GHC.isExternalName name -> pure (sspan, RtkDecl name)-        (Just (GHC.PatSynBind (GHC.PSB (GHC.L sspan name) _ _ _ _)))+        (Just (GHC.PatSynBind _ (GHC.PSB _ (GHC.L sspan name) _ _ _)))             | GHC.isExternalName name -> pure (sspan, RtkDecl name)         _ -> empty     con term = case cast term of@@ -168,24 +170,27 @@               ++ everythingInRenamedSource fld cdcl         Nothing -> empty     ins term = case cast term of-        (Just ((GHC.DataFamInstD (GHC.DataFamInstDecl eqn))+        (Just ((GHC.DataFamInstD _ (GHC.DataFamInstDecl eqn))                 :: GHC.InstDecl GHC.GhcRn))           -> pure . tyref $ GHC.feqn_tycon $ GHC.hsib_body eqn-        (Just (GHC.TyFamInstD (GHC.TyFamInstDecl eqn))) ->+        (Just (GHC.TyFamInstD _ (GHC.TyFamInstDecl eqn))) ->             pure . tyref $ GHC.feqn_tycon $ GHC.hsib_body eqn         _ -> empty     fld term = case cast term of         Just (field :: GHC.ConDeclField GHC.GhcRn)-          -> map (decl . fmap GHC.selectorFieldOcc) $ GHC.cd_fld_names field+          -> map (decl . fmap GHC.extFieldOcc) $ GHC.cd_fld_names field         Nothing -> empty     fix term = case cast term of-        Just ((GHC.FixitySig names _) :: GHC.FixitySig GHC.GhcRn)-          -> map decl names+        Just ((GHC.FixitySig _ names _) :: GHC.FixitySig GHC.GhcRn)+          -> map (\(GHC.L sspan x) -> (sspan, RtkVar x)) names+        Just ((GHC.XFixitySig {}) :: GHC.FixitySig GHC.GhcRn)+          -> GHC.panic "haddock:decls"         Nothing -> empty     tyfam (GHC.L _ (GHC.FamilyDecl{..})) = [decl fdLName]-    sig (GHC.L _ (GHC.TypeSig names _)) = map decl names-    sig (GHC.L _ (GHC.PatSynSig names _)) = map decl names-    sig (GHC.L _ (GHC.ClassOpSig _ names _)) = map decl names+    tyfam (GHC.L _ (GHC.XFamilyDecl {})) = GHC.panic "haddock:dels"+    sig (GHC.L _ (GHC.TypeSig _ names _)) = map decl names+    sig (GHC.L _ (GHC.PatSynSig _ names _)) = map decl names+    sig (GHC.L _ (GHC.ClassOpSig _ _ names _)) = map decl names     sig _ = []     decl (GHC.L sspan name) = (sspan, RtkDecl name)     tyref (GHC.L sspan name) = (sspan, RtkType name)@@ -199,12 +204,12 @@     everythingInRenamedSource ie src ++ mapMaybe (imp . GHC.unLoc) imps   where     ie term = case cast term of-        (Just ((GHC.IEVar v) :: GHC.IE GHC.GhcRn)) -> pure $ var $ GHC.ieLWrappedName v-        (Just (GHC.IEThingAbs t)) -> pure $ typ $ GHC.ieLWrappedName t-        (Just (GHC.IEThingAll t)) -> pure $ typ $ GHC.ieLWrappedName t-        (Just (GHC.IEThingWith t _ vs _fls)) ->+        (Just ((GHC.IEVar _ v) :: GHC.IE GHC.GhcRn)) -> pure $ var $ GHC.ieLWrappedName v+        (Just (GHC.IEThingAbs _ t)) -> pure $ typ $ GHC.ieLWrappedName t+        (Just (GHC.IEThingAll _ t)) -> pure $ typ $ GHC.ieLWrappedName t+        (Just (GHC.IEThingWith _ t _ vs _fls)) ->           [typ $ GHC.ieLWrappedName t] ++ map (var . GHC.ieLWrappedName) vs-        (Just (GHC.IEModuleContents m)) -> pure $ modu m+        (Just (GHC.IEModuleContents _ m)) -> pure $ modu m         _ -> empty     typ (GHC.L sspan name) = (sspan, RtkType name)     var (GHC.L sspan name) = (sspan, RtkVar name)
src/Haddock/Backends/Hyperlinker/Parser.hs view
@@ -3,6 +3,8 @@ import Data.Either         ( isRight, isLeft ) import Data.List           ( foldl', isPrefixOf, isSuffixOf ) import Data.Maybe          ( maybeToList )+import Data.Char           ( isSpace )+import qualified Text.Read as R  import GHC                 ( DynFlags, addSourceToTokens ) import SrcLoc@@ -24,8 +26,13 @@ -- (In reality, this only holds for input not containing '\r', '\t', '\f', '\v', -- characters, since GHC transforms those into ' ' and '\n') parse :: DynFlags -> FilePath -> String -> [T.Token]-parse dflags fp s = ghcToks (processCPP dflags fp s)-+parse dflags fp = ghcToks . processCPP dflags fp . filterCRLF+  where+    -- Remove CRLFs from source+    filterCRLF :: String -> String+    filterCRLF ('\r':'\n':cs) = '\n' : filterCRLF cs+    filterCRLF (c:cs) = c : filterCRLF cs+    filterCRLF [] = []  -- | Parse the source into tokens using the GHC lexer. --@@ -104,12 +111,9 @@ isCPPline = isPrefixOf "#" . dropWhile (`elem` " \t") . take 5  --- | Split a "line" off the front of a string, supporting newline escapes.------ By "line", we understand: the shortest substring ending in a '\n' that is not------   1. immediately preceded by a '\\'---   2. not inside some (possibly nested) block comment+-- | Split a "line" off the front of a string, hopefully without cutting tokens+-- in half. I say "hopefully" because knowing what a token is requires lexing,+-- yet lexing depends on this function. -- -- All characters in the input are present in the output: --@@ -117,17 +121,36 @@ spanToNewline :: Int                 -- ^ open '{-'               -> String              -- ^ input               -> (String, String)-spanToNewline _ [] = ([], [])++-- Base case and space characters+spanToNewline _ "" = ("", "") spanToNewline n ('\n':str) | n <= 0 = ("\n", str)+spanToNewline n ('\n':str) | n <= 0 = ("\n", str) spanToNewline n ('\\':'\n':str) =     let (str', rest) = spanToNewline n str     in ('\\':'\n':str', rest)++-- Block comments spanToNewline n ('{':'-':str) =     let (str', rest) = spanToNewline (n+1) str     in ('{':'-':str', rest) spanToNewline n ('-':'}':str) =     let (str', rest) = spanToNewline (n-1) str     in ('-':'}':str', rest)++-- When not in a block comment, try to lex a Haskell token+spanToNewline 0 str@(c:_) | ((lexed, str') : _) <- R.lex str, not (isSpace c) =+    if all (== '-') lexed && length lexed >= 2+      -- A Haskell line comment+      then case span (/= '\n') str' of+             (str'', '\n':rest) -> (lexed ++ str'' ++ "\n", rest)+             (_, _) -> (str, "") ++      -- An actual Haskell token+      else let (str'', rest) = spanToNewline 0 str'+           in (lexed ++ str'', rest)++-- In all other cases, advance one character at a time spanToNewline n (c:str) =     let (str', rest) = spanToNewline n str     in (c:str', rest)@@ -211,6 +234,7 @@     ITqualified            -> TkKeyword     ITthen                 -> TkKeyword     ITtype                 -> TkKeyword+    ITvia                  -> TkKeyword     ITwhere                -> TkKeyword      ITforall            {} -> TkKeyword@@ -261,9 +285,6 @@     IToptions_prag      {} -> TkPragma     ITinclude_prag      {} -> TkPragma     ITlanguage_prag        -> TkPragma-    ITvect_prag         {} -> TkPragma-    ITvect_scalar_prag  {} -> TkPragma-    ITnovect_prag       {} -> TkPragma     ITminimal_prag      {} -> TkPragma     IToverlappable_prag {} -> TkPragma     IToverlapping_prag  {} -> TkPragma@@ -282,11 +303,11 @@     ITrarrow            {} -> TkGlyph     ITat                   -> TkGlyph     ITtilde                -> TkGlyph-    ITtildehsh             -> TkGlyph     ITdarrow            {} -> TkGlyph     ITminus                -> TkGlyph     ITbang                 -> TkGlyph     ITdot                  -> TkOperator+    ITstar              {} -> TkOperator     ITtypeApp              -> TkGlyph      ITbiglam               -> TkGlyph@@ -408,9 +429,6 @@     IToptions_prag      {} -> True     ITinclude_prag      {} -> True     ITlanguage_prag        -> True-    ITvect_prag         {} -> True-    ITvect_scalar_prag  {} -> True-    ITnovect_prag       {} -> True     ITminimal_prag      {} -> True     IToverlappable_prag {} -> True     IToverlapping_prag  {} -> True
src/Haddock/Backends/Hyperlinker/Renderer.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE RecordWildCards #-} - module Haddock.Backends.Hyperlinker.Renderer (render) where  @@ -28,36 +27,10 @@        -> Html render mcss mjs srcs tokens = header mcss mjs <> body srcs tokens --data TokenGroup-    = GrpNormal Token-    | GrpRich TokenDetails [Token]----- | Group consecutive tokens pointing to the same element.------ We want to render qualified identifiers as one entity. For example,--- @Bar.Baz.foo@ consists of 5 tokens (@Bar@, @.@, @Baz@, @.@, @foo@) but for--- better user experience when highlighting and clicking links, these tokens--- should be regarded as one identifier. Therefore, before rendering we must--- group consecutive elements pointing to the same 'GHC.Name' (note that even--- dot token has it if it is part of qualified name).-groupTokens :: [RichToken] -> [TokenGroup]-groupTokens [] = []-groupTokens ((RichToken tok Nothing):rest) = (GrpNormal tok):(groupTokens rest)-groupTokens ((RichToken tok (Just det)):rest) =-    let (grp, rest') = span same rest-    in (GrpRich det (tok:(map rtkToken grp))):(groupTokens rest')-  where-    same (RichToken _ (Just det')) = det == det'-    same _ = False-- body :: SrcMap -> [RichToken] -> Html-body srcs tokens =-    Html.body . Html.pre $ hypsrc+body srcs tokens = Html.body . Html.pre $ hypsrc   where-    hypsrc = mconcat . map (tokenGroup srcs) . groupTokens $ tokens+    hypsrc = mconcat . map (richToken srcs) $ tokens   header :: Maybe FilePath -> Maybe FilePath -> Html@@ -78,29 +51,20 @@         , Html.src scriptFile         ] --tokenGroup :: SrcMap -> TokenGroup -> Html-tokenGroup _ (GrpNormal tok@(Token { .. }))+-- | Given information about the source position of definitions, render a token+richToken :: SrcMap -> RichToken -> Html+richToken srcs (RichToken Token{..} details)     | tkType == TkSpace = renderSpace (GHC.srcSpanStartLine tkSpan) tkValue-    | otherwise = tokenSpan tok ! attrs-  where-    attrs = [ multiclass . tokenStyle $ tkType ]-tokenGroup srcs (GrpRich det tokens) =-    externalAnchor det . internalAnchor det . hyperlink srcs det $ content-  where-    content = mconcat . map (richToken det) $ tokens---richToken :: TokenDetails -> Token -> Html-richToken det tok =-    tokenSpan tok ! [ multiclass style ]+    | otherwise = linked content   where-    style = (tokenStyle . tkType) tok ++ richTokenStyle det---tokenSpan :: Token -> Html-tokenSpan = Html.thespan . Html.toHtml . tkValue+    content = tokenSpan ! [ multiclass style ]+    tokenSpan = Html.thespan (Html.toHtml tkValue)+    style = tokenStyle tkType ++ maybe [] richTokenStyle details +    -- If we have name information, we can make links+    linked = case details of+      Just d -> externalAnchor d . internalAnchor d . hyperlink srcs d+      Nothing -> id  richTokenStyle :: TokenDetails -> [StyleClass] richTokenStyle (RtkVar _) = ["hs-var"]
src/Haddock/Backends/LaTeX.hs view
@@ -27,7 +27,7 @@ import OccName import Name                 ( nameOccName ) import RdrName              ( rdrNameOcc )-import FastString           ( unpackFS, unpackLitString, zString )+import FastString           ( unpackFS ) import Outputable           ( panic)  import qualified Data.Map as Map@@ -169,23 +169,16 @@        body = processExports exports   ---  writeFile (odir </> moduleLaTeXFile mdl) (fullRender PageMode 80 1 string_txt "" tex)---string_txt :: TextDetails -> String -> String-string_txt (Chr c)   s  = c:s-string_txt (Str s1)  s2 = s1 ++ s2-string_txt (PStr s1) s2 = unpackFS s1 ++ s2-string_txt (ZStr s1) s2 = zString s1 ++ s2-string_txt (LStr s1 _) s2 = unpackLitString s1 ++ s2-+  writeFile (odir </> moduleLaTeXFile mdl) (fullRender PageMode 80 1 txtPrinter "" tex) +-- | Prints out an entry in a module export list. exportListItem :: ExportItem DocNameI -> LaTeX exportListItem ExportDecl { expItemDecl = decl, expItemSubDocs = subdocs }-  = sep (punctuate comma . map ppDocBinder $ declNames decl) <>-     case subdocs of-       [] -> empty-       _  -> parens (sep (punctuate comma (map (ppDocBinder . fst) subdocs)))+  = let (leader, names) = declNames decl+    in sep (punctuate comma [ leader <+> ppDocBinder name | name <- names ]) <>+         case subdocs of+           [] -> empty+           _  -> parens (sep (punctuate comma (map (ppDocBinder . fst) subdocs))) exportListItem (ExportNoDecl y [])   = ppDocBinder y exportListItem (ExportNoDecl y subs)@@ -215,7 +208,7 @@   isSimpleSig :: ExportItem DocNameI -> Maybe ([DocName], HsType DocNameI)-isSimpleSig ExportDecl { expItemDecl = L _ (SigD (TypeSig lnames t))+isSimpleSig ExportDecl { expItemDecl = L _ (SigD _ (TypeSig _ lnames t))                        , expItemMbDoc = (Documentation Nothing Nothing, argDocs) }   | Map.null argDocs = Just (map unLoc lnames, unLoc (hsSigWcType t)) isSimpleSig _ = Nothing@@ -249,13 +242,17 @@         sec _ = text "\\paragraph"  -declNames :: LHsDecl DocNameI -> [DocName]+-- | 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  -> [tcdName d]-  SigD (TypeSig lnames _ ) -> map unLoc lnames-  SigD (PatSynSig lnames _) -> map unLoc lnames-  ForD (ForeignImport (L _ n) _ _ _) -> [n]-  ForD (ForeignExport (L _ n) _ _ _) -> [n]+  TyClD _ d  -> (empty, [tcdName 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"  @@ -278,47 +275,44 @@ -- * Decls ------------------------------------------------------------------------------- --ppDecl :: LHsDecl DocNameI-       -> [(HsDecl DocNameI, DocForDecl DocName)]-       -> DocForDecl DocName-       -> [DocInstance DocNameI]-       -> [(DocName, DocForDecl DocName)]-       -> [(DocName, Fixity)]+-- | 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 (L loc decl) pats (doc, fnArgsDoc) instances subdocs _fixities = case decl of-  TyClD d@(FamDecl {})          -> ppTyFam False loc doc d unicode-  TyClD d@(DataDecl {})-                                -> ppDataDecl pats instances subdocs loc (Just doc) d unicode-  TyClD d@(SynDecl {})          -> ppTySyn loc (doc, fnArgsDoc) d unicode+ppDecl decl pats (doc, fnArgsDoc) instances subdocs _fxts = case unLoc decl of+  TyClD _ d@FamDecl {}         -> ppTyFam False doc d unicode+  TyClD _ d@DataDecl {}        -> ppDataDecl pats instances subdocs (Just doc) d unicode+  TyClD _ d@SynDecl {}         -> ppTySyn (doc, fnArgsDoc) d unicode -- Family instances happen via FamInst now---  TyClD d@(TySynonym {})+--  TyClD _ d@TySynonym{} --    | Just _  <- tcdTyPats d    -> ppTyInst False loc doc d unicode -- Family instances happen via FamInst now-  TyClD d@(ClassDecl {})    -> ppClassDecl instances loc doc subdocs d unicode-  SigD (TypeSig lnames t)   -> ppFunSig loc (doc, fnArgsDoc) (map unLoc lnames)-                                        (hsSigWcType t) unicode-  SigD (PatSynSig lnames ty) ->-      ppLPatSig loc (doc, fnArgsDoc) (map unLoc lnames) ty unicode-  ForD d                         -> ppFor loc (doc, fnArgsDoc) d unicode-  InstD _                        -> empty-  DerivD _                       -> empty+  TyClD _ d@ClassDecl{}          -> ppClassDecl instances doc subdocs d unicode+  SigD _ (TypeSig _ lnames ty)   -> ppFunSig (doc, fnArgsDoc) (map unLoc lnames) (hsSigWcType 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  -ppTyFam :: Bool -> SrcSpan -> Documentation DocName ->+ppTyFam :: Bool -> Documentation DocName ->               TyClDecl DocNameI -> Bool -> LaTeX-ppTyFam _ _ _ _ _ =+ppTyFam _ _ _ _ =   error "type family declarations are currently not supported by --latex"  -ppFor :: SrcSpan -> DocForDecl DocName -> ForeignDecl DocNameI -> Bool -> LaTeX-ppFor loc doc (ForeignImport (L _ name) typ _ _) unicode =-  ppFunSig loc doc [name] (hsSigType typ) unicode-ppFor _ _ _ _ = error "ppFor error in Haddock.Backends.LaTeX"+ppFor :: DocForDecl DocName -> ForeignDecl DocNameI -> Bool -> LaTeX+ppFor doc (ForeignImport _ (L _ name) typ _) unicode =+  ppFunSig doc [name] (hsSigType typ) unicode+ppFor _ _ _ = error "ppFor error in Haddock.Backends.LaTeX" --  error "foreign declarations are currently not supported by --latex"  @@ -328,18 +322,18 @@   -- we skip type patterns for now-ppTySyn :: SrcSpan -> DocForDecl DocName -> TyClDecl DocNameI -> Bool -> LaTeX+ppTySyn :: DocForDecl DocName -> TyClDecl DocNameI -> Bool -> LaTeX -ppTySyn loc doc (SynDecl { tcdLName = L _ name, tcdTyVars = ltyvars+ppTySyn doc (SynDecl { tcdLName = L _ name, tcdTyVars = ltyvars                          , tcdRhs = ltype }) unicode-  = ppTypeOrFunSig loc [name] (unLoc ltype) doc (full, hdr, char '=') unicode+  = ppTypeOrFunSig (unLoc 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"+ppTySyn _ _ _ = error "declaration not supported by ppTySyn"   -------------------------------------------------------------------------------@@ -347,63 +341,100 @@ -------------------------------------------------------------------------------  -ppFunSig :: SrcSpan -> DocForDecl DocName -> [DocName] -> LHsType DocNameI+ppFunSig :: DocForDecl DocName -> [DocName] -> LHsType DocNameI          -> Bool -> LaTeX-ppFunSig loc doc docnames (L _ typ) unicode =-  ppTypeOrFunSig loc docnames typ doc+ppFunSig doc docnames (L _ typ) unicode =+  ppTypeOrFunSig typ doc     ( ppTypeSig names typ False     , hsep . punctuate comma $ map ppSymName names-    , dcolon unicode)+    , dcolon unicode+    )     unicode  where    names = map getName docnames -ppLPatSig :: SrcSpan -> DocForDecl DocName -> [DocName]-          -> LHsSigType DocNameI-          -> Bool -> LaTeX-ppLPatSig _loc (doc, _argDocs) docnames ty unicode-  = declWithDoc pref1 (documentationToLaTeX doc)+-- | 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+  = ppTypeOrFunSig typ doc+      ( keyword "pattern" <+> ppTypeSig names typ False+      , keyword "pattern" <+> (hsep . punctuate comma $ map ppSymName names)+      , dcolon unicode+      )+      unicode   where-    pref1 = hsep [ keyword "pattern"-                 , hsep $ punctuate comma $ map ppDocBinder docnames-                 , dcolon unicode-                 , ppLType unicode (hsSigType ty)-                 ]+    typ = unLoc (hsSigType ty)+    names = map getName docnames -ppTypeOrFunSig :: SrcSpan -> [DocName] -> HsType DocNameI-               -> DocForDecl DocName -> (LaTeX, LaTeX, LaTeX)-               -> Bool -> LaTeX-ppTypeOrFunSig _ _ typ (doc, argDocs) (pref1, pref2, sep0)-               unicode-  | Map.null argDocs =-      declWithDoc pref1 (documentationToLaTeX doc)-  | otherwise        =-      declWithDoc pref2 $ Just $+-- | Pretty-print a type, adding documentation to the whole type and its+-- arguments as needed.+ppTypeOrFunSig :: HsType 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" $$-        do_args 0 sep0 typ $$+        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+             -> HsType 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_args 0 leader typ   where-     do_largs n leader (L _ t) = do_args n leader t+    do_largs n leader (L _ t) = do_args n leader t -     arg_doc n = rDoc . fmap _doc $ Map.lookup n argDocs+    arg_doc n = rDoc . fmap _doc $ Map.lookup n argDocs -     do_args :: Int -> LaTeX -> HsType DocNameI -> LaTeX-     do_args _n leader (HsForAllTy tvs ltype)-       = decltt leader-         <-> decltt (hsep (forallSymbol unicode : ppTyVars tvs ++ [dot]))-         <+> ppLType unicode ltype-     do_args n leader (HsQualTy lctxt ltype)-       = decltt leader-         <-> ppLContextNoArrow lctxt unicode <+> nl $$-             do_largs n (darrow unicode) ltype-     do_args n leader (HsFunTy 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+    do_args :: Int -> LaTeX -> HsType DocNameI -> [(LaTeX, LaTeX)]+    do_args _n leader (HsForAllTy _ tvs ltype)+      = [ ( decltt leader+          , decltt (hsep (forallSymbol unicode : ppTyVars tvs ++ [dot]))+              <+> ppLType unicode ltype+          ) ]+    do_args n leader (HsQualTy _ lctxt ltype)+      = (decltt leader, ppLContextNoArrow lctxt unicode <+> nl)+        : do_largs n (darrow unicode) ltype +    do_args n leader (HsFunTy _ (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 _ 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) (text "\\ ")) <> text ","+    gadtEnd = hcat (replicate (if unicode then 3 else 4) (text "\\ ")) <> text "\\}"+    gadtOpen = text "\\{"++ ppTypeSig :: [Name] -> HsType DocNameI  -> Bool -> LaTeX ppTypeSig nms ty unicode =   hsep (punctuate comma $ map ppSymName nms)@@ -483,10 +514,10 @@                            hsep (map (ppDocName . unLoc) vars2)  -ppClassDecl :: [DocInstance DocNameI] -> SrcSpan+ppClassDecl :: [DocInstance DocNameI]             -> Documentation DocName -> [(DocName, DocForDecl DocName)]             -> TyClDecl DocNameI -> Bool -> LaTeX-ppClassDecl instances loc doc subdocs+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)) $$@@ -508,15 +539,15 @@      methodTable =       text "\\haddockpremethods{}\\textbf{Methods}" $$-      vcat  [ ppFunSig loc doc [name] (hsSigWcType typ) unicode-            | L _ (TypeSig lnames typ) <- lsigs+      vcat  [ ppFunSig doc [name] (hsSigWcType typ) unicode+            | L _ (TypeSig _ lnames typ) <- lsigs             , name <- map unLoc lnames             , let doc = lookupAnySubdoc name subdocs             ]      instancesBit = ppDocInstances unicode instances -ppClassDecl _ _ _ _ _ _ = error "declaration type not supported by ppShortClassDecl"+ppClassDecl _ _ _ _ _ = error "declaration type not supported by ppShortClassDecl"  ppDocInstances :: Bool -> [DocInstance DocNameI] -> LaTeX ppDocInstances _unicode [] = empty@@ -565,15 +596,17 @@ -- * Data & newtype declarations ------------------------------------------------------------------------------- --ppDataDecl :: [(HsDecl DocNameI, DocForDecl DocName)] -> [DocInstance DocNameI] ->-              [(DocName, DocForDecl DocName)] -> SrcSpan ->-              Maybe (Documentation DocName) -> TyClDecl DocNameI -> Bool ->-              LaTeX-ppDataDecl pats instances subdocs _loc doc dataDecl unicode--   =  declWithDoc (ppDataHeader dataDecl unicode <+> whereBit)-                  (if null body then Nothing else Just (vcat body))+-- | 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@@ -585,28 +618,26 @@     (whereBit, leaders)       | null cons       , null pats = (empty,[])-      | null cons = (decltt (keyword "where"), repeat empty)+      | null cons = (text "where", repeat empty)       | otherwise = case resTy of-        ConDeclGADT{} -> (decltt (keyword "where"), repeat empty)+        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 cons) $$           text "\\end{tabulary}\\par"      patternBit-      | null cons = Nothing+      | null pats = Nothing       | otherwise = Just $+          text "\\enspace" <+> emph (text "Bundled Patterns") <> text "\\par" $$           text "\\haddockbeginconstrs" $$-          vcat [ hsep [ keyword "pattern"-                      , hsep $ punctuate comma $ map (ppDocBinder . unLoc) lnames-                      , dcolon unicode-                      , ppLType unicode (hsSigType ty)-                      ] <-> rDoc (fmap _doc . combineDocumentation . fst $ d)-               | (SigD (PatSynSig lnames ty),d) <- pats+          vcat [ empty <-> ppSideBySidePat lnames typ d unicode+               | (SigD _ (PatSynSig _ lnames typ), d) <- pats                ] $$           text "\\end{tabulary}\\par" @@ -625,192 +656,155 @@       False -> empty  -ppSideBySideConstr :: [(DocName, DocForDecl DocName)] -> Bool -> LaTeX-                   -> LConDecl DocNameI -> LaTeX-ppSideBySideConstr subdocs unicode leader (L _ con@(ConDeclH98 {})) =-  leader <->-  case con_details con of--    PrefixCon args ->-      decltt (hsep ((header_ unicode <+> ppOcc) :-                 map (ppLParendType unicode) args))-      <-> rDoc mbDoc <+> nl--    RecCon (L _ fields) ->-      (decltt (header_ unicode <+> ppOcc)-        <-> rDoc mbDoc <+> nl)-      $$-      doRecordFields fields--    InfixCon arg1 arg2 ->-      decltt (hsep [ header_ unicode <+> ppLParendType unicode arg1,-                 ppOcc,-                 ppLParendType unicode arg2 ])-      <-> rDoc mbDoc <+> nl-- where-    doRecordFields fields =-        vcat (map (ppSideBySideField subdocs unicode) (map unLoc fields))+-- | 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)+    aConName = unLoc (head (getConNames con)) +    occ      = map (nameOccName . getName . unLoc) $ getConNames con -    header_ = ppConstrHdr False tyVars context-    occ     = map (nameOccName . getName . unLoc) $ getConNames con-    ppOcc   = case occ of-      [one] -> ppBinder one-      _     -> cat (punctuate comma (map ppBinder occ))-    tyVars  = tyvarNames (fromMaybe (HsQTvs PlaceHolder [] PlaceHolder) (con_qvars con))-    context = unLoc (fromMaybe (noLoc []) (con_cxt con))+    ppOcc      = cat (punctuate comma (map ppBinder occ))+    ppOccInfix = cat (punctuate comma (map ppBinderInfix occ)) -    -- 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 getConNames con of-              [] -> panic "empty con_names"-              (cn:_) -> lookup (unLoc cn) subdocs >>=-                        fmap _doc . combineDocumentation . fst+    -- 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 -ppSideBySideConstr subdocs unicode leader (L _ con@(ConDeclGADT {})) =-  leader <->-  doGADTCon (hsib_body $ con_type con)+    -- First line of the constructor (no doc, no fields, single-line)+    decl = case con of+      ConDeclH98{ con_args = det+                , con_ex_tvs = vars+                , con_mb_cxt = cxt+                } -> let tyVars = map (getName . hsLTyVarName) vars+                         context = unLoc (fromMaybe (noLoc []) cxt)+                         forall_ = False+                         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) args)+                              ] - where-    doGADTCon resTy = decltt (ppOcc <+> dcolon unicode <+>-                               ppLType unicode resTy-                            ) <-> rDoc mbDoc+        -- Record constructor, e.g. 'Identity { runIdentity :: a }'+        RecCon _ ->  header_ <+> ppOcc -    occ     = map (nameOccName . getName . unLoc) $ getConNames con-    ppOcc   = case occ of-      [one] -> ppBinder one-      _     -> cat (punctuate comma (map ppBinder occ))+        -- Infix constructor, e.g. 'a :| [a]'+        InfixCon arg1 arg2+          | hasArgDocs -> header_ <+> ppOcc+          | otherwise -> hsep [ header_+                              , ppLParendType unicode arg1+                              , ppOccInfix+                              , ppLParendType unicode arg2+                              ] -    -- 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 getConNames con of-              [] -> panic "empty con_names"-              (cn:_) -> lookup (unLoc cn) subdocs >>=-                        fmap _doc . combineDocumentation . fst-{- old+      ConDeclGADT{}+        | hasArgDocs || not (isEmpty fieldPart) -> ppOcc+        | otherwise -> hsep [ ppOcc+                            , dcolon unicode+                            -- ++AZ++ make this prepend "{..}" when it is a record style GADT+                            , ppLType unicode (getGADTConType con)+                            ]+      XConDecl{} -> panic "haddock:ppSideBySideConstr" -ppSideBySideConstr :: [(DocName, DocForDecl DocName)] -> Bool -> LaTeX-                   -> LConDecl DocName -> LaTeX-ppSideBySideConstr subdocs unicode leader (L loc con) =-  leader <->-  case con_res con of-  ResTyH98 -> case con_details con of+    fieldPart = case (con, getConArgs con) of+        -- Record style GADTs+        (ConDeclGADT{}, RecCon _)            -> doConstrArgsWithDocs [] -    PrefixCon args ->-      decltt (hsep ((header_ unicode <+> ppOcc) :-                 map (ppLParendType unicode) args))-      <-> rDoc mbDoc <+> nl+        -- Regular record declarations+        (_, RecCon (L _ fields))             -> doRecordFields fields -    RecCon (L _ fields) ->-      (decltt (header_ unicode <+> ppOcc)-        <-> rDoc mbDoc <+> nl)-      $$-      doRecordFields fields+        -- Any GADT or a regular H98 prefix data constructor+        (_, PrefixCon args)     | hasArgDocs -> doConstrArgsWithDocs args -    InfixCon arg1 arg2 ->-      decltt (hsep [ header_ unicode <+> ppLParendType unicode arg1,-                 ppOcc,-                 ppLParendType unicode arg2 ])-      <-> rDoc mbDoc <+> nl+        -- An infix H98 data constructor+        (_, InfixCon arg1 arg2) | hasArgDocs -> doConstrArgsWithDocs [arg1,arg2] -  ResTyGADT _ resTy -> case con_details con of-    -- prefix & infix could also use hsConDeclArgTys if it seemed to-    -- simplify the code.-    PrefixCon args -> doGADTCon args resTy-    cd@(RecCon (L _ fields)) -> doGADTCon (hsConDeclArgTys cd) resTy <+> nl $$-                                     doRecordFields fields-    InfixCon arg1 arg2 -> doGADTCon [arg1, arg2] resTy+        _ -> empty - where     doRecordFields fields =-        vcat (map (ppSideBySideField subdocs unicode) (map unLoc fields))+      vcat [ empty <-> tt (text begin) <+> ppSideBySideField subdocs unicode field <+> nl+           | (begin, L _ field) <- zip ("\\qquad \\{" : repeat "\\qquad ,") fields+           ]+      $$+      empty <-> tt (text "\\qquad \\}") <+> nl -    doGADTCon args resTy = decltt (ppOcc <+> dcolon unicode <+>-                               ppLType unicode (mk_forall $ mk_phi $-                                                foldr mkFunTy resTy args)-                            ) <-> rDoc mbDoc+    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)+        ]+      XConDecl{} -> panic "haddock:doConstrArgsWithDocs"  -    header_ = ppConstrHdr (con_explicit con) tyVars context-    occ     = map (nameOccName . getName . unLoc) $ con_names con-    ppOcc   = case occ of-      [one] -> ppBinder one-      _     -> cat (punctuate comma (map ppBinder occ))-    ltvs    = con_qvars con-    tyVars  = tyvarNames (con_qvars con)-    context = unLoc (con_cxt con)--    mk_forall ty | con_explicit con = L loc (HsForAllTy (hsQTvExplicit ltvs) ty)-                 | otherwise        = ty-    mk_phi ty | null context = ty-              | otherwise    = L loc (HsQualTy (con_cxt con) ty)-     -- 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 con_names con of+    mbDoc = case getConNames con of               [] -> panic "empty con_names"               (cn:_) -> lookup (unLoc cn) subdocs >>=                         fmap _doc . combineDocumentation . fst-    mkFunTy a b = noLoc (HsFunTy a b)--} ++-- | Pretty-print a record field ppSideBySideField :: [(DocName, DocForDecl DocName)] -> Bool -> ConDeclField DocNameI ->  LaTeX-ppSideBySideField subdocs unicode (ConDeclField names ltype _) =+ppSideBySideField subdocs unicode (ConDeclField _ names ltype _) =   decltt (cat (punctuate comma (map (ppBinder . rdrNameOcc . unLoc . rdrNameFieldOcc . 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 (selectorFieldOcc $ unLoc $ head names) subdocs >>= fmap _doc . combineDocumentation . fst+    mbDoc = lookup (extFieldOcc $ unLoc $ head names) subdocs >>= fmap _doc . combineDocumentation . fst+ppSideBySideField _ _ (XConDeclField _) = panic "haddock:ppSideBySideField" --- {---- ppHsFullConstr :: HsConDecl -> LaTeX--- ppHsFullConstr (HsConDecl _ nm tvs ctxt typeList doc) =---      declWithDoc False doc (--- 	hsep ((ppHsConstrHdr tvs ctxt +++--- 		ppHsBinder False nm) : map ppHsBangType typeList)---       )--- ppHsFullConstr (HsRecDecl _ nm tvs ctxt fields doc) =---    td << vanillaTable << (---      case doc of---        Nothing -> aboves [hdr, fields_html]---        Just _  -> aboves [hdr, constr_doc, fields_html]---    )------   where hdr = declBox (ppHsConstrHdr tvs ctxt +++ ppHsBinder False nm)------ 	constr_doc--- 	  | isJust doc = docBox (docToLaTeX (fromJust doc))--- 	  | otherwise  = LaTeX.emptyTable------ 	fields_html =--- 	   td <<--- 	      table ! [width "100%", cellpadding 0, cellspacing 8] << (--- 		   aboves (map ppFullField (concat (map expandField fields)))--- 		)--- -}------ ppShortField :: Bool -> Bool -> ConDeclField DocName -> LaTeX--- ppShortField summary unicode (ConDeclField (L _ name) ltype _)---   = tda [theclass "recfield"] << (---       ppBinder summary (docNameOcc name)---       <+> dcolon unicode <+> ppLType unicode ltype---     )------ {---- ppFullField :: HsFieldDecl -> LaTeX--- ppFullField (HsFieldDecl [n] ty doc)---   = declWithDoc False doc (--- 	ppHsBinder False n <+> dcolon <+> ppHsBangType ty---     )--- ppFullField _ = error "ppFullField"------ expandField :: HsFieldDecl -> [HsFieldDecl]--- expandField (HsFieldDecl ns ty doc) = [ HsFieldDecl [n] ty doc | n <- ns ]--- -} +-- | Pretty-print a bundled pattern synonym+ppSideBySidePat :: [Located 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+                            , ppLType unicode (hsSigType typ)+                            ]++    fieldPart+      | not hasArgDocs = empty+      | otherwise = vcat+          [ empty <-> text "\\qquad" <+> l <+> text "\\enspace" <+> r+          | (l,r) <- ppSubSigLike unicode (unLoc patTy) argDocs [] (dcolon unicode)+          ]++    patTy = hsSigType typ++    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@@ -824,6 +818,7 @@     ppAppDocNameNames False name (tyvarNames tyvars) ppDataHeader _ _ = error "ppDataHeader: illegal argument" + -------------------------------------------------------------------------------- -- * Type applications --------------------------------------------------------------------------------@@ -911,24 +906,6 @@ -- Stolen from Html and tweaked for LaTeX generation ------------------------------------------------------------------------------- --pREC_TOP, pREC_FUN, pREC_OP, pREC_CON :: Int--pREC_TOP = (0 :: Int)   -- type in ParseIface.y in GHC-pREC_FUN = (1 :: Int)   -- btype in ParseIface.y in GHC-                        -- Used for LH arg of (->)-pREC_OP  = (2 :: Int)   -- Used for arg of any infix operator-                        -- (we don't keep their fixities around)-pREC_CON = (3 :: Int)   -- Used for arg of type applicn:-                        -- always parenthesise unless atomic--maybeParen :: Int           -- Precedence of context-           -> Int           -- Precedence of top-level operator-           -> LaTeX -> LaTeX  -- Wrap in parens if (ctxt >= op)-maybeParen ctxt_prec op_prec p | ctxt_prec >= op_prec = parens p-                               | otherwise            = p-- ppLType, ppLParendType, ppLFunLhType :: Bool -> Located (HsType DocNameI) -> LaTeX ppLType       unicode y = ppType unicode (unLoc y) ppLParendType unicode y = ppParendType unicode (unLoc y)@@ -936,78 +913,70 @@   ppType, ppParendType, ppFunLhType :: Bool -> HsType DocNameI -> LaTeX-ppType       unicode ty = ppr_mono_ty pREC_TOP ty unicode-ppParendType unicode ty = ppr_mono_ty pREC_CON ty unicode-ppFunLhType  unicode ty = ppr_mono_ty pREC_FUN ty unicode+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  ppLKind :: Bool -> LHsKind DocNameI -> LaTeX ppLKind unicode y = ppKind unicode (unLoc y)  ppKind :: Bool -> HsKind DocNameI -> LaTeX-ppKind unicode ki = ppr_mono_ty pREC_TOP ki unicode+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_mono_lty :: Int -> LHsType DocNameI -> Bool -> LaTeX-ppr_mono_lty ctxt_prec ty unicode = ppr_mono_ty ctxt_prec (unLoc ty) unicode+ppr_mono_lty :: LHsType DocNameI -> Bool -> LaTeX+ppr_mono_lty ty unicode = ppr_mono_ty (unLoc ty) unicode  -ppr_mono_ty :: Int -> HsType DocNameI -> Bool -> LaTeX-ppr_mono_ty ctxt_prec (HsForAllTy tvs ty) unicode-  = maybeParen ctxt_prec pREC_FUN $-    sep [ hsep (forallSymbol unicode : ppTyVars tvs) <> dot-        , ppr_mono_lty pREC_TOP ty unicode ]-ppr_mono_ty ctxt_prec (HsQualTy ctxt ty) unicode-  = maybeParen ctxt_prec pREC_FUN $-    sep [ ppLContext ctxt unicode-        , ppr_mono_lty pREC_TOP ty unicode ]--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 Promoted    (L _ name)) _ = char '\'' <> ppDocName name-ppr_mono_ty ctxt_prec (HsFunTy ty1 ty2)   u = ppr_fun_ty ctxt_prec ty1 ty2 u-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 pREC_TOP ty u <+> dcolon u <+> ppLKind u kind)-ppr_mono_ty _         (HsListTy ty)       u = brackets (ppr_mono_lty pREC_TOP ty u)-ppr_mono_ty _         (HsPArrTy ty)       u = pabrackets (ppr_mono_lty pREC_TOP ty u)-ppr_mono_ty _         (HsIParamTy (L _ n) ty) u = brackets (ppIPName n <+> dcolon u <+> ppr_mono_lty pREC_TOP ty u)-ppr_mono_ty _         (HsSpliceTy {})     _ = error "ppr_mono_ty HsSpliceTy"-ppr_mono_ty _         (HsRecTy {})        _ = error "ppr_mono_ty HsRecTy"-ppr_mono_ty _         (HsCoreTy {})       _ = error "ppr_mono_ty HsCoreTy"-ppr_mono_ty _         (HsExplicitListTy Promoted _ 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 :: HsType DocNameI -> Bool -> LaTeX+ppr_mono_ty (HsForAllTy _ tvs ty) unicode+  = sep [ hsep (forallSymbol unicode : ppTyVars tvs) <> dot+        , ppr_mono_lty ty unicode ]+ppr_mono_ty (HsQualTy _ ctxt ty) unicode+  = sep [ ppLContext ctxt unicode+        , ppr_mono_lty ty unicode ]+ppr_mono_ty (HsFunTy _ ty1 ty2)   u+  = sep [ ppr_mono_lty ty1 u+        , arrow u <+> ppr_mono_lty ty2 u ] -ppr_mono_ty ctxt_prec (HsEqTy ty1 ty2) unicode-  = maybeParen ctxt_prec pREC_OP $-    ppr_mono_lty pREC_OP ty1 unicode <+> char '~' <+> ppr_mono_lty pREC_OP ty2 unicode+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 _ Promoted    (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 = brackets (ppIPName n <+> dcolon u <+> ppr_mono_lty ty u)+ppr_mono_ty (HsSpliceTy {})     _ = error "ppr_mono_ty HsSpliceTy"+ppr_mono_ty (HsRecTy {})        _ = text "{..}"+ppr_mono_ty (XHsType (NHsCoreTy {}))  _ = error "ppr_mono_ty HsCoreTy"+ppr_mono_ty (HsExplicitListTy _ Promoted 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 ctxt_prec (HsAppTy fun_ty arg_ty) unicode-  = maybeParen ctxt_prec pREC_CON $-    hsep [ppr_mono_lty pREC_FUN fun_ty unicode, ppr_mono_lty pREC_CON arg_ty unicode]+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 ctxt_prec (HsOpTy ty1 op ty2) unicode-  = maybeParen ctxt_prec pREC_FUN $-    ppr_mono_lty pREC_OP ty1 unicode <+> ppr_op <+> ppr_mono_lty pREC_OP ty2 unicode+ppr_mono_ty (HsOpTy _ ty1 op ty2) unicode+  = ppr_mono_lty ty1 unicode <+> ppr_op <+> ppr_mono_lty ty2 unicode   where     ppr_op = if not (isSymOcc occName) then char '`' <> ppLDocName op <> char '`' else ppLDocName op     occName = nameOccName . getName . unLoc $ op -ppr_mono_ty ctxt_prec (HsParTy ty) unicode---  = parens (ppr_mono_lty pREC_TOP ty)-  = ppr_mono_lty ctxt_prec ty unicode--ppr_mono_ty ctxt_prec (HsDocTy ty _) unicode-  = ppr_mono_lty ctxt_prec ty unicode+ppr_mono_ty (HsParTy _ ty) unicode+  = parens (ppr_mono_lty ty unicode)+--  = ppr_mono_lty ty unicode -ppr_mono_ty _ (HsWildCardTy (AnonWildCard _)) _ = char '_'+ppr_mono_ty (HsDocTy _ ty _) unicode+  = ppr_mono_lty ty unicode -ppr_mono_ty _ (HsTyLit t) u = ppr_tylit t u+ppr_mono_ty (HsWildCardTy (AnonWildCard _)) _ = char '_' -ppr_mono_ty _ (HsAppsTy {}) _ = panic "ppr_mono_ty:HsAppsTy"+ppr_mono_ty (HsTyLit _ t) u = ppr_tylit t u+ppr_mono_ty (HsStarTy _ isUni) unicode = starSymbol (isUni || unicode)   ppr_tylit :: HsTyLit -> Bool -> LaTeX@@ -1017,15 +986,6 @@   -- XXX: Do something with Unicode parameter?  -ppr_fun_ty :: Int -> LHsType DocNameI -> LHsType DocNameI -> Bool -> LaTeX-ppr_fun_ty ctxt_prec ty1 ty2 unicode-  = let p1 = ppr_mono_lty pREC_FUN ty1 unicode-        p2 = ppr_mono_lty pREC_TOP ty2 unicode-    in-    maybeParen ctxt_prec pREC_FUN $-    sep [p1, arrow unicode <+> p2]-- ------------------------------------------------------------------------------- -- * Names -------------------------------------------------------------------------------@@ -1036,6 +996,11 @@   | isInfixName n = parens $ ppOccName n   | otherwise     = ppOccName n +ppBinderInfix :: OccName -> LaTeX+ppBinderInfix n+  | isInfixName n = ppOccName n+  | otherwise     = cat [ char '`', ppOccName n, char '`' ]+ isInfixName :: OccName -> Bool isInfixName n = isVarSym n || isConSym n @@ -1267,12 +1232,12 @@ quote doc = text "\\begin{quote}" $$ doc $$ text "\\end{quote}"  -dcolon, arrow, darrow, forallSymbol :: Bool -> LaTeX+dcolon, arrow, darrow, forallSymbol, starSymbol :: Bool -> LaTeX dcolon unicode = text (if unicode then "∷" else "::") arrow  unicode = text (if unicode then "→" else "->") darrow unicode = text (if unicode then "⇒" else "=>") forallSymbol unicode = text (if unicode then "∀" else "forall")-+starSymbol unicode = text (if unicode then "★" else "*")  dot :: LaTeX dot = char '.'@@ -1288,10 +1253,6 @@  ubxparens :: LaTeX -> LaTeX ubxparens h = text "(#" <> h <> text "#)"---pabrackets :: LaTeX -> LaTeX-pabrackets h = text "[:" <> h <> text ":]"   nl :: LaTeX
src/Haddock/Backends/Xhtml.hs view
@@ -667,7 +667,7 @@  processExport :: Bool -> LinksInfo -> Bool -> Maybe Package -> Qualification               -> ExportItem DocNameI -> Maybe Html-processExport _ _ _ _ _ ExportDecl { expItemDecl = L _ (InstD _) } = Nothing -- Hide empty instances+processExport _ _ _ _ _ ExportDecl { expItemDecl = L _ (InstD {}) } = Nothing -- Hide empty instances processExport summary _ _ pkg qual (ExportGroup lev id0 doc)   = nothingIf summary $ groupHeading lev id0 << docToHtml (Just id0) pkg qual (mkMeta doc) processExport summary links unicode pkg qual (ExportDecl decl pats doc subdocs insts fixities splice)
src/Haddock/Backends/Xhtml/Decl.hs view
@@ -39,24 +39,34 @@ import Name import BooleanFormula import RdrName ( rdrNameOcc )+import Outputable ( panic ) -ppDecl :: Bool -> LinksInfo -> LHsDecl DocNameI-       -> [(HsDecl DocNameI, DocForDecl DocName)]-       -> DocForDecl DocName ->  [DocInstance DocNameI] -> [(DocName, Fixity)]-       -> [(DocName, DocForDecl DocName)] -> Splice -> Unicode-       -> Maybe Package -> Qualification -> Html+-- | 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)            -> ppTyFam summ False links instances fixities loc mbDoc d splice unicode pkg qual-  TyClD d@(DataDecl {})        -> ppDataDecl summ links instances fixities subdocs loc mbDoc d pats splice unicode pkg qual-  TyClD d@(SynDecl {})         -> ppTySyn summ links fixities loc (mbDoc, fnArgsDoc) d splice unicode pkg qual-  TyClD d@(ClassDecl {})       -> ppClassDecl summ links instances fixities loc mbDoc subdocs d splice unicode pkg qual-  SigD (TypeSig lnames lty)    -> ppLFunSig summ links loc (mbDoc, fnArgsDoc) lnames+  TyClD _ (FamDecl _ d)          -> ppTyFam summ False links instances fixities loc mbDoc d splice unicode pkg qual+  TyClD _ d@(DataDecl {})        -> ppDataDecl summ links instances fixities subdocs loc mbDoc d pats splice unicode pkg qual+  TyClD _ d@(SynDecl {})         -> ppTySyn summ links fixities loc (mbDoc, fnArgsDoc) d splice unicode pkg qual+  TyClD _ d@(ClassDecl {})       -> ppClassDecl summ links instances fixities loc mbDoc subdocs d splice unicode pkg qual+  SigD _ (TypeSig _ lnames lty)  -> ppLFunSig summ links loc (mbDoc, fnArgsDoc) lnames                                          (hsSigWcType lty) fixities splice unicode pkg qual-  SigD (PatSynSig lnames ty)   -> ppLPatSig summ links loc (mbDoc, fnArgsDoc) lnames-                                         ty fixities splice unicode pkg qual-  ForD d                       -> ppFor summ links loc (mbDoc, fnArgsDoc) d fixities splice unicode pkg qual-  InstD _                      -> noHtml-  DerivD _                     -> noHtml+  SigD _ (PatSynSig _ lnames lty) -> ppLPatSig summ links loc (mbDoc, fnArgsDoc) lnames+                                         (hsSigType lty) fixities splice unicode pkg qual+  ForD _ d                       -> ppFor summ links loc (mbDoc, fnArgsDoc) d fixities splice unicode pkg qual+  InstD _ _                      -> noHtml+  DerivD _ _                     -> noHtml   _                            -> error "declaration not supported by ppDecl"  @@ -76,22 +86,19 @@   where     pp_typ = ppLType unicode qual HideEmptyContexts typ -ppLPatSig :: Bool -> LinksInfo -> SrcSpan -> DocForDecl DocName ->-             [Located DocName] -> LHsSigType DocNameI ->-             [(DocName, Fixity)] ->-             Splice -> Unicode -> Maybe Package -> Qualification -> Html-ppLPatSig summary links loc (doc, _argDocs) docnames typ fixities splice-          unicode pkg qual-  | summary = pref1-  | otherwise = topDeclElem links loc splice (map unLoc docnames) (pref1 <+> ppFixities fixities qual)-                +++ docSection Nothing pkg qual doc+-- | Pretty print a pattern synonym+ppLPatSig :: Bool -> LinksInfo -> SrcSpan -> DocForDecl DocName+          -> [Located DocName]     -- ^ names of patterns in declaration+          -> LHsType 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-    pref1 = hsep [ keyword "pattern"-                 , hsep $ punctuate comma $ map (ppBinder summary . getOccName) docnames-                 , dcolon unicode-                 , ppPatSigType unicode qual (hsSigType typ)-                 ]+    pp_typ = ppPatSigType unicode qual typ + ppSigLike :: Bool -> LinksInfo -> SrcSpan -> Html -> DocForDecl DocName ->              [DocName] -> [(DocName, Fixity)] -> (HsType DocNameI, Html) ->              Splice -> Unicode -> Maybe Package -> Qualification -> HideEmptyContexts -> Html@@ -99,7 +106,7 @@           splice unicode pkg qual emptyCtxts =   ppTypeOrFunSig summary links loc docnames typ doc     ( addFixities $ leader <+> ppTypeSig summary occnames pp_typ unicode-    , addFixities . concatHtml . punctuate comma $ map (ppBinder False) occnames+    , (leader <+>) . addFixities . concatHtml . punctuate comma $ map (ppBinder False) occnames     , dcolon unicode     )     splice unicode pkg qual emptyCtxts@@ -118,36 +125,72 @@                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 (do_args 0 sep typ) +++ 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+             -> HsType 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_args 0 sep typ+  where     argDoc n = Map.lookup n argDocs      do_largs n leader (L _ t) = do_args n leader t      do_args :: Int -> Html -> HsType DocNameI -> [SubDecl]-    do_args n leader (HsForAllTy tvs ltype)+    do_args n leader (HsForAllTy _ tvs ltype)       = do_largs n leader' ltype       where         leader' = leader <+> ppForAll tvs unicode qual -    do_args n leader (HsQualTy lctxt ltype)+    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 lt r)+    do_args n leader (HsFunTy _ (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 _ 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 "{"+++ ppForAll :: [LHsTyVarBndr DocNameI] -> Unicode -> Qualification -> Html ppForAll tvs unicode qual =-  case [ppKTv n k | L _ (KindedTyVar (L _ n) k) <- tvs] of+  case [ppKTv n k | L _ (KindedTyVar _ (L _ n) k) <- tvs] of     [] -> noHtml     ts -> forallSymbol unicode <+> hsep ts +++ dot   where ppKTv n k = parens $@@ -186,7 +229,7 @@ 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+ppFor summary links loc doc (ForeignImport _ (L _ name) typ _) fixities       splice unicode pkg qual   = ppFunSig summary links loc doc [name] (hsSigType typ) fixities splice unicode pkg qual ppFor _ _ _ _ _ _ _ _ _ _ = error "ppFor"@@ -279,12 +322,14 @@      ClosedTypeFamily _ -> keyword "where ..."      _                  -> mempty   )+ppTyFamHeader _ _ (XFamilyDecl _) _ _ = panic "haddock;ppTyFamHeader"  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+    NoSig _               -> noHtml+    KindSig _ kind        -> dcolon unicode  <+> ppLKind unicode qual kind+    TyVarSig _ (L _ bndr) -> equals <+> ppHsTyVarBndr unicode qual bndr+    XFamilyResultSig _    -> panic "haddock:ppResultSig"  ppPseudoFamilyHeader :: Unicode -> Qualification -> PseudoFamilyDecl DocNameI                      -> Html@@ -330,6 +375,8 @@       = ( ppAppNameTypes (unLoc n) (map unLoc ts) unicode qual           <+> equals <+> ppType unicode qual HideEmptyContexts (unLoc rhs)         , Nothing, [] )+    ppTyFamEqn (XHsImplicitBndrs _) = panic "haddock:ppTyFam"+    ppTyFamEqn (HsIB { hsib_body = XFamEqn _}) = panic "haddock:ppTyFam"   @@ -363,6 +410,7 @@ ppFamDeclBinderWithVars :: Bool -> Unicode -> Qualification -> FamilyDecl DocNameI -> Html ppFamDeclBinderWithVars summ unicode qual (FamilyDecl { fdLName = lname, fdTyVars = tvs }) =   ppAppDocNameTyVarBndrs summ unicode qual (unLoc lname) (hsq_explicit tvs)+ppFamDeclBinderWithVars _ _ _ (XFamilyDecl _) = panic "haddock:ppFamDeclBinderWithVars"  -- | Print a newtype / data binder and its variables ppDataBinderWithVars :: Bool -> Unicode -> Qualification -> TyClDecl DocNameI -> Html@@ -475,9 +523,9 @@                  -- ToDo: add associated type defaults -            [ ppFunSig summary links loc doc names (hsSigWcType typ)+            [ ppFunSig summary links loc doc names (hsSigType typ)                        [] splice unicode pkg qual-              | L _ (TypeSig lnames typ) <- sigs+              | 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@@ -525,7 +573,7 @@      methodBit = subMethods [ ppFunSig summary links loc doc [name] (hsSigType typ)                                       subfixs splice unicode pkg qual-                           | L _ (ClassOpSig _ lnames typ) <- lsigs+                           | L _ (ClassOpSig _ _ lnames typ) <- lsigs                            , name <- map unLoc lnames                            , let doc = lookupAnySubdoc name subdocs                                  subfixs = [ f | f@(n',_) <- fixities@@ -534,15 +582,15 @@                            -- N.B. taking just the first name is ok. Signatures with multiple names                            -- are expanded so that each name gets its own signature. -    minimalBit = case [ s | MinimalSig _ (L _ s) <- sigs ] of+    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 | TypeSig ns _ <- sigs, L _ n <- ns]+                   sort [getName n | ClassOpSig _ _ ns _ <- sigs, L _ n <- ns]         -> noHtml        -- Minimal complete definition = the only shown method       Var (L _ n) : _ | [getName n] ==-                        [getName n' | L _ (TypeSig ns _) <- lsigs, L _ n' <- ns]+                        [getName n' | L _ (ClassOpSig _ _ ns _) <- lsigs, L _ n' <- ns]         -> noHtml        -- Minimal complete definition = nothing@@ -572,9 +620,9 @@   -- force Splice = True to use line URLs   where     instName = getOccString origin-    instDecl :: Int -> DocInstance DocNameI -> (SubDecl,Located DocName)+    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), loc)+        ((ppInstHead links splice unicode qual mdoc origin False no inst mdl), mdl, loc)   ppOrphanInstances :: LinksInfo@@ -587,9 +635,9 @@     instOrigin :: InstHead name -> InstOrigin (IdP name)     instOrigin inst = OriginClass (ihdClsName inst) -    instDecl :: Int -> DocInstance DocNameI -> (SubDecl,Located DocName)+    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 mdl), loc)+        ((ppInstHead links splice unicode qual mdoc (instOrigin inst) True no inst Nothing), mdl, loc)   ppInstHead :: LinksInfo -> Splice -> Unicode -> Qualification@@ -645,7 +693,7 @@               -> [Sig DocNameI]               -> [Html] ppInstanceSigs links splice unicode qual sigs = do-    TypeSig lnames typ <- sigs+    TypeSig _ lnames typ <- sigs     let names = map unLoc lnames         L _ rtyp = hsSigWcType typ     -- Instance methods signatures are synified and thus don't have a useful@@ -706,21 +754,27 @@     isH98     = case unLoc (head cons) of                   ConDeclH98 {} -> True                   ConDeclGADT{} -> False+                  XConDecl{}    -> False      pats1 = [ hsep [ keyword "pattern"                    , hsep $ punctuate comma $ map (ppBinder summary . getOccName) lnames                    , dcolon unicode                    , ppPatSigType unicode qual (hsSigType typ)                    ]-            | (SigD (PatSynSig lnames typ),_) <- pats+            | (SigD _ (PatSynSig _ lnames typ),_) <- pats             ]  -ppDataDecl :: Bool -> LinksInfo -> [DocInstance DocNameI] -> [(DocName, Fixity)] ->-              [(DocName, DocForDecl DocName)] ->-              SrcSpan -> Documentation DocName -> TyClDecl DocNameI ->-              [(HsDecl DocNameI, DocForDecl DocName)] ->-              Splice -> Unicode -> Maybe Package -> Qualification -> Html+-- | 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 @@ -733,6 +787,7 @@     isH98     = case unLoc (head cons) of                   ConDeclH98 {} -> True                   ConDeclGADT{} -> False+                  XConDecl{}    -> False      header_ = topDeclElem links loc splice [docname] $              ppDataHeader summary dataDecl unicode qual <+> whereBit <+> fix@@ -749,25 +804,20 @@       [ ppSideBySideConstr subdocs subfixs unicode pkg qual c       | c <- cons       , let subfixs = filter (\(n,_) -> any (\cn -> cn == n)-                                     (map unLoc (getConNames (unLoc c)))) fixities+                                            (map unLoc (getConNames (unLoc c)))) fixities       ]      patternBit = subPatterns pkg qual-      [ (hsep [ keyword "pattern"-              , hsep $ punctuate comma $ map (ppBinder summary . getOccName) lnames-              , dcolon unicode-              , ppPatSigType unicode qual (hsSigType typ)-              ] <+> ppFixities subfixs qual-        ,combineDocumentation (fst d), [])-      | (SigD (PatSynSig lnames typ),d) <- pats-      , let subfixs = filter (\(n,_) -> any (\cn -> cn == n) (map unLoc lnames)) fixities+      [ 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@@ -777,121 +827,183 @@ -- 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{} -> case con_details con of-    PrefixCon args ->-      (header_ unicode qual +++ hsep (ppOcc-            : map (ppLParendType unicode qual HideEmptyContexts) args), noHtml, noHtml)-    RecCon (L _ fields) ->-      (header_ unicode qual +++ ppOcc <+> char '{',-       doRecordFields fields,-       char '}')-    InfixCon arg1 arg2 ->-      (header_ unicode qual +++ hsep [ppLParendType unicode qual HideEmptyContexts arg1,-            ppOccInfix, ppLParendType unicode qual HideEmptyContexts arg2],-       noHtml, noHtml)+ppShortConstrParts summary dataInst con unicode qual+  = case con of+      ConDeclH98{ con_args = det+                , con_ex_tvs = vars+                , con_mb_cxt = cxt+                } -> let tyVars = map (getName . hsLTyVarName) vars+                         context = unLoc (fromMaybe (noLoc []) cxt)+                         forall_ = False+                         header_ = ppConstrHdr forall_ tyVars context unicode qual+                     in case det of -  ConDeclGADT {} -> (ppOcc <+> dcolon unicode <+> ppLType unicode qual HideEmptyContexts resTy,noHtml,noHtml)+        -- Prefix constructor, e.g. 'Just a'+        PrefixCon args ->+          ( header_ +++ hsep (ppOcc : map (ppLParendType unicode qual HideEmptyContexts) args)+          , noHtml+          , noHtml+          ) -  where-    resTy = hsib_body (con_type con)+        -- Record constructor, e.g. 'Identity { runIdentity :: a }'+        RecCon (L _ fields) ->+          ( header_ +++ ppOcc <+> char '{'+          , shortSubDecls dataInst [ ppShortField summary unicode qual field+                                   | L _ field <- fields+                                   ]+          , char '}'+          ) -    doRecordFields fields = shortSubDecls dataInst (map (ppShortField summary unicode qual) (map unLoc fields))+        -- Infix constructor, e.g. 'a :| [a]'+        InfixCon arg1 arg2 ->+          ( header_ +++ hsep [ ppLParendType unicode qual HideEmptyContexts arg1+                             , ppOccInfix+                             , ppLParendType unicode qual HideEmptyContexts arg2+                             ]+          , noHtml+          , noHtml+          ) -    header_  = ppConstrHdr forall_ tyVars context+      -- GADT constructor, e.g. 'Foo :: Int -> Foo'+      ConDeclGADT {} ->+          ( hsep [ ppOcc, dcolon unicode, ppLType unicode qual HideEmptyContexts (getGADTConType con) ]+          , noHtml+          , noHtml+          )+      XConDecl {} -> panic "haddock:ppShortConstrParts"++  where     occ        = map (nameOccName . getName . unLoc) $ getConNames con+    ppOcc      = hsep (punctuate comma (map (ppBinder summary) occ))+    ppOccInfix = hsep (punctuate comma (map (ppBinderInfix summary) occ)) -    ppOcc      = case occ of-      [one] -> ppBinder summary one-      _     -> hsep (punctuate comma (map (ppBinder summary) occ)) -    ppOccInfix = case occ of-      [one] -> ppBinderInfix summary one-      _     -> 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)+    aConName = unLoc (head (getConNames con)) -    ltvs     = fromMaybe (HsQTvs PlaceHolder [] PlaceHolder) (con_qvars con)-    tyVars   = tyvarNames ltvs-    lcontext = fromMaybe (noLoc []) (con_cxt con)-    context  = unLoc lcontext-    forall_  = False+    fixity   = ppFixities fixities qual+    occ      = map (nameOccName . getName . unLoc) $ getConNames con +    ppOcc      = hsep (punctuate comma (map (ppBinder False) occ))+    ppOccInfix = hsep (punctuate comma (map (ppBinderInfix False) occ)) --- ppConstrHdr is for (non-GADT) existentials constructors' syntax-ppConstrHdr :: Bool -> [Name] -> HsContext DocNameI -> Unicode-            -> Qualification -> Html-ppConstrHdr forall_ tvs ctxt unicode qual- = (if null tvs then noHtml else ppForall)-   +++-   (if null ctxt then noHtml-    else ppContextNoArrow ctxt unicode qual HideEmptyContexts-         <+> darrow unicode +++ toHtml " ")-  where-    ppForall | forall_   = forallSymbol unicode <+> hsep (map (ppName Prefix) tvs)-                           <+> toHtml ". "-             | otherwise = noHtml+    -- 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 -ppSideBySideConstr :: [(DocName, DocForDecl DocName)] -> [(DocName, Fixity)]-                   -> Unicode -> Maybe Package -> Qualification -> LConDecl DocNameI -> SubDecl-ppSideBySideConstr subdocs fixities unicode pkg qual (L _ con)- = (decl, mbDoc, fieldPart)- where     decl = case con of-      ConDeclH98{} -> case con_details con of-        PrefixCon args ->-          hsep ((header_ +++ ppOcc)-            : map (ppLParendType unicode qual HideEmptyContexts) args)-          <+> fixity+      ConDeclH98{ con_args = det+                , con_ex_tvs = vars+                , con_mb_cxt = cxt+                } -> let tyVars = map (getName . hsLTyVarName) vars+                         context = unLoc (fromMaybe (noLoc []) cxt)+                         forall_ = False+                         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) args)+                              , fixity+                              ] +        -- Record constructor, e.g. 'Identity { runIdentity :: a }'         RecCon _ -> header_ +++ ppOcc <+> fixity -        InfixCon arg1 arg2 ->-          hsep [header_ +++ ppLParendType unicode qual HideEmptyContexts arg1,-            ppOccInfix,-            ppLParendType unicode qual HideEmptyContexts arg2]-          <+> fixity+        -- Infix constructor, e.g. 'a :| [a]'+        InfixCon arg1 arg2+          | hasArgDocs -> header_ +++ ppOcc <+> fixity+          | otherwise -> hsep [ header_ +++ ppLParendType unicode qual HideEmptyContexts arg1+                              , ppOccInfix+                              , ppLParendType unicode qual HideEmptyContexts arg2+                              , fixity+                              ] -      ConDeclGADT{} -> doGADTCon resTy+      -- 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+                              , ppLType unicode qual HideEmptyContexts (getGADTConType con)+                              , fixity+                              ]+      XConDecl{} -> panic "haddock:ppSideBySideConstr" -    resTy = hsib_body (con_type con)+    fieldPart = case (con, getConArgs con) of+        -- Record style GADTs+        (ConDeclGADT{}, RecCon _)            -> [ doConstrArgsWithDocs [] ] -    fieldPart = case getConDetails con of-        RecCon (L _ fields) -> [doRecordFields fields]-        _ -> []+        -- Regular record declarations+        (_, RecCon (L _ fields))             -> [ doRecordFields fields ] -    doRecordFields fields = subFields pkg qual-      (map (ppSideBySideField subdocs unicode qual) (map unLoc fields))+        -- Any GADT or a regular H98 prefix data constructor+        (_, PrefixCon args)     | hasArgDocs -> [ doConstrArgsWithDocs args ] -    doGADTCon :: Located (HsType DocNameI) -> Html-    doGADTCon ty = ppOcc <+> dcolon unicode-        -- ++AZ++ make this prepend "{..}" when it is a record style GADT-        <+> ppLType unicode qual HideEmptyContexts ty-        <+> fixity+        -- An infix H98 data constructor+        (_, InfixCon arg1 arg2) | hasArgDocs -> [ doConstrArgsWithDocs [arg1,arg2] ] -    fixity  = ppFixities fixities qual-    header_ = ppConstrHdr forall_ tyVars context unicode qual-    occ       = map (nameOccName . getName . unLoc) $ getConNames con+        _ -> [] -    ppOcc     = case occ of-      [one] -> ppBinder False one-      _     -> hsep (punctuate comma (map (ppBinder False) occ))+    doRecordFields fields = subFields pkg qual+      (map (ppSideBySideField subdocs unicode qual) (map unLoc fields)) -    ppOccInfix = case occ of-      [one] -> ppBinderInfix False one-      _     -> hsep (punctuate comma (map (ppBinderInfix False) occ))+    doConstrArgsWithDocs args = subFields pkg qual $ case con of+      ConDeclH98{} ->+        [ (ppLParendType unicode qual HideEmptyContexts arg, mdoc, [])+        | (i, arg) <- zip [0..] args+        , let mdoc = Map.lookup i argDocs+        ]+      ConDeclGADT{} ->+        ppSubSigLike unicode qual (unLoc (getGADTConType con))+                     argDocs subdocs (dcolon unicode) HideEmptyContexts+      XConDecl{} -> panic "haddock:doConstrArgsWithDocs" -    tyVars  = tyvarNames (fromMaybe (HsQTvs PlaceHolder [] PlaceHolder) (con_qvars con))-    context = unLoc (fromMaybe (noLoc []) (con_cxt con))-    forall_ = False     -- 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 (unLoc $ head $ getConNames con) subdocs >>=             combineDocumentation . fst  +-- ppConstrHdr is for (non-GADT) existentials constructors' syntax+ppConstrHdr :: Bool               -- ^ print explicit foralls+            -> [Name]             -- ^ type variables+            -> HsContext DocNameI -- ^ context+            -> Unicode -> Qualification -> Html+ppConstrHdr forall_ tvs ctxt unicode qual = ppForall +++ ppCtxt+  where+    ppForall+      | null tvs || not forall_ = noHtml+      | otherwise = forallSymbol unicode+                      <+> hsep (map (ppName Prefix) tvs)+                      <+> toHtml ". "++    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 (map ((ppBinder False) . rdrNameOcc . unLoc . rdrNameFieldOcc . unLoc) names))+ppSideBySideField subdocs unicode qual (ConDeclField _ names ltype _) =+  ( hsep (punctuate comma [ ppBinder False (rdrNameOcc field)+                          | L _ name <- names+                          , let field = (unLoc . rdrNameFieldOcc) name+                          ])       <+> dcolon unicode       <+> ppLType unicode qual HideEmptyContexts ltype   , mbDoc@@ -900,15 +1012,51 @@   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 (selectorFieldOcc $ unLoc $ head names) subdocs >>= combineDocumentation . fst+    mbDoc = lookup (extFieldOcc $ unLoc $ head names) subdocs >>= combineDocumentation . fst+ppSideBySideField _ _ _ (XConDeclField _) = panic "haddock:ppSideBySideField"   ppShortField :: Bool -> Unicode -> Qualification -> ConDeclField DocNameI -> Html-ppShortField summary unicode qual (ConDeclField names ltype _)+ppShortField summary unicode qual (ConDeclField _ names ltype _)   = hsep (punctuate comma (map ((ppBinder summary) . rdrNameOcc . unLoc . rdrNameFieldOcc . unLoc) names))     <+> dcolon unicode <+> ppLType unicode qual HideEmptyContexts ltype+ppShortField _ _ _ (XConDeclField _) = panic "haddock:ppShortField"  +-- | Pretty print an expanded pattern (for bundled patterns)+ppSideBySidePat :: [(DocName, Fixity)] -> Unicode -> Qualification+                   -> [Located 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 (hsSigType typ)+                            , fixity+                            ]++    fieldPart+      | not hasArgDocs = []+      | otherwise = [ subFields Nothing qual (ppSubSigLike unicode qual (unLoc patTy)+                                                        argDocs [] (dcolon unicode)+                                                        emptyCtxt) ]++    patTy = hsSigType typ+    emptyCtxt = patSigContext patTy++ -- | 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@@ -953,129 +1101,112 @@ -- * Rendering of HsType -------------------------------------------------------------------------------- --pREC_TOP, pREC_CTX, pREC_FUN, pREC_OP, pREC_CON :: Int--pREC_TOP = 0 :: Int   -- type in ParseIface.y in GHC-pREC_CTX = 1 :: Int   -- Used for single contexts, eg. ctx => type-                      -- (as opposed to (ctx1, ctx2) => type)-pREC_FUN = 2 :: Int   -- btype in ParseIface.y in GHC-                      -- Used for LH arg of (->)-pREC_OP  = 3 :: Int   -- Used for arg of any infix operator-                      -- (we don't keep their fixities around)-pREC_CON = 4 :: Int   -- Used for arg of type applicn:-                      -- always parenthesise unless atomic--maybeParen :: Int           -- Precedence of context-           -> Int           -- Precedence of top-level operator-           -> Html -> Html  -- Wrap in parens if (ctxt >= op)-maybeParen ctxt_prec op_prec p | ctxt_prec >= op_prec = parens p-                               | otherwise            = p-- ppLType, ppLParendType, ppLFunLhType :: Unicode -> Qualification -> HideEmptyContexts -> Located (HsType 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)  ppCtxType :: Unicode -> Qualification -> HsType DocNameI -> Html-ppCtxType unicode qual ty = ppr_mono_ty pREC_CTX ty unicode qual HideEmptyContexts+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 pREC_TOP ty unicode qual emptyCtxts-ppParendType unicode qual emptyCtxts ty = ppr_mono_ty pREC_CON ty unicode qual emptyCtxts-ppFunLhType  unicode qual emptyCtxts ty = ppr_mono_ty pREC_FUN ty unicode qual emptyCtxts+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  ppHsTyVarBndr :: Unicode -> Qualification -> HsTyVarBndr DocNameI -> Html-ppHsTyVarBndr _       qual (UserTyVar (L _ name)) =+ppHsTyVarBndr _       qual (UserTyVar _ (L _ name)) =     ppDocName qual Raw False name-ppHsTyVarBndr unicode qual (KindedTyVar name kind) =+ppHsTyVarBndr unicode qual (KindedTyVar _ name kind) =     parens (ppDocName qual Raw False (unLoc name) <+> dcolon unicode <+>             ppLKind unicode qual kind)+ppHsTyVarBndr _ _ (XTyVarBndr _) = error "haddock:ppHsTyVarBndr"  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 pREC_TOP ki unicode qual HideEmptyContexts+ppKind unicode qual ki = ppr_mono_ty (reparenTypePrec PREC_TOP ki) unicode qual HideEmptyContexts -ppPatSigType :: Unicode -> Qualification -> LHsType DocNameI -> Html-ppPatSigType unicode qual typ =-  let emptyCtxts =-        if hasNonEmptyContext typ && isFirstContextEmpty typ-          then ShowEmptyToplevelContexts-          else HideEmptyContexts-  in ppLType unicode qual emptyCtxts typ+patSigContext :: LHsType name -> HideEmptyContexts+patSigContext typ | hasNonEmptyContext typ && isFirstContextEmpty typ =  ShowEmptyToplevelContexts+                  | otherwise = HideEmptyContexts   where     hasNonEmptyContext :: LHsType name -> Bool     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+        HsForAllTy _ _ s -> hasNonEmptyContext s+        HsQualTy _ cxt s -> if null (unLoc cxt) then hasNonEmptyContext s else True+        HsFunTy _ _ s    -> hasNonEmptyContext s         _ -> False     isFirstContextEmpty :: LHsType name -> Bool     isFirstContextEmpty t =       case unLoc t of-        HsForAllTy _ s -> isFirstContextEmpty s-        HsQualTy cxt _ -> null (unLoc cxt)-        HsFunTy _ s -> isFirstContextEmpty s+        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 -> LHsType DocNameI -> Html+ppPatSigType unicode qual typ =+  let emptyCtxts = patSigContext typ in ppLType unicode qual emptyCtxts typ+ ppForAllPart :: Unicode -> Qualification -> [LHsTyVarBndr DocNameI] -> Html ppForAllPart unicode qual tvs = hsep (forallSymbol unicode : ppTyVars unicode qual tvs) +++ dot -ppr_mono_lty :: Int -> LHsType DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html-ppr_mono_lty ctxt_prec ty = ppr_mono_ty ctxt_prec (unLoc ty)+ppr_mono_lty :: LHsType DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html+ppr_mono_lty ty = ppr_mono_ty (unLoc ty)  -ppr_mono_ty :: Int -> HsType DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html-ppr_mono_ty ctxt_prec (HsForAllTy tvs ty) unicode qual emptyCtxts-  = maybeParen ctxt_prec pREC_FUN $-    ppForAllPart unicode qual tvs <+> ppr_mono_lty pREC_TOP ty unicode qual emptyCtxts+ppr_mono_ty :: HsType DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html+ppr_mono_ty (HsForAllTy _ tvs ty) unicode qual emptyCtxts+  = ppForAllPart unicode qual tvs <+> ppr_mono_lty ty unicode qual emptyCtxts -ppr_mono_ty ctxt_prec (HsQualTy ctxt ty) unicode qual emptyCtxts-  = maybeParen ctxt_prec pREC_FUN $-    ppLContext ctxt unicode qual emptyCtxts <+> ppr_mono_lty pREC_TOP ty unicode qual emptyCtxts+ppr_mono_ty (HsQualTy _ ctxt ty) unicode qual emptyCtxts+  = ppLContext 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 (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 _ (L _ name)) _ q _ = ppDocName q Prefix True name-ppr_mono_ty ctxt_prec (HsFunTy ty1 ty2)   u q e = ppr_fun_ty ctxt_prec ty1 ty2 u q e-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 =-    parens (ppr_mono_lty pREC_TOP ty u q e <+> dcolon u <+> ppLKind u q kind)-ppr_mono_ty _         (HsListTy ty)       u q _ = brackets (ppr_mono_lty pREC_TOP ty u q HideEmptyContexts)-ppr_mono_ty _         (HsPArrTy ty)       u q _ = pabrackets (ppr_mono_lty pREC_TOP ty u q HideEmptyContexts)-ppr_mono_ty ctxt_prec (HsIParamTy (L _ n) ty) u q _ =-    maybeParen ctxt_prec pREC_CTX $ ppIPName n <+> dcolon u <+> ppr_mono_lty pREC_TOP ty u q HideEmptyContexts-ppr_mono_ty _         (HsSpliceTy {})     _ _ _ = error "ppr_mono_ty HsSpliceTy"-ppr_mono_ty _         (HsRecTy {})        _ _ _ = toHtml "{..}"+ppr_mono_ty (HsBangTy _ b ty) u q _ =+  ppBang b +++ ppLParendType u q HideEmptyContexts ty+ppr_mono_ty (HsTyVar _ _ (L _ name)) _ q _ =+  ppDocName q Prefix True name+ppr_mono_ty (HsStarTy _ isUni) u _ _ =+  toHtml (if u || isUni then "★" else "*")+ppr_mono_ty (HsFunTy _ ty1 ty2) u q e =+  hsep [ ppr_mono_lty ty1 u q HideEmptyContexts+       , arrow u <+> ppr_mono_lty ty2 u q e+       ]+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 =+  parens (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 {})     _ _ _ = error "ppr_mono_ty HsSpliceTy"+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 _         (HsCoreTy {})       _ _ _ = error "ppr_mono_ty HsCoreTy"-ppr_mono_ty _         (HsExplicitListTy Promoted _ 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 _         (HsAppsTy {})       _ _ _ = error "ppr_mono_ty HsAppsTy"--ppr_mono_ty ctxt_prec (HsEqTy ty1 ty2) unicode qual _-  = maybeParen ctxt_prec pREC_CTX $-    ppr_mono_lty pREC_OP ty1 unicode qual HideEmptyContexts <+> char '~' <+> ppr_mono_lty pREC_OP ty2 unicode qual HideEmptyContexts+ppr_mono_ty (XHsType (NHsCoreTy {})) _ _ _ = error "ppr_mono_ty HsCoreTy"+ppr_mono_ty (HsExplicitListTy _ Promoted 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 ctxt_prec (HsAppTy fun_ty arg_ty) unicode qual _-  = maybeParen ctxt_prec pREC_CON $-    hsep [ppr_mono_lty pREC_FUN fun_ty unicode qual HideEmptyContexts, ppr_mono_lty pREC_CON arg_ty unicode qual HideEmptyContexts]+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 ctxt_prec (HsOpTy ty1 op ty2) unicode qual _-  = maybeParen ctxt_prec pREC_FUN $-    ppr_mono_lty pREC_OP ty1 unicode qual HideEmptyContexts <+> ppr_op <+> ppr_mono_lty pREC_OP ty2 unicode qual HideEmptyContexts+ppr_mono_ty (HsOpTy _ ty1 op ty2) unicode qual _+  = ppr_mono_lty ty1 unicode qual HideEmptyContexts <+> ppr_op <+> ppr_mono_lty ty2 unicode qual HideEmptyContexts   where     -- `(:)` is valid in type signature only as constructor to promoted list     -- and needs to be quoted in code so we explicitly quote it here too.@@ -1084,24 +1215,17 @@         | otherwise = ppr_op'     ppr_op' = ppLDocName qual Infix op -ppr_mono_ty ctxt_prec (HsParTy ty) unicode qual emptyCtxts---  = parens (ppr_mono_lty pREC_TOP ty)-  = ppr_mono_lty ctxt_prec ty unicode qual emptyCtxts+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 ctxt_prec (HsDocTy ty _) unicode qual emptyCtxts-  = 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 (AnonWildCard _)) _ _ _ = char '_'-ppr_mono_ty _ (HsTyLit n) _ _ _ = ppr_tylit n+ppr_mono_ty (HsWildCardTy (AnonWildCard _)) _ _ _ = char '_'+ppr_mono_ty (HsTyLit _ n) _ _ _ = ppr_tylit n  ppr_tylit :: HsTyLit -> Html ppr_tylit (HsNumTy _ n) = toHtml (show n) ppr_tylit (HsStrTy _ s) = toHtml (show s) -ppr_fun_ty :: Int -> LHsType DocNameI -> LHsType DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html-ppr_fun_ty ctxt_prec ty1 ty2 unicode qual emptyCtxts-  = let p1 = ppr_mono_lty pREC_FUN ty1 unicode qual HideEmptyContexts-        p2 = ppr_mono_lty pREC_TOP ty2 unicode qual emptyCtxts-    in-    maybeParen ctxt_prec pREC_FUN $-    hsep [p1, arrow unicode <+> p2]
src/Haddock/Backends/Xhtml/Layout.hs view
@@ -40,7 +40,6 @@   topDeclElem, declElem, ) where - import Haddock.Backends.Xhtml.DocMarkup import Haddock.Backends.Xhtml.Types import Haddock.Backends.Xhtml.Utils@@ -48,6 +47,7 @@ import Haddock.Utils (makeAnchorId, nameAnchorId) import qualified Data.Map as Map import Text.XHtml hiding ( name, title, quote )+import Data.Maybe (fromMaybe)  import FastString            ( unpackFS ) import GHC@@ -151,21 +151,23 @@  -- | Sub table with source information (optional). subTableSrc :: Maybe Package -> Qualification -> LinksInfo -> Bool-            -> [(SubDecl,Located DocName)] -> Maybe Html+            -> [(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),L loc dn) =+    subRow ((decl, mdoc, subs), mdl, L loc dn) =       (td ! [theclass "src clearfix"] <<         (thespan ! [theclass "inst-left"] << decl)-        <+> linkHtml loc dn+        <+> linkHtml loc mdl dn       <->       docElement td << fmap (docToHtml Nothing pkg qual) mdoc       )       : map (cell . (td <<)) subs-    linkHtml loc@(RealSrcSpan _) dn = links lnks loc splice dn-    linkHtml _ _ = noHtml +    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@@ -197,7 +199,7 @@ subInstances :: Maybe Package -> Qualification              -> String -- ^ Class name, used for anchor generation              -> LinksInfo -> Bool-             -> [(SubDecl,Located DocName)] -> Html+             -> [(SubDecl, Maybe Module, Located DocName)] -> Html subInstances pkg qual nm lnks splice = maybe noHtml wrap . instTable   where     wrap contents = subSection (collapseDetails id_ DetailsOpen (summary +++ contents))@@ -209,7 +211,7 @@  subOrphanInstances :: Maybe Package -> Qualification                    -> LinksInfo -> Bool-                   -> [(SubDecl,Located DocName)] -> Html+                   -> [(SubDecl, Maybe Module, Located DocName)] -> Html subOrphanInstances pkg qual lnks splice  = maybe noHtml wrap . instTable   where     wrap = ((h1 << "Orphan instances") +++)@@ -268,13 +270,13 @@ -- 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 $ head names))+    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 -> DocName -> Html-links ((_,_,sourceMap,lineMap), (_,_,maybe_wiki_url)) loc splice docName@(Documented n mdl) =+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))) @@ -298,12 +300,13 @@          -- For source links, we want to point to the original module,         -- because only that will have the source.-        -- TODO: do something about type instances. They will point to-        -- the module defining the type family, which is wrong.-        origMod = nameModule n+        --+        -- '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 = moduleUnitId origMod          fname = case loc of           RealSrcSpan l -> unpackFS (srcSpanFile l)           UnhelpfulSpan _ -> error "links: UnhelpfulSpan"-links _ _ _ _ = noHtml+links _ _ _ _ _ = noHtml
src/Haddock/Backends/Xhtml/Utils.hs view
@@ -110,7 +110,7 @@  hsep :: [Html] -> Html hsep [] = noHtml-hsep htmls = foldr1 (\a b -> a+++" "+++b) htmls+hsep htmls = foldr1 (<+>) htmls  -- | Concatenate a series of 'Html' values vertically, with linebreaks in between. vcat :: [Html] -> Html
src/Haddock/Convert.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, PatternGuards #-}+{-# LANGUAGE CPP, PatternGuards, TypeFamilies #-} ----------------------------------------------------------------------------- -- | -- Module      :  Haddock.Convert@@ -31,13 +31,13 @@ import RdrName ( mkVarUnqual ) import PatSyn import SrcLoc ( Located, noLoc, unLoc, GenLocated(..), srcLocSpan )-import TcType ( tcSplitSigmaTy )+import TcType import TyCon import Type import TyCoRep import TysPrim ( alphaTyVars )-import TysWiredIn ( listTyConName, starKindTyConName, unitTy )-import PrelNames ( hasKey, eqTyConKey, ipClassKey+import TysWiredIn ( listTyConName, liftedTypeKindTyConName, unitTy )+import PrelNames ( hasKey, eqTyConKey, eqTyConName, ipClassKey                  , tYPETyConKey, liftedRepDataConKey ) import Unique ( getUnique ) import Util ( chkAppend, compareLength, dropList, filterByList, filterOut@@ -61,14 +61,14 @@   -- 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 (synifyIdSig ImplicitizeForAll i)+  AnId i -> allOK $ SigD noExt (synifyIdSig 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 ErrMsg (LFamilyDecl a)-           extractFamilyDecl (FamDecl d) = return $ noLoc d+           extractFamilyDecl (FamDecl _ d) = return $ noLoc d            extractFamilyDecl _           =              Left "tyThingToLHsDecl: impossible associated tycon" @@ -76,7 +76,7 @@            atFamDecls  = map extractFamilyDecl (rights atTyClDecls)            tyClErrors = lefts atTyClDecls            famDeclErrors = lefts atFamDecls-       in withErrs (tyClErrors ++ famDeclErrors) . TyClD $ ClassDecl+       in withErrs (tyClErrors ++ famDeclErrors) . TyClD noExt $ ClassDecl          { tcdCtxt = synifyCtx (classSCTheta cl)          , tcdLName = synifyName cl          , tcdTyVars = synifyTyVars (tyConVisibleTyVars (classTyCon cl))@@ -84,7 +84,7 @@          , tcdFDs = map (\ (l,r) -> noLoc                         (map (noLoc . getName) l, map (noLoc . getName) r) ) $                          snd $ classTvsFds cl-         , tcdSigs = noLoc (MinimalSig NoSourceText . noLoc . fmap noLoc $ classMinimalDef cl) :+         , tcdSigs = noLoc (MinimalSig noExt NoSourceText . noLoc . fmap noLoc $ classMinimalDef cl) :                       map (noLoc . synifyTcIdSig DeleteTopLevelQuantification)                         (classMethods cl)          , tcdMeths = emptyBag --ignore default method definitions, they don't affect signature@@ -92,20 +92,20 @@          , tcdATs = rights atFamDecls          , tcdATDefs = [] --ignore associated type defaults          , tcdDocs = [] --we don't have any docs at this point-         , tcdFVs = placeHolderNamesTc }+         , tcdCExt = placeHolderNamesTc }     | otherwise-    -> synifyTyCon Nothing tc >>= allOK . TyClD+    -> synifyTyCon Nothing tc >>= allOK . TyClD noExt    -- 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 (TypeSig [synifyName dc]+  AConLike (RealDataCon dc) -> allOK $ SigD noExt (TypeSig noExt [synifyName dc]     (synifySigWcType ImplicitizeForAll (dataConUserType dc)))    AConLike (PatSynCon ps) ->-    allOK . SigD $ PatSynSig [synifyName ps] (synifyPatSynSigType ps)+    allOK . SigD noExt $ PatSynSig noExt [synifyName ps] (synifyPatSynSigType ps)   where     withErrs e x = return (e, x)     allOK x = return (mempty, x)@@ -118,9 +118,10 @@         annot_typats    = zipWith3 annotHsType (mkIsPolyTvs fam_tvs)                                    args_types_only typats         hs_rhs          = synifyType WithinType rhs-    in HsIB { hsib_vars   = map tyVarName tkvs-            , hsib_closed = True-            , hsib_body   = FamEqn { feqn_tycon  = name+    in HsIB { hsib_ext = HsIBRn { hsib_vars   = map tyVarName tkvs+                                , hsib_closed = True }+            , hsib_body   = FamEqn { feqn_ext    = noExt+                                   , feqn_tycon  = name                                    , feqn_pats   = annot_typats                                    , feqn_fixity = Prefix                                    , feqn_rhs    = hs_rhs } }@@ -131,13 +132,13 @@ synifyAxiom ax@(CoAxiom { co_ax_tc = tc })   | isOpenTypeFamilyTyCon tc   , Just branch <- coAxiomSingleBranch_maybe ax-  = return $ InstD-           $ TyFamInstD+  = return $ InstD noExt+           $ TyFamInstD noExt            $ TyFamInstDecl { tfid_eqn = synifyAxBranch tc branch }    | Just ax' <- isClosedSynFamilyTyConWithAxiom_maybe tc   , getUnique ax' == getUnique ax   -- without the getUniques, type error-  = synifyTyCon (Just ax) tc >>= return . TyClD+  = synifyTyCon (Just ax) tc >>= return . TyClD noExt    | otherwise   = Left "synifyAxiom: closed/open family confusion"@@ -150,25 +151,27 @@     DataDecl { tcdLName = synifyName tc              , tcdTyVars =       -- tyConTyVars doesn't work on fun/prim, but we can make them up:                          let mk_hs_tv realKind fakeTyVar-                                = noLoc $ KindedTyVar (noLoc (getName fakeTyVar))+                                = noLoc $ KindedTyVar noExt (noLoc (getName fakeTyVar))                                                       (synifyKindSig realKind)-                         in HsQTvs { hsq_implicit = []   -- No kind polymorphism+                         in HsQTvs { hsq_ext =+                                       HsQTvsRn { hsq_implicit = []   -- No kind polymorphism+                                                , hsq_dependent = emptyNameSet }                                    , hsq_explicit = zipWith mk_hs_tv (fst (splitFunTys (tyConKind tc)))                                                                 alphaTyVars --a, b, c... which are unfortunately all kind *-                                   , hsq_dependent = emptyNameSet }+                                   }             , tcdFixity = Prefix -           , tcdDataDefn = HsDataDefn { dd_ND = DataType  -- arbitrary lie, they are neither+           , tcdDataDefn = HsDataDefn { dd_ext = noExt+                                      , dd_ND = DataType  -- arbitrary lie, they are neither                                                     -- algebraic data nor newtype:                                       , dd_ctxt = noLoc []                                       , dd_cType = Nothing-                                      , dd_kindSig = synifyDataTyConReturnKind tc+                                      , dd_kindSig = Just (synifyKindSig (tyConKind tc))                                                -- we have their kind accurately:                                       , dd_cons = []  -- No constructors                                       , dd_derivs = noLoc [] }-           , tcdDataCusk = False-           , tcdFVs = placeHolderNamesTc }+           , tcdDExt = DataDeclRn False placeHolderNamesTc }  synifyTyCon _coax tc   | Just flav <- famTyConFlav_maybe tc@@ -189,8 +192,9 @@         -> mkFamDecl DataFamily   where     resultVar = famTcResVar tc-    mkFamDecl i = return $ FamDecl $-      FamilyDecl { fdInfo = i+    mkFamDecl i = return $ FamDecl noExt $+      FamilyDecl { fdExt = noExt+                 , fdInfo = i                  , fdLName = synifyName tc                  , fdTyVars = synifyTyVars (tyConVisibleTyVars tc)                  , fdFixity = Prefix@@ -203,11 +207,11 @@  synifyTyCon coax tc   | Just ty <- synTyConRhs_maybe tc-  = return $ SynDecl { tcdLName = synifyName tc+  = return $ SynDecl { tcdSExt   = emptyNameSet+                     , tcdLName  = synifyName tc                      , tcdTyVars = synifyTyVars (tyConVisibleTyVars tc)                      , tcdFixity = Prefix-                     , tcdRhs = synifyType WithinType ty-                     , tcdFVs = placeHolderNamesTc }+                     , tcdRhs = synifyType WithinType ty }   | otherwise =   -- (closed) newtype and data   let@@ -240,7 +244,8 @@   cons = rights consRaw   -- "deriving" doesn't affect the signature, no need to specify any.   alg_deriv = noLoc []-  defn = HsDataDefn { dd_ND      = alg_nd+  defn = HsDataDefn { dd_ext     = noExt+                    , dd_ND      = alg_nd                     , dd_ctxt    = alg_ctx                     , dd_cType   = Nothing                     , dd_kindSig = kindSig@@ -250,7 +255,7 @@   [] -> return $         DataDecl { tcdLName = name, tcdTyVars = tyvars, tcdFixity = Prefix                  , tcdDataDefn = defn-                 , tcdDataCusk = False, tcdFVs = placeHolderNamesTc }+                 , tcdDExt = DataDeclRn False placeHolderNamesTc }   dataConErrs -> Left $ unlines dataConErrs  -- In this module, every TyCon being considered has come from an interface@@ -284,9 +289,9 @@  synifyFamilyResultSig :: Maybe Name -> Kind -> LFamilyResultSig GhcRn synifyFamilyResultSig  Nothing    kind =-   noLoc $ KindSig  (synifyKindSig kind)+   noLoc $ KindSig  noExt (synifyKindSig kind) synifyFamilyResultSig (Just name) kind =-   noLoc $ TyVarSig (noLoc $ KindedTyVar (noLoc name) (synifyKindSig kind))+   noLoc $ TyVarSig noExt (noLoc $ KindedTyVar noExt (noLoc 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@@ -304,10 +309,6 @@   -- con_qvars means a different thing depending on gadt-syntax   (univ_tvs, ex_tvs, _eq_spec, theta, arg_tys, res_ty) = dataConFullSig dc -  qvars = if use_gadt_syntax-          then synifyTyVars (univ_tvs ++ ex_tvs)-          else synifyTyVars ex_tvs-   -- skip any EqTheta, use 'orig'inal syntax   ctx = synifyCtx theta @@ -316,12 +317,12 @@                let tySyn = synifyType WithinType ty                in case bang of                     (HsSrcBang _ NoSrcUnpack NoSrcStrict) -> tySyn-                    bang' -> noLoc $ HsBangTy bang' tySyn)+                    bang' -> noLoc $ HsBangTy noExt bang' tySyn)             arg_tys (dataConSrcBangs dc)    field_tys = zipWith con_decl_field (dataConFieldLabels dc) linear_tys   con_decl_field fl synTy = noLoc $-    ConDeclField [noLoc $ FieldOcc (noLoc $ mkVarUnqual $ flLabel fl) (flSelector fl)] synTy+    ConDeclField noExt [noLoc $ FieldOcc (flSelector fl) (noLoc $ mkVarUnqual $ flLabel fl)] synTy                  Nothing   hs_arg_tys = case (use_named_field_syntax, use_infix_syntax) of           (True,True) -> Left "synifyDataCon: contradiction!"@@ -330,45 +331,51 @@           (False,True) -> case linear_tys of                            [a,b] -> return $ InfixCon a b                            _ -> Left "synifyDataCon: infix with non-2 args?"-  gadt_ty = HsIB [] (synifyType WithinType res_ty) False  -- finally we get synifyDataCon's result!  in hs_arg_tys >>=       \hat ->         if use_gadt_syntax            then return $ noLoc $-              ConDeclGADT { con_names = [name]-                          , con_type = gadt_ty-                          , con_doc =  Nothing }+              ConDeclGADT { con_g_ext  = noExt+                          , con_names  = [name]+                          , con_forall = noLoc True+                          , con_qvars  = synifyTyVars (univ_tvs ++ ex_tvs)+                          , con_mb_cxt = Just ctx+                          , con_args   =  hat+                          , con_res_ty = synifyType WithinType res_ty+                          , con_doc    =  Nothing }            else return $ noLoc $-              ConDeclH98 { con_name = name-                         , con_qvars = Just qvars-                         , con_cxt   = Just ctx-                         , con_details =  hat-                         , con_doc =  Nothing }+              ConDeclH98 { con_ext    = noExt+                         , con_name   = name+                         , con_forall = noLoc True+                         , con_ex_tvs = map synifyTyVar ex_tvs+                         , con_mb_cxt = Just ctx+                         , con_args   = hat+                         , con_doc    = Nothing }  synifyName :: NamedThing n => n -> Located Name synifyName n = L (srcLocSpan (getSrcLoc n)) (getName n)   synifyIdSig :: SynifyTypeState -> Id -> Sig GhcRn-synifyIdSig s i = TypeSig [synifyName i] (synifySigWcType s (varType i))+synifyIdSig s i = TypeSig noExt [synifyName i] (synifySigWcType s (varType i))  synifyTcIdSig :: SynifyTypeState -> Id -> Sig GhcRn-synifyTcIdSig s i = ClassOpSig False [synifyName i] (synifySigType s (varType i))+synifyTcIdSig s i = ClassOpSig noExt False [synifyName i] (synifySigType s (varType i))  synifyCtx :: [PredType] -> LHsContext GhcRn synifyCtx = noLoc . map (synifyType WithinType)   synifyTyVars :: [TyVar] -> LHsQTyVars GhcRn-synifyTyVars ktvs = HsQTvs { hsq_implicit = []-                           , hsq_explicit = map synifyTyVar ktvs-                           , hsq_dependent = emptyNameSet }+synifyTyVars ktvs = HsQTvs { hsq_ext = HsQTvsRn { hsq_implicit = []+                                                , hsq_dependent = emptyNameSet }+                           , hsq_explicit = map synifyTyVar ktvs }  synifyTyVar :: TyVar -> LHsTyVarBndr GhcRn synifyTyVar tv-  | isLiftedTypeKind kind = noLoc (UserTyVar (noLoc name))-  | otherwise             = noLoc (KindedTyVar (noLoc name) (synifyKindSig kind))+  | isLiftedTypeKind kind = noLoc (UserTyVar noExt (noLoc name))+  | otherwise             = noLoc (KindedTyVar noExt (noLoc name) (synifyKindSig kind))   where     kind = tyVarKind tv     name = getName tv@@ -385,7 +392,7 @@   | not $ isEmptyVarSet $ filterVarSet isTyVar $ tyCoVarsOfType ty   = let ki    = typeKind ty         hs_ki = synifyType WithinType ki-    in noLoc (HsKindSig hs_ty hs_ki)+    in noLoc (HsKindSig noExt hs_ty hs_ki) annotHsType _    _ hs_ty = hs_ty  -- | For every type variable in the input,@@ -430,7 +437,7 @@ synifyPatSynSigType ps = mkEmptyImplicitBndrs (synifyPatSynType ps)  synifyType :: SynifyTypeState -> Type -> LHsType GhcRn-synifyType _ (TyVarTy tv) = noLoc $ HsTyVar NotPromoted $ noLoc (getName tv)+synifyType _ (TyVarTy tv) = noLoc $ HsTyVar noExt NotPromoted $ noLoc (getName tv) synifyType _ (TyConApp tc tys)   = maybe_sig res_ty   where@@ -440,41 +447,46 @@       | tc `hasKey` tYPETyConKey       , [TyConApp lev []] <- tys       , lev `hasKey` liftedRepDataConKey-      = noLoc (HsTyVar NotPromoted (noLoc starKindTyConName))+      = noLoc (HsTyVar noExt NotPromoted (noLoc liftedTypeKindTyConName))       -- Use non-prefix tuple syntax where possible, because it looks nicer.       | Just sort <- tyConTuple_maybe tc       , tyConArity tc == length tys-      = noLoc $ HsTupleTy (case sort of+      = noLoc $ HsTupleTy noExt+                          (case sort of                               BoxedTuple      -> HsBoxedTuple                               ConstraintTuple -> HsConstraintTuple                               UnboxedTuple    -> HsUnboxedTuple)                            (map (synifyType WithinType) vis_tys)       -- ditto for lists       | getName tc == listTyConName, [ty] <- tys =-         noLoc $ HsListTy (synifyType WithinType ty)+         noLoc $ HsListTy noExt (synifyType WithinType ty)       -- ditto for implicit parameter tycons       | tc `hasKey` ipClassKey       , [name, ty] <- tys       , Just x <- isStrLitTy name-      = noLoc $ HsIParamTy (noLoc $ HsIPName x) (synifyType WithinType ty)+      = noLoc $ HsIParamTy noExt (noLoc $ HsIPName x) (synifyType WithinType ty)       -- and equalities       | tc `hasKey` eqTyConKey       , [ty1, ty2] <- tys-      = noLoc $ HsEqTy (synifyType WithinType ty1) (synifyType WithinType ty2)+      = noLoc $ HsOpTy noExt+                       (synifyType WithinType ty1)+                       (noLoc eqTyConName)+                       (synifyType WithinType ty2)       -- and infix type operators       | isSymOcc (nameOccName (getName tc))       , ty1:ty2:tys_rest <- vis_tys-      = mk_app_tys (HsOpTy (synifyType WithinType ty1)+      = mk_app_tys (HsOpTy noExt+                           (synifyType WithinType ty1)                            (noLoc $ getName tc)                            (synifyType WithinType ty2))                    tys_rest       -- Most TyCons:       | otherwise-      = mk_app_tys (HsTyVar NotPromoted $ noLoc (getName tc))+      = mk_app_tys (HsTyVar noExt NotPromoted $ noLoc (getName tc))                    vis_tys       where         mk_app_tys ty_app ty_args =-          foldl (\t1 t2 -> noLoc $ HsAppTy t1 t2)+          foldl (\t1 t2 -> noLoc $ HsAppTy noExt t1 t2)                 (noLoc ty_app)                 (map (synifyType WithinType) $                  filterOut isCoercionTy ty_args)@@ -488,7 +500,7 @@       | needs_kind_sig       = let full_kind  = typeKind (mkTyConApp tc tys)             full_kind' = synifyType WithinType full_kind-        in noLoc $ HsKindSig ty' full_kind'+        in noLoc $ HsKindSig noExt ty' full_kind'       | otherwise = ty'      needs_kind_sig :: Bool@@ -509,22 +521,24 @@ synifyType _ (AppTy t1 t2) = let   s1 = synifyType WithinType t1   s2 = synifyType WithinType t2-  in noLoc $ HsAppTy s1 s2+  in noLoc $ HsAppTy noExt s1 s2 synifyType _ (FunTy t1 t2) = let   s1 = synifyType WithinType t1   s2 = synifyType WithinType t2-  in noLoc $ HsFunTy s1 s2+  in noLoc $ HsFunTy noExt s1 s2 synifyType s forallty@(ForAllTy _tv _ty) =-  let (tvs, ctx, tau) = tcSplitSigmaTy forallty+  let (tvs, ctx, tau) = tcSplitSigmaTyPreserveSynonyms forallty       sPhi = HsQualTy { hst_ctxt = synifyCtx ctx+                      , hst_xqual   = noExt                       , hst_body = synifyType WithinType tau }   in case s of     DeleteTopLevelQuantification -> synifyType ImplicitizeForAll tau     WithinType        -> noLoc $ HsForAllTy { hst_bndrs = map synifyTyVar tvs+                                            , hst_xforall = noExt                                             , hst_body  = noLoc sPhi }     ImplicitizeForAll -> noLoc sPhi -synifyType _ (LitTy t) = noLoc $ HsTyLit $ synifyTyLit t+synifyType _ (LitTy t) = noLoc $ HsTyLit noExt $ synifyTyLit t synifyType s (CastTy t _) = synifyType s t synifyType _ (CoercionTy {}) = error "synifyType:Coercion" @@ -537,10 +551,12 @@                -- possible by taking theta = [], as that will print no context at all              | otherwise = req_theta   sForAll []  s = s-  sForAll tvs s = HsForAllTy { hst_bndrs = map synifyTyVar tvs-                             , hst_body  = noLoc s }-  sQual theta s = HsQualTy   { hst_ctxt  = synifyCtx theta-                             , hst_body  = noLoc s }+  sForAll tvs s = HsForAllTy { hst_bndrs   = map synifyTyVar tvs+                             , hst_xforall = noExt+                             , hst_body    = noLoc s }+  sQual theta s = HsQualTy   { hst_ctxt    = synifyCtx theta+                             , hst_xqual   = noExt+                             , hst_body    = noLoc s }   sTau = unLoc $ synifyType WithinType $ mkFunTys arg_tys res_ty   in noLoc $ sForAll univ_tvs $ sQual req_theta' $ sForAll ex_tvs $ sQual prov_theta sTau @@ -560,7 +576,7 @@         , clsiTyVars = synifyTyVars (tyConVisibleTyVars cls_tycon)         , clsiSigs = map synifyClsIdSig $ classMethods cls         , clsiAssocTys = do-            (Right (FamDecl fam)) <- map (synifyTyCon Nothing) $ classATs cls+            (Right (FamDecl _ fam)) <- map (synifyTyCon Nothing) $ classATs cls             pure $ mkPseudoFamilyDecl fam         }     }@@ -610,3 +626,47 @@     ts' = synifyTypes ts     annot_ts = zipWith3 annotHsType is_poly_tvs ts ts'     is_poly_tvs = mkIsPolyTvs (tyConVisibleTyVars 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 preserves type synonyms.+--+-- See Note [Invariant: Never expand type synonyms]+tcSplitSigmaTyPreserveSynonyms :: Type -> ([TyVar], ThetaType, Type)+tcSplitSigmaTyPreserveSynonyms ty =+    case tcSplitForAllTysPreserveSynonyms ty of+      (tvs, rho) -> case tcSplitPhiTyPreserveSynonyms rho of+        (theta, tau) -> (tvs, theta, tau)++-- | See Note [Invariant: Never expand type synonyms]+tcSplitForAllTysPreserveSynonyms :: Type -> ([TyVar], Type)+tcSplitForAllTysPreserveSynonyms ty = split ty ty []+  where+    split _       (ForAllTy (TvBndr tv _) ty') tvs = split ty' ty' (tv:tvs)+    split orig_ty _                            tvs = (reverse tvs, orig_ty)++-- | 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 arg res)+  | isPredTy arg = Just (arg, res)+tcSplitPredFunTyPreserveSynonyms_maybe _+  = Nothing
src/Haddock/GhcUtils.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns, FlexibleInstances, ViewPatterns #-}+{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_HADDOCK hide #-} -----------------------------------------------------------------------------@@ -17,6 +18,7 @@   import Control.Arrow+import Haddock.Types( DocNameI )  import Exception import Outputable@@ -27,8 +29,11 @@ import HscTypes import GHC import Class+import DynFlags +import HsTypes (HsType(..)) + moduleString :: Module -> String moduleString = moduleNameString . moduleName @@ -44,57 +49,65 @@   getMainDeclBinder :: HsDecl name -> [IdP name]-getMainDeclBinder (TyClD d) = [tcdName d]-getMainDeclBinder (ValD d) =+getMainDeclBinder (TyClD _ d) = [tcdName d]+getMainDeclBinder (ValD _ d) =   case collectHsBindBinders d of     []       -> []     (name:_) -> [name]-getMainDeclBinder (SigD d) = sigNameNoLoc d-getMainDeclBinder (ForD (ForeignImport name _ _ _)) = [unLoc name]-getMainDeclBinder (ForD (ForeignExport _ _ _ _)) = []+getMainDeclBinder (SigD _ d) = sigNameNoLoc d+getMainDeclBinder (ForD _ (ForeignImport _ name _ _)) = [unLoc name]+getMainDeclBinder (ForD _ (ForeignExport _ _ _ _)) = [] getMainDeclBinder _ = []  -- Extract the source location where an instance is defined. This is used -- to correlate InstDecls with their Instance/CoAxiom Names, via the -- instanceMap. getInstLoc :: InstDecl name -> SrcSpan-getInstLoc (ClsInstD (ClsInstDecl { cid_poly_ty = ty })) = getLoc (hsSigType ty)-getInstLoc (DataFamInstD (DataFamInstDecl+getInstLoc (ClsInstD _ (ClsInstDecl { cid_poly_ty = ty })) = getLoc (hsSigType ty)+getInstLoc (DataFamInstD _ (DataFamInstDecl   { dfid_eqn = HsIB { hsib_body = FamEqn { feqn_tycon = L l _ }}})) = l-getInstLoc (TyFamInstD (TyFamInstDecl+getInstLoc (TyFamInstD _ (TyFamInstDecl   -- Since CoAxioms' Names refer to the whole line for type family instances   -- in particular, we need to dig a bit deeper to pull out the entire   -- equation. This does not happen for data family instances, for some reason.   { tfid_eqn = HsIB { hsib_body = FamEqn { feqn_rhs = L l _ }}})) = l+getInstLoc (ClsInstD _ (XClsInstDecl _)) = panic "getInstLoc"+getInstLoc (DataFamInstD _ (DataFamInstDecl (HsIB _ (XFamEqn _)))) = panic "getInstLoc"+getInstLoc (TyFamInstD _ (TyFamInstDecl (HsIB _ (XFamEqn _)))) = panic "getInstLoc"+getInstLoc (XInstDecl _) = panic "getInstLoc"+getInstLoc (DataFamInstD _ (DataFamInstDecl (XHsImplicitBndrs _))) = panic "getInstLoc"+getInstLoc (TyFamInstD _ (TyFamInstDecl (XHsImplicitBndrs _))) = panic "getInstLoc" ++ -- 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 name -> Bool) -> LSig name -> Maybe (LSig name)+filterLSigNames :: (IdP (GhcPass p) -> Bool) -> LSig (GhcPass p) -> Maybe (LSig (GhcPass p)) filterLSigNames p (L loc sig) = L loc <$> (filterSigNames p sig) -filterSigNames :: (IdP name -> Bool) -> Sig name -> Maybe (Sig name)-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 ty)) =+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 ty)) =   case filter (p . unLoc) ns of     []       -> Nothing-    filtered -> Just (FixSig (FixitySig filtered ty))-filterSigNames _ orig@(MinimalSig _ _)      = Just orig-filterSigNames p (TypeSig ns ty) =+    filtered -> Just (FixSig noExt (FixitySig noExt filtered ty))+filterSigNames _ orig@(MinimalSig _ _ _)      = Just orig+filterSigNames p (TypeSig _ ns ty) =   case filter (p . unLoc) ns of     []       -> Nothing-    filtered -> Just (TypeSig filtered ty)-filterSigNames p (ClassOpSig is_default ns ty) =+    filtered -> Just (TypeSig noExt filtered ty)+filterSigNames p (ClassOpSig _ is_default ns ty) =   case filter (p . unLoc) ns of     []       -> Nothing-    filtered -> Just (ClassOpSig is_default filtered ty)-filterSigNames p (PatSynSig ns ty) =+    filtered -> Just (ClassOpSig noExt is_default filtered ty)+filterSigNames p (PatSynSig _ ns ty) =   case filter (p . unLoc) ns of     []       -> Nothing-    filtered -> Just (PatSynSig filtered ty)-filterSigNames _ _                           = Nothing+    filtered -> Just (PatSynSig noExt filtered ty)+filterSigNames _ _                             = Nothing  ifTrueJust :: Bool -> name -> Maybe name ifTrueJust True  = Just@@ -104,13 +117,13 @@ sigName (L _ sig) = sigNameNoLoc sig  sigNameNoLoc :: Sig name -> [IdP name]-sigNameNoLoc (TypeSig      ns _)       = map unLoc ns-sigNameNoLoc (ClassOpSig _ ns _)       = map unLoc ns-sigNameNoLoc (PatSynSig    ns _)       = map unLoc ns-sigNameNoLoc (SpecSig      n _ _)      = [unLoc n]-sigNameNoLoc (InlineSig    n _)        = [unLoc n]-sigNameNoLoc (FixSig (FixitySig ns _)) = map unLoc ns-sigNameNoLoc _                         = []+sigNameNoLoc (TypeSig    _   ns _)         = map unLoc ns+sigNameNoLoc (ClassOpSig _ _ ns _)         = map unLoc ns+sigNameNoLoc (PatSynSig  _   ns _)         = map unLoc ns+sigNameNoLoc (SpecSig    _   n _ _)        = [unLoc n]+sigNameNoLoc (InlineSig  _   n _)          = [unLoc n]+sigNameNoLoc (FixSig _ (FixitySig _ ns _)) = map unLoc ns+sigNameNoLoc _                             = []  -- | Was this signature given by the user? isUserLSig :: LSig name -> Bool@@ -121,16 +134,16 @@   isClassD :: HsDecl a -> Bool-isClassD (TyClD d) = isClassDecl d+isClassD (TyClD _ d) = isClassDecl d isClassD _ = False  isValD :: HsDecl a -> Bool-isValD (ValD _) = True+isValD (ValD _ _) = True isValD _ = False   declATs :: HsDecl a -> [IdP a]-declATs (TyClD d) | isClassDecl d = map (unL . fdLName . unL) $ tcdATs d+declATs (TyClD _ d) | isClassDecl d = map (unL . fdLName . unL) $ tcdATs d declATs _ = []  @@ -148,7 +161,168 @@       where         y = f x +-- ---------------------------------------------------------------------++-- This function is duplicated as getGADTConType and getGADTConTypeG,+-- as I can't get the types to line up otherwise. AZ.++getGADTConType :: ConDecl DocNameI -> LHsType 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_forall = L _ has_forall+                            , con_qvars = qtvs+                            , con_mb_cxt = mcxt, con_args = args+                            , con_res_ty = res_ty })+ | has_forall = noLoc (HsForAllTy { hst_xforall = NoExt+                                  , hst_bndrs = hsQTvExplicit qtvs+                                  , hst_body  = theta_ty })+ | otherwise  = theta_ty+ where+   theta_ty | Just theta <- mcxt+            = noLoc (HsQualTy { hst_xqual = NoExt, hst_ctxt = theta, hst_body = tau_ty })+            | otherwise+            = tau_ty++   tau_ty = case args of+              RecCon flds -> noLoc (HsFunTy noExt (noLoc (HsRecTy noExt (unLoc flds))) res_ty)+              PrefixCon pos_args -> foldr mkFunTy res_ty pos_args+              InfixCon arg1 arg2 -> arg1 `mkFunTy` (arg2 `mkFunTy` res_ty)++   mkFunTy a b = noLoc (HsFunTy noExt a b)++getGADTConType (ConDeclH98 {}) = panic "getGADTConType"+  -- Should only be called on ConDeclGADT+getGADTConType (XConDecl {}) = panic "getGADTConType"++-- -------------------------------------++getGADTConTypeG :: ConDecl (GhcPass p) -> LHsType (GhcPass p)+-- 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+getGADTConTypeG (ConDeclGADT { con_forall = L _ has_forall+                            , con_qvars = qtvs+                            , con_mb_cxt = mcxt, con_args = args+                            , con_res_ty = res_ty })+ | has_forall = noLoc (HsForAllTy { hst_xforall = NoExt+                                  , hst_bndrs = hsQTvExplicit qtvs+                                  , hst_body  = theta_ty })+ | otherwise  = theta_ty+ where+   theta_ty | Just theta <- mcxt+            = noLoc (HsQualTy { hst_xqual = NoExt, hst_ctxt = theta, hst_body = tau_ty })+            | otherwise+            = tau_ty++   tau_ty = case args of+              RecCon flds -> noLoc (HsFunTy noExt (noLoc (HsRecTy noExt (unLoc flds))) res_ty)+              PrefixCon pos_args -> foldr mkFunTy res_ty pos_args+              InfixCon arg1 arg2 -> arg1 `mkFunTy` (arg2 `mkFunTy` res_ty)++   mkFunTy a b = noLoc (HsFunTy noExt a b)++getGADTConTypeG (ConDeclH98 {}) = panic "getGADTConTypeG"+  -- Should only be called on ConDeclGADT+getGADTConTypeG (XConDecl {}) = panic "getGADTConTypeG"++ -------------------------------------------------------------------------------+-- * Parenthesization+-------------------------------------------------------------------------------++-- | Precedence level (inside the 'HsType' AST).+data Precedence+  = PREC_TOP  -- ^ precedence of 'type' production in GHC's parser++  | PREC_CTX  -- ^ Used for single contexts, eg. ctx => type+              -- (as opposed to (ctx1, ctx2) => type)++  | PREC_FUN  -- ^ precedence of 'btype' production in GHC's parser+              -- (used for LH arg of (->))++  | PREC_OP   -- ^ arg of any infix operator+              -- (we don't keep have fixity info)++  | PREC_CON  -- ^ arg of type application: always parenthesize unless atomic+  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 :: (XParTy a ~ NoExt) => Precedence -> HsType a -> HsType a+reparenTypePrec = go+  where++  -- Shorter name for 'reparenType'+  go :: (XParTy a ~ NoExt) => 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 _ (HsKindSig x ty kind) = HsKindSig x (reparenLType ty) (reparenLType kind)+  go _ (HsListTy x ty)       = HsListTy x (reparenLType ty)+  go _ (HsRecTy x flds)      = HsRecTy x (map (fmap 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 (HsIParamTy x n ty)+    = paren p PREC_CTX $ HsIParamTy x n (reparenLType ty)+  go p (HsForAllTy x tvs ty)+    = paren p PREC_CTX $ HsForAllTy x (map (fmap reparenTyVar) tvs) (reparenLType ty)+  go p (HsQualTy x ctxt ty)+    = paren p PREC_FUN $ HsQualTy x (fmap (map reparenLType) ctxt) (reparenLType ty)+  go p (HsFunTy x ty1 ty2)+    = paren p PREC_FUN $ HsFunTy x (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 (HsOpTy x ty1 op ty2)+    = paren p PREC_FUN $ HsOpTy x (goL PREC_OP ty1) op (goL PREC_OP ty2)+  go p (HsParTy _ t) = unLoc $ 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 :: (XParTy a ~ NoExt) => Precedence -> LHsType a -> LHsType a+  goL ctxt_prec = fmap (go ctxt_prec)++  -- Optionally wrap a type in parens+  paren :: (XParTy a ~ NoExt)+        => 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 NoExt . noLoc+                          | otherwise            = id+++-- | Add parenthesis around the types in a 'HsType' (see 'reparenTypePrec')+reparenType :: (XParTy a ~ NoExt) => HsType a -> HsType a+reparenType = reparenTypePrec PREC_TOP++-- | Add parenthesis around the types in a 'LHsType' (see 'reparenTypePrec')+reparenLType :: (XParTy a ~ NoExt) => LHsType a -> LHsType a+reparenLType = fmap reparenType++-- | Add parenthesis around the types in a 'HsTyVarBndr' (see 'reparenTypePrec')+reparenTyVar :: (XParTy a ~ NoExt) => HsTyVarBndr a -> HsTyVarBndr a+reparenTyVar (UserTyVar x n) = UserTyVar x n+reparenTyVar (KindedTyVar x n kind) = KindedTyVar x n (reparenLType kind)+reparenTyVar v@XTyVarBndr{} = v++-- | Add parenthesis around the types in a 'ConDeclField' (see 'reparenTypePrec')+reparenConDeclField :: (XParTy a ~ NoExt) => ConDeclField a -> ConDeclField a+reparenConDeclField (ConDeclField x n t d) = ConDeclField x n (reparenLType t) d+reparenConDeclField c@XConDeclField{} = c+++------------------------------------------------------------------------------- -- * Located ------------------------------------------------------------------------------- @@ -179,8 +353,8 @@  instance Parent (ConDecl GhcRn) where   children con =-    case getConDetails con of-      RecCon fields -> map (selectorFieldOcc . unL) $+    case con_args con of+      RecCon fields -> map (extFieldOcc . unL) $                          concatMap (cd_fld_names . unL) (unL fields)       _             -> [] @@ -190,7 +364,7 @@                               $ (dd_cons . tcdDataDefn) $ d     | isClassDecl d =         map (unL . fdLName . unL) (tcdATs d) ++-        [ unL n | L _ (TypeSig ns _) <- tcdSigs d, n <- ns ]+        [ unL n | L _ (TypeSig _ ns _) <- tcdSigs d, n <- ns ]     | otherwise = []  @@ -218,7 +392,7 @@  -- | 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 n (TyClD _ d) = [ p | (c, p) <- parentMap d, c == n ] parents _ _ = []  @@ -255,7 +429,10 @@ setObjectDir, setHiDir, setStubDir, setOutputDir :: String -> DynFlags -> DynFlags setObjectDir  f d = d{ objectDir  = Just f} setHiDir      f d = d{ hiDir      = Just f}-setStubDir    f d = d{ stubDir    = Just f, includePaths = f : includePaths d }+setStubDir    f d = d{ stubDir    = Just f+                     , includePaths = addGlobalInclude (includePaths d) [f] }   -- -stubdir D adds an implicit -I D, so that gcc can find the _stub.h file   -- \#included from the .hc file when compiling with -fvia-C. setOutputDir  f = setObjectDir f . setHiDir f . setStubDir f++
src/Haddock/Interface.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, OverloadedStrings #-}+{-# LANGUAGE CPP, OverloadedStrings, BangPatterns #-} ----------------------------------------------------------------------------- -- | -- Module      :  Haddock.Interface@@ -51,6 +51,7 @@ import System.FilePath import Text.Printf +import Module (mkModuleSet, emptyModuleSet, unionModuleSet, ModuleSet) import Digraph import DynFlags hiding (verbosity) import Exception@@ -59,7 +60,9 @@ import FastString (unpackFS) import MonadUtils (liftIO) import TcRnTypes (tcg_rdr_env)-import RdrName (plusGlobalRdrEnv)+import Name (nameIsFromExternalPackage, nameOccName)+import OccName (isTcOcc)+import RdrName (unQualOK, gre_name, globalRdrEnvElts) import ErrUtils (withTiming)  #if defined(mingw32_HOST_OS)@@ -87,7 +90,7 @@   out verbosity verbose "Creating interfaces..."   let instIfaceMap =  Map.fromList [ (instMod iface, iface) | ext <- extIfaces                                    , iface <- ifInstalledIfaces ext ]-  interfaces <- createIfaces0 verbosity modules flags instIfaceMap+  (interfaces, ms) <- createIfaces0 verbosity modules flags instIfaceMap    let exportedNames =         Set.unions $ map (Set.fromList . ifaceExports) $@@ -96,7 +99,7 @@   out verbosity verbose "Attaching instances..."   interfaces' <- {-# SCC attachInstances #-}                  withTiming getDynFlags "attachInstances" (const ()) $ do-                   attachInstances (exportedNames, mods) interfaces instIfaceMap+                   attachInstances (exportedNames, mods) interfaces instIfaceMap ms    out verbosity verbose "Building cross-linking environment..."   -- Combine the link envs of the external packages into one@@ -120,7 +123,7 @@ --------------------------------------------------------------------------------  -createIfaces0 :: Verbosity -> [String] -> [Flag] -> InstIfaceMap -> Ghc [Interface]+createIfaces0 :: Verbosity -> [String] -> [Flag] -> InstIfaceMap -> Ghc ([Interface], ModuleSet) createIfaces0 verbosity modules flags instIfaceMap =   -- 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@@ -150,44 +153,52 @@       depanal [] False  -createIfaces :: Verbosity -> [Flag] -> InstIfaceMap -> ModuleGraph -> Ghc [Interface]+createIfaces :: Verbosity -> [Flag] -> InstIfaceMap -> ModuleGraph -> Ghc ([Interface], ModuleSet) createIfaces verbosity flags instIfaceMap mods = do   let sortedMods = flattenSCCs $ topSortModuleGraph False mods Nothing   out verbosity normal "Haddock coverage:"-  (ifaces, _) <- foldM f ([], Map.empty) sortedMods-  return (reverse ifaces)+  (ifaces, _, !ms) <- foldM f ([], Map.empty, emptyModuleSet) sortedMods+  return (reverse ifaces, ms)   where-    f (ifaces, ifaceMap) modSummary = do+    f (ifaces, ifaceMap, !ms) modSummary = do       x <- {-# SCC processModule #-}            withTiming getDynFlags "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.+        Just (iface, ms') -> ( iface:ifaces+                             , Map.insert (ifaceMod iface) iface ifaceMap+                             , unionModuleSet ms ms' )+        Nothing           -> ( ifaces+                             , ifaceMap+                             , ms ) -- Boot modules don't generate ifaces.  -processModule :: Verbosity -> ModSummary -> [Flag] -> IfaceMap -> InstIfaceMap -> Ghc (Maybe Interface)+processModule :: Verbosity -> ModSummary -> [Flag] -> IfaceMap -> InstIfaceMap -> Ghc (Maybe (Interface, ModuleSet)) processModule verbosity modsum flags modMap instIfaceMap = do   out verbosity verbose $ "Checking module " ++ moduleString (ms_mod modsum) ++ "..."   tm <- {-# SCC "parse/typecheck/load" #-} loadModule =<< typecheckModule =<< parseModule modsum -  -- We need to modify the interactive context's environment so that when-  -- Haddock later looks for instances, it also looks in the modules it-  -- encountered while typechecking.-  ---  -- See https://github.com/haskell/haddock/issues/469.-  hsc_env@HscEnv{ hsc_IC = old_IC } <- getSession-  let new_rdr_env = tcg_rdr_env . fst . GHC.tm_internals_ $ tm-  setSession hsc_env{ hsc_IC = old_IC {-    ic_rn_gbl_env = ic_rn_gbl_env old_IC `plusGlobalRdrEnv` new_rdr_env-  } }-   if not $ isBootSummary modsum then do     out verbosity verbose "Creating interface..."-    (interface, msg) <- {-# SCC createIterface #-}+    (interface, msgs) <- {-# SCC createIterface #-}                         withTiming getDynFlags "createInterface" (const ()) $ do                           runWriterGhc $ createInterface tm flags modMap instIfaceMap-    liftIO $ mapM_ putStrLn msg++    -- We need to keep track of which modules were somehow in scope so that when+    -- Haddock later looks for instances, it also looks in these modules too.+    --+    -- See https://github.com/haskell/haddock/issues/469.+    hsc_env <- getSession+    let new_rdr_env = tcg_rdr_env . fst . GHC.tm_internals_ $ tm+        this_pkg = thisPackage (hsc_dflags hsc_env)+        !mods = mkModuleSet [ nameModule name+                            | gre <- globalRdrEnvElts new_rdr_env+                            , let name = gre_name gre+                            , nameIsFromExternalPackage this_pkg name+                            , isTcOcc (nameOccName name)   -- Types and classes only+                            , unQualOK gre ]               -- In scope unqualified++    liftIO $ mapM_ putStrLn (nub msgs)     dflags <- getDynFlags     let (haddockable, haddocked) = ifaceHaddockCoverage interface         percentage = round (fromIntegral haddocked * 100 / fromIntegral haddockable :: Double) :: Int@@ -220,7 +231,7 @@         unless header $ out verbosity normal "    Module header"         mapM_ (out verbosity normal . ("    " ++)) undocumentedExports     interface' <- liftIO $ evaluate interface-    return (Just interface')+    return (Just (interface', mods))   else     return Nothing 
src/Haddock/Interface/AttachInstances.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, MagicHash #-}+{-# LANGUAGE CPP, MagicHash, BangPatterns #-} {-# LANGUAGE TypeFamilies #-} ----------------------------------------------------------------------------- -- |@@ -34,6 +34,7 @@ import FastString import GHC import InstEnv+import Module ( ModuleSet, moduleSetElts ) import MonadUtils (liftIO) import Name import NameEnv@@ -51,11 +52,13 @@ type ExportInfo = (ExportedNames, Modules)  -- Also attaches fixities-attachInstances :: ExportInfo -> [Interface] -> InstIfaceMap -> Ghc [Interface]-attachInstances expInfo ifaces instIfaceMap = do-  (_msgs, mb_index) <- getNameToInstancesIndex (map ifaceMod ifaces)+attachInstances :: ExportInfo -> [Interface] -> InstIfaceMap -> ModuleSet -> Ghc [Interface]+attachInstances expInfo ifaces instIfaceMap mods = do+  (_msgs, mb_index) <- getNameToInstancesIndex (map ifaceMod ifaces) mods'   mapM (attach $ fromMaybe emptyNameEnv mb_index) ifaces   where+    mods' = Just (moduleSetElts mods)+     -- TODO: take an IfaceMap as input     ifaceMap = Map.fromList [ (ifaceMod i, i) | i <- ifaces ] @@ -86,7 +89,7 @@   -> Ghc (ExportItem GhcRn) attachToExportItem index expInfo iface ifaceMap instIfaceMap export =   case attachFixities export of-    e@ExportDecl { expItemDecl = L eSpan (TyClD d) } -> do+    e@ExportDecl { expItemDecl = L eSpan (TyClD _ d) } -> do       insts <-         let mb_instances  = lookupNameEnv index (tcdName d)             cls_instances = maybeToList mb_instances >>= fst
src/Haddock/Interface/Create.hs view
@@ -58,10 +58,10 @@ import Bag import RdrName import TcRnTypes-import FastString ( concatFS, unpackFS )+import FastString ( unpackFS, fastStringToByteString) import BasicTypes ( StringLiteral(..), SourceText(..) ) import qualified Outputable as O-import HsDecls    ( getConDetails )+import HsDecls ( getConArgs )   -- | Use a 'TypecheckedModule' to produce an 'Interface'.@@ -135,7 +135,7 @@                         $  map getName instances                         ++ map getName fam_instances       -- Locations of all TH splices-      splices = [ l | L l (SpliceD _) <- hsmodDecls hsm ]+      splices = [ l | L l (SpliceD _ _) <- hsmodDecls hsm ]    warningMap <- liftErrMsg (mkWarningMap dflags warnings gre exportedNames) @@ -304,11 +304,11 @@  parseWarning :: DynFlags -> GlobalRdrEnv -> WarningTxt -> ErrMsgM (Doc Name) parseWarning dflags gre w = case w of-  DeprecatedTxt _ msg -> format "Deprecated: " (concatFS $ map (sl_fs . unLoc) msg)-  WarningTxt    _ msg -> format "Warning: "    (concatFS $ map (sl_fs . unLoc) msg)+  DeprecatedTxt _ msg -> format "Deprecated: " (foldMap (fastStringToByteString . sl_fs . unLoc) msg)+  WarningTxt    _ msg -> format "Warning: "    (foldMap (fastStringToByteString . sl_fs . unLoc) msg)   where-    format x xs = DocWarning . DocParagraph . DocAppend (DocString x)-                  <$> processDocString dflags gre (HsDocString xs)+    format x bs = DocWarning . DocParagraph . DocAppend (DocString x)+                  <$> processDocString dflags gre (mkHsDocStringUtf8ByteString bs)   -------------------------------------------------------------------------------@@ -393,7 +393,7 @@             m'   <- traverse (processDocStringParas dflags pkgName gre) m             pure (doc', m') -      (doc, args) <- declDoc docStrs (typeDocs decl)+      (doc, args) <- declDoc docStrs (declTypeDocs decl)        let           subs :: [(Name, [HsDocString], Map Int HsDocString)]@@ -419,9 +419,12 @@     instanceMap = M.fromList [ (getSrcSpan n, n) | n <- instances ]      names :: SrcSpan -> HsDecl GhcRn -> [Name]-    names l (InstD d) = maybeToList (M.lookup loc instanceMap) -- See note [2].+    names _ (InstD _ d) = maybeToList (M.lookup loc instanceMap) -- See note [2].       where loc = case d of-              TyFamInstD _ -> l -- The CoAx's loc is the whole line, but only for TFs+              -- The CoAx's loc is the whole line, but only for TFs. The+              -- workaround is to dig into the family instance declaration and+              -- get the identifier with the right location.+              TyFamInstD _ (TyFamInstDecl d') -> getLoc (feqn_tycon (hsib_body d'))               _ -> getInstLoc d     names l (DerivD {}) = maybeToList (M.lookup l instanceMap) -- See note [2].     names _ decl = getMainDeclBinder decl@@ -446,67 +449,83 @@              -> HsDecl GhcRn              -> [(Name, [HsDocString], Map Int HsDocString)] subordinates instMap decl = case decl of-  InstD (ClsInstD d) -> do+  InstD _ (ClsInstD _ d) -> do     DataFamInstDecl { dfid_eqn = HsIB { hsib_body =       FamEqn { feqn_tycon = L l _              , feqn_rhs   = defn }}} <- unLoc <$> cid_datafam_insts d     [ (n, [], M.empty) | Just n <- [M.lookup l instMap] ] ++ dataSubs defn -  InstD (DataFamInstD (DataFamInstDecl (HsIB { hsib_body = d })))+  InstD _ (DataFamInstD _ (DataFamInstDecl (HsIB { hsib_body = d })))     -> dataSubs (feqn_rhs d)-  TyClD d | isClassDecl d -> classSubs d-          | isDataDecl  d -> dataSubs (tcdDataDefn d)+  TyClD _ d | isClassDecl d -> classSubs d+            | isDataDecl  d -> dataSubs (tcdDataDefn d)   _ -> []   where-    classSubs dd = [ (name, doc, typeDocs d) | (L _ d, doc) <- classDecls dd+    classSubs dd = [ (name, doc, declTypeDocs d) | (L _ d, doc) <- classDecls dd                    , name <- getMainDeclBinder d, not (isValD d)                    ]     dataSubs :: HsDataDefn GhcRn -> [(Name, [HsDocString], Map Int HsDocString)]     dataSubs dd = constrs ++ fields ++ derivs       where         cons = map unL $ (dd_cons dd)-        constrs = [ (unL cname, maybeToList $ fmap unL $ con_doc c, M.empty)+        constrs = [ (unL cname, maybeToList $ fmap unL $ con_doc c, conArgDocs c)                   | c <- cons, cname <- getConNames c ]-        fields  = [ (selectorFieldOcc n, maybeToList $ fmap unL doc, M.empty)-                  | RecCon flds <- map getConDetails cons-                  , L _ (ConDeclField ns _ doc) <- (unLoc flds)+        fields  = [ (extFieldOcc n, maybeToList $ fmap unL doc, M.empty)+                  | RecCon flds <- map getConArgs cons+                  , L _ (ConDeclField _ ns _ doc) <- (unLoc flds)                   , L _ n <- ns ]         derivs  = [ (instName, [unL doc], M.empty)-                  | HsIB { hsib_body = L l (HsDocTy _ doc) }+                  | HsIB { hsib_body = L l (HsDocTy _ _ doc) }                       <- concatMap (unLoc . deriv_clause_tys . unLoc) $                            unLoc $ dd_derivs dd                   , Just instName <- [M.lookup l instMap] ] +-- | Extract constructor argument docs from inside constructor decls.+conArgDocs :: ConDecl GhcRn -> Map Int HsDocString+conArgDocs con = case getConArgs con of+                   PrefixCon args -> go 0 (map unLoc args ++ ret)+                   InfixCon arg1 arg2 -> go 0 ([unLoc arg1, unLoc arg2] ++ ret)+                   RecCon _ -> go 1 ret+  where+    go n (HsDocTy _ _ (L _ ds) : tys) = M.insert n ds $ go (n+1) tys+    go n (HsBangTy _ _ (L _ (HsDocTy _ _ (L _ ds))) : tys) = M.insert n ds $ go (n+1) tys+    go n (_ : tys) = go (n+1) tys+    go _ [] = M.empty++    ret = case con of+            ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ]+            _ -> []++-- | Extract function argument docs from inside top-level decls.+declTypeDocs :: HsDecl GhcRn -> Map Int HsDocString+declTypeDocs (SigD  _ (TypeSig _ _ ty))          = typeDocs (unLoc (hsSigWcType ty))+declTypeDocs (SigD  _ (ClassOpSig _ _ _ ty))     = typeDocs (unLoc (hsSigType ty))+declTypeDocs (SigD  _ (PatSynSig _ _ ty))        = typeDocs (unLoc (hsSigType ty))+declTypeDocs (ForD  _ (ForeignImport _ _ ty _))  = typeDocs (unLoc (hsSigType ty))+declTypeDocs (TyClD _ (SynDecl { tcdRhs = ty })) = typeDocs (unLoc ty)+declTypeDocs _ = M.empty+ -- | Extract function argument docs from inside types.-typeDocs :: HsDecl GhcRn -> Map Int HsDocString-typeDocs d =-  let docs = go 0 in-  case d of-    SigD (TypeSig _ ty)      -> docs (unLoc (hsSigWcType ty))-    SigD (ClassOpSig _ _ ty) -> docs (unLoc (hsSigType ty))-    SigD (PatSynSig _ ty)    -> docs (unLoc (hsSigType ty))-    ForD (ForeignImport _ ty _ _)   -> docs (unLoc (hsSigType ty))-    TyClD (SynDecl { tcdRhs = ty }) -> docs (unLoc ty)-    _ -> M.empty+typeDocs :: HsType GhcRn -> Map Int HsDocString+typeDocs = go 0   where     go n (HsForAllTy { hst_body = ty }) = go n (unLoc ty)     go n (HsQualTy   { hst_body = ty }) = go n (unLoc ty)-    go n (HsFunTy (L _ (HsDocTy _ (L _ x))) (L _ ty)) = M.insert n x $ go (n+1) ty-    go n (HsFunTy _ ty) = go (n+1) (unLoc ty)-    go n (HsDocTy _ (L _ doc)) = M.singleton n doc+    go n (HsFunTy _ (L _ (HsDocTy _ _ (L _ x))) (L _ ty)) = M.insert n x $ go (n+1) ty+    go n (HsFunTy _ _ ty) = go (n+1) (unLoc ty)+    go n (HsDocTy _ _ (L _ doc)) = M.singleton n doc     go _ _ = M.empty - -- | All the sub declarations of a class (that we handle), ordered by -- source location, with documentation attached if it exists. classDecls :: TyClDecl GhcRn -> [(LHsDecl GhcRn, [HsDocString])] classDecls class_ = filterDecls . collectDocs . sortByLoc $ decls   where     decls = docs ++ defs ++ sigs ++ ats-    docs  = mkDecls tcdDocs DocD class_-    defs  = mkDecls (bagToList . tcdMeths) ValD class_-    sigs  = mkDecls tcdSigs SigD class_-    ats   = mkDecls tcdATs (TyClD . FamDecl) class_+    docs  = mkDecls tcdDocs (DocD noExt) class_+    defs  = mkDecls (bagToList . tcdMeths) (ValD noExt) class_+    sigs  = mkDecls tcdSigs (SigD noExt) class_+    ats   = mkDecls tcdATs (TyClD noExt . FamDecl noExt) class_   -- | The top-level declarations of a module that we care about,@@ -518,26 +537,26 @@ -- | Extract a map of fixity declarations only mkFixMap :: HsGroup GhcRn -> FixMap mkFixMap group_ = M.fromList [ (n,f)-                             | L _ (FixitySig ns f) <- hs_fixds group_,+                             | L _ (FixitySig _ ns f) <- hs_fixds group_,                                L _ n <- ns ]   -- | Take all declarations except pragmas, infix decls, rules from an 'HsGroup'. ungroup :: HsGroup GhcRn -> [LHsDecl GhcRn] ungroup group_ =-  mkDecls (tyClGroupTyClDecls . hs_tyclds) TyClD  group_ ++-  mkDecls hs_derivds             DerivD group_ ++-  mkDecls hs_defds               DefD   group_ ++-  mkDecls hs_fords               ForD   group_ ++-  mkDecls hs_docs                DocD   group_ ++-  mkDecls (tyClGroupInstDecls . hs_tyclds) InstD  group_ ++-  mkDecls (typesigs . hs_valds)  SigD   group_ ++-  mkDecls (valbinds . hs_valds)  ValD   group_+  mkDecls (tyClGroupTyClDecls . hs_tyclds) (TyClD noExt)  group_ +++  mkDecls hs_derivds             (DerivD noExt) group_ +++  mkDecls hs_defds               (DefD noExt)   group_ +++  mkDecls hs_fords               (ForD noExt)   group_ +++  mkDecls hs_docs                (DocD noExt)   group_ +++  mkDecls (tyClGroupInstDecls . hs_tyclds) (InstD noExt)  group_ +++  mkDecls (typesigs . hs_valds)  (SigD noExt)   group_ +++  mkDecls (valbinds . hs_valds)  (ValD noExt)   group_   where-    typesigs (ValBindsOut _ sigs) = filter isUserLSig sigs+    typesigs (XValBindsLR (NValBinds _ sigs)) = filter isUserLSig sigs     typesigs _ = error "expected ValBindsOut" -    valbinds (ValBindsOut binds _) = concatMap bagToList . snd . unzip $ binds+    valbinds (XValBindsLR (NValBinds binds _)) = concatMap bagToList . snd . unzip $ binds     valbinds _ = error "expected ValBindsOut"  @@ -563,14 +582,14 @@ filterDecls :: [(LHsDecl a, doc)] -> [(LHsDecl a, doc)] filterDecls = filter (isHandled . unL . fst)   where-    isHandled (ForD (ForeignImport {})) = True+    isHandled (ForD _ (ForeignImport {})) = True     isHandled (TyClD {})  = True     isHandled (InstD {})  = True     isHandled (DerivD {}) = True-    isHandled (SigD d) = isUserLSig (reL d)-    isHandled (ValD _) = True+    isHandled (SigD _ d)  = isUserLSig (reL d)+    isHandled (ValD {})   = True     -- we keep doc declarations to be able to get at named docs-    isHandled (DocD _) = True+    isHandled (DocD {})   = True     isHandled _ = False  -- | Go through all class declarations and filter their sub-declarations@@ -578,8 +597,8 @@ filterClasses decls = [ if isClassD d then (L loc (filterClass d), doc) else x                       | x@(L loc d, doc) <- decls ]   where-    filterClass (TyClD c) =-      TyClD $ c { tcdSigs = filter (liftA2 (||) isUserLSig isMinimalLSig) $ tcdSigs c }+    filterClass (TyClD x c) =+      TyClD x $ c { tcdSigs = filter (liftA2 (||) isUserLSig isMinimalLSig) $ tcdSigs c }     filterClass _ = error "expected TyClD"  @@ -598,10 +617,10 @@   where     go Nothing _ [] = []     go (Just prev) docs [] = finished prev docs []-    go prev docs (L _ (DocD (DocCommentNext str)) : ds)+    go prev docs (L _ (DocD _ (DocCommentNext str)) : ds)       | Nothing <- prev = go Nothing (str:docs) ds       | Just decl <- prev = finished decl docs (go Nothing [str] ds)-    go prev docs (L _ (DocD (DocCommentPrev str)) : ds) = go prev (str:docs) ds+    go prev docs (L _ (DocD _ (DocCommentPrev str)) : ds) = go prev (str:docs) ds     go Nothing docs (d:ds) = go (Just d) docs ds     go (Just prev) docs (d:ds) = finished prev docs (go (Just d) [] ds) @@ -644,22 +663,22 @@         allExports     Just exports -> liftM concat $ mapM lookupExport exports   where-    lookupExport (IEGroup lev docStr, _)  = liftErrMsg $ do+    lookupExport (IEGroup _ lev docStr, _)  = liftErrMsg $ do       doc <- processDocString dflags gre docStr       return [ExportGroup lev "" doc] -    lookupExport (IEDoc docStr, _)        = liftErrMsg $ do+    lookupExport (IEDoc _ docStr, _)        = liftErrMsg $ do       doc <- processDocStringParas dflags pkgName gre docStr       return [ExportDoc doc] -    lookupExport (IEDocNamed str, _)      = liftErrMsg $+    lookupExport (IEDocNamed _ str, _)      = liftErrMsg $       findNamedDoc str [ unL d | d <- decls ] >>= \case         Nothing -> return  []         Just docStr -> do           doc <- processDocStringParas dflags pkgName gre docStr           return [ExportDoc doc] -    lookupExport (IEModuleContents (L _ mod_name), _)+    lookupExport (IEModuleContents _ (L _ mod_name), _)       -- only consider exporting a module if we are sure we       -- are really exporting the whole module and not some       -- subset. We also look through module aliases here.@@ -696,7 +715,7 @@       let t = availName avail       r    <- findDecl avail       case r of-        ([L l (ValD _)], (doc, _)) -> do+        ([L l (ValD _ _)], (doc, _)) -> do           -- Top-level binding without type signature           export <- hiValExportItem dflags t l doc (l `elem` splices) $ M.lookup t fixMap           return [export]@@ -721,17 +740,17 @@                   -- A single signature might refer to many names, but we                   -- create an export item for a single name only.  So we                   -- modify the signature to contain only that single name.-                  L loc (SigD sig) ->+                  L loc (SigD _ sig) ->                     -- fromJust is safe since we already checked in guards                     -- that 't' is a name declared in this declaration.-                    let newDecl = L loc . SigD . fromJust $ filterSigNames (== t) sig+                    let newDecl = L loc . SigD noExt . fromJust $ filterSigNames (== t) sig                     in availExportDecl avail newDecl docs_ -                  L loc (TyClD cl@ClassDecl{}) -> do+                  L loc (TyClD _ cl@ClassDecl{}) -> do                     mdef <- liftGhcToErrMsgGhc $ minimalDef t-                    let sig = maybeToList $ fmap (noLoc . MinimalSig NoSourceText . noLoc . fmap noLoc) mdef+                    let sig = maybeToList $ fmap (noLoc . MinimalSig noExt NoSourceText . noLoc . fmap noLoc) mdef                     availExportDecl avail-                      (L loc $ TyClD cl { tcdSigs = sig ++ tcdSigs cl }) docs_+                      (L loc $ TyClD noExt cl { tcdSigs = sig ++ tcdSigs cl }) docs_                    _ -> availExportDecl avail decl docs_ @@ -994,13 +1013,13 @@   let availEnv = availsToNameEnv (nubAvails avails)   (concat . concat) `fmap` (for decls $ \decl -> do     case decl of-      (L _ (DocD (DocGroup lev docStr))) -> do+      (L _ (DocD _ (DocGroup lev docStr))) -> do         doc <- liftErrMsg (processDocString dflags gre docStr)         return [[ExportGroup lev "" doc]]-      (L _ (DocD (DocCommentNamed _ docStr))) -> do+      (L _ (DocD _ (DocCommentNamed _ docStr))) -> do         doc <- liftErrMsg (processDocStringParas dflags pkgName gre docStr)         return [[ExportDoc doc]]-      (L _ (ValD valDecl))+      (L _ (ValD _ valDecl))         | name:_ <- collectHsBindBinders valDecl         , Just (L _ SigD{}:_) <- filter isSigD <$> M.lookup name declMap         -> return []@@ -1025,12 +1044,12 @@   | name `elem` getMainDeclBinder (unLoc decl) = decl   | otherwise  =     case unLoc decl of-      TyClD d@ClassDecl {} ->+      TyClD _ d@ClassDecl {} ->         let           matchesMethod =             [ lsig             | lsig <- tcdSigs d-            , ClassOpSig False _ _ <- pure $ unLoc lsig+            , ClassOpSig _ False _ _ <- pure $ unLoc lsig               -- Note: exclude `default` declarations (see #505)             , name `elem` sigName lsig             ]@@ -1045,8 +1064,8 @@         in case (matchesMethod, matchesAssociatedType)  of           ([s0], _) -> let (n, tyvar_names) = (tcdName d, tyClDeclTyVars d)                            L pos sig = addClassContext n tyvar_names s0-                       in L pos (SigD sig)-          (_, [L pos fam_decl]) -> L pos (TyClD (FamDecl fam_decl))+                       in L pos (SigD noExt sig)+          (_, [L pos fam_decl]) -> L pos (TyClD noExt (FamDecl noExt fam_decl))            ([], [])             | Just (famInstDecl:_) <- M.lookup name declMap@@ -1055,23 +1074,23 @@                                          O.$$ O.nest 4 (O.ppr d)                                          O.$$ O.text "Matches:"                                          O.$$ O.nest 4 (O.ppr matchesMethod O.<+> O.ppr matchesAssociatedType))-      TyClD d@DataDecl {} ->+      TyClD _ d@DataDecl {} ->         let (n, tyvar_tys) = (tcdName d, lHsQTyVarsToTypes (tyClDeclTyVars d))         in if isDataConName name-           then SigD <$> extractPatternSyn name n tyvar_tys (dd_cons (tcdDataDefn d))-           else SigD <$> extractRecSel name n tyvar_tys (dd_cons (tcdDataDefn d))-      TyClD FamDecl {}+           then SigD noExt <$> extractPatternSyn name n tyvar_tys (dd_cons (tcdDataDefn d))+           else SigD noExt <$> extractRecSel name n tyvar_tys (dd_cons (tcdDataDefn d))+      TyClD _ FamDecl {}         | isValName name         , Just (famInst:_) <- M.lookup name declMap         -> extractDecl declMap name famInst-      InstD (DataFamInstD (DataFamInstDecl (HsIB { hsib_body =+      InstD _ (DataFamInstD _ (DataFamInstDecl (HsIB { hsib_body =                              FamEqn { feqn_tycon = L _ n                                     , feqn_pats  = tys                                     , feqn_rhs   = defn }}))) ->         if isDataConName name-        then SigD <$> extractPatternSyn name n tys (dd_cons defn)-        else SigD <$> extractRecSel name n tys (dd_cons defn)-      InstD (ClsInstD ClsInstDecl { cid_datafam_insts = insts })+        then SigD noExt <$> extractPatternSyn name n tys (dd_cons defn)+        else SigD noExt <$> extractRecSel name n tys (dd_cons defn)+      InstD _ (ClsInstD _ ClsInstDecl { cid_datafam_insts = insts })         | isDataConName name ->             let matches = [ d' | L _ d'@(DataFamInstDecl (HsIB { hsib_body =                                           FamEqn { feqn_rhs   = dd@@ -1080,19 +1099,19 @@                                , name `elem` map unLoc (concatMap (getConNames . unLoc) (dd_cons dd))                                ]             in case matches of-                [d0] -> extractDecl declMap name (noLoc (InstD (DataFamInstD d0)))+                [d0] -> extractDecl declMap name (noLoc (InstD noExt (DataFamInstD noExt d0)))                 _    -> error "internal: extractDecl (ClsInstD)"         | otherwise ->             let matches = [ d' | L _ d'@(DataFamInstDecl (HsIB { hsib_body = d }))                                    <- insts                                  -- , L _ ConDecl { con_details = RecCon rec } <- dd_cons (feqn_rhs d)-                               , RecCon rec <- map (getConDetails . unLoc) (dd_cons (feqn_rhs d))+                               , RecCon rec <- map (getConArgs . unLoc) (dd_cons (feqn_rhs d))                                , ConDeclField { cd_fld_names = ns } <- map unLoc (unLoc rec)                                , L _ n <- ns-                               , selectorFieldOcc n == name+                               , extFieldOcc n == name                           ]             in case matches of-              [d0] -> extractDecl declMap name (noLoc . InstD $ DataFamInstD d0)+              [d0] -> extractDecl declMap name (noLoc . InstD noExt $ DataFamInstD noExt d0)               _ -> error "internal: extractDecl (ClsInstD)"       _ -> error "internal: extractDecl" @@ -1108,42 +1127,42 @@   extract :: ConDecl GhcRn -> Sig GhcRn   extract con =     let args =-          case getConDetails con of+          case getConArgs con of             PrefixCon args' -> args'             RecCon (L _ fields) -> cd_fld_type . unLoc <$> fields             InfixCon arg1 arg2 -> [arg1, arg2]         typ = longArrow args (data_ty con)         typ' =           case con of-            ConDeclH98 { con_cxt = Just cxt } -> noLoc (HsQualTy cxt typ)+            ConDeclH98 { con_mb_cxt = Just cxt } -> noLoc (HsQualTy noExt cxt typ)             _ -> typ-        typ'' = noLoc (HsQualTy (noLoc []) typ')-    in PatSynSig [noLoc nm] (mkEmptyImplicitBndrs typ'')+        typ'' = noLoc (HsQualTy noExt (noLoc []) typ')+    in PatSynSig noExt [noLoc nm] (mkEmptyImplicitBndrs typ'') -  longArrow :: [LHsType name] -> LHsType name -> LHsType name-  longArrow inputs output = foldr (\x y -> noLoc (HsFunTy x y)) output inputs+  longArrow :: [LHsType GhcRn] -> LHsType GhcRn -> LHsType GhcRn+  longArrow inputs output = foldr (\x y -> noLoc (HsFunTy noExt x y)) output inputs    data_ty con-    | ConDeclGADT{} <- con = hsib_body $ con_type con-    | otherwise = foldl' (\x y -> noLoc (HsAppTy x y)) (noLoc (HsTyVar NotPromoted (noLoc t))) tvs+    | ConDeclGADT{} <- con = con_res_ty con+    | otherwise = foldl' (\x y -> noLoc (HsAppTy noExt x y)) (noLoc (HsTyVar noExt NotPromoted (noLoc t))) tvs  extractRecSel :: Name -> Name -> [LHsType GhcRn] -> [LConDecl GhcRn]               -> LSig GhcRn extractRecSel _ _ _ [] = error "extractRecSel: selector not found"  extractRecSel nm t tvs (L _ con : rest) =-  case getConDetails con of-    RecCon (L _ fields) | ((l,L _ (ConDeclField _nn ty _)) : _) <- matching_fields fields ->-      L l (TypeSig [noLoc nm] (mkEmptySigWcType (noLoc (HsFunTy data_ty (getBangType ty)))))+  case getConArgs con of+    RecCon (L _ fields) | ((l,L _ (ConDeclField _ _nn ty _)) : _) <- matching_fields fields ->+      L l (TypeSig noExt [noLoc nm] (mkEmptySigWcType (noLoc (HsFunTy noExt data_ty (getBangType ty)))))     _ -> extractRecSel nm t tvs rest  where   matching_fields :: [LConDeclField GhcRn] -> [(SrcSpan, LConDeclField GhcRn)]-  matching_fields flds = [ (l,f) | f@(L _ (ConDeclField ns _ _)) <- flds-                                 , L l n <- ns, selectorFieldOcc n == nm ]+  matching_fields flds = [ (l,f) | f@(L _ (ConDeclField _ ns _ _)) <- flds+                                 , L l n <- ns, extFieldOcc n == nm ]   data_ty     -- ResTyGADT _ ty <- con_res con = ty-    | ConDeclGADT{} <- con = hsib_body $ con_type con-    | otherwise = foldl' (\x y -> noLoc (HsAppTy x y)) (noLoc (HsTyVar NotPromoted (noLoc t))) tvs+    | ConDeclGADT{} <- con = con_res_ty con+    | otherwise = foldl' (\x y -> noLoc (HsAppTy noExt x y)) (noLoc (HsTyVar noExt NotPromoted (noLoc t))) tvs  -- | Keep export items with docs. pruneExportItems :: [ExportItem GhcRn] -> [ExportItem GhcRn]@@ -1163,8 +1182,8 @@       where subs    = map fst (expItemSubDocs e)             patsyns = concatMap (getMainDeclBinder . fst) (expItemPats e)             name = case unLoc $ expItemDecl e of-              InstD d -> maybeToList $ M.lookup (getInstLoc d) instMap-              decl    -> getMainDeclBinder decl+              InstD _ d -> maybeToList $ M.lookup (getInstLoc d) instMap+              decl      -> getMainDeclBinder decl     exportName ExportNoDecl {} = [] -- we don't count these as visible, since                                     -- we don't want links to go to them.     exportName _ = []@@ -1208,7 +1227,7 @@     search [] = do       tell ["Cannot find documentation for: $" ++ name]       return Nothing-    search (DocD (DocCommentNamed name' doc) : rest)+    search (DocD _ (DocCommentNamed name' doc) : rest)       | name == name' = return (Just doc)       | otherwise = search rest     search (_other_decl : rest) = search rest
src/Haddock/Interface/LexParseRn.hs view
@@ -1,5 +1,6 @@ {-# OPTIONS_GHC -Wwarn #-} {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE ViewPatterns #-}   ----------------------------------------------------------------------------- -- | -- Module      :  Haddock.Interface.LexParseRn@@ -18,17 +19,20 @@   , processModuleHeader   ) where +import Avail+import Control.Arrow+import Control.Monad import Data.List+import Data.Ord import Documentation.Haddock.Doc (metaDocConcat) import DynFlags (languageExtensions) import qualified GHC.LanguageExtensions as LangExt-import FastString import GHC import Haddock.Interface.ParseModuleHeader import Haddock.Parser import Haddock.Types import Name-import Outputable ( showPpr )+import Outputable ( showPpr, showSDoc ) import RdrName import EnumSet import RnEnv (dataTcOccs)@@ -44,14 +48,13 @@     MetaDoc { _meta = Meta Nothing Nothing, _doc = DocEmpty } -> pure Nothing     x -> pure (Just x) -processDocStringParas :: DynFlags -> Maybe Package -> GlobalRdrEnv -> HsDocString-                      -> ErrMsgM (MDoc Name)-processDocStringParas dflags pkg gre (HsDocString fs) =-  overDocF (rename dflags gre) $ parseParas dflags pkg (unpackFS fs)+processDocStringParas :: DynFlags -> Maybe Package -> GlobalRdrEnv -> HsDocString -> ErrMsgM (MDoc Name)+processDocStringParas dflags pkg gre hds =+  overDocF (rename dflags gre) $ parseParas dflags pkg (unpackHDS hds)  processDocString :: DynFlags -> GlobalRdrEnv -> HsDocString -> ErrMsgM (Doc Name)-processDocString dflags gre (HsDocString fs) =-  rename dflags gre $ parseString dflags (unpackFS fs)+processDocString dflags gre hds =+  rename dflags gre $ parseString dflags (unpackHDS hds)  processModuleHeader :: DynFlags -> Maybe Package -> GlobalRdrEnv -> SafeHaskellMode -> Maybe LHsDocString                     -> ErrMsgM (HaddockModInfo Name, Maybe (MDoc Name))@@ -59,8 +62,8 @@   (hmi, doc) <-     case mayStr of       Nothing -> return failure-      Just (L _ (HsDocString fs)) -> do-        let str = unpackFS fs+      Just (L _ hds) -> do+        let str = unpackHDS hds             (hmi, doc) = parseModuleHeader dflags pkgName str         !descr <- case hmi_description hmi of                     Just hmi_descr -> Just <$> rename dflags gre hmi_descr@@ -96,15 +99,15 @@         -- Generate the choices for the possible kind of thing this         -- is.         let choices = dataTcOccs x-        -- Try to look up all the names in the GlobalRdrEnv that match-        -- the names.-        let names = concatMap (\c -> map gre_name (lookupGRE_RdrName c gre)) choices -        case names of+        -- Lookup any GlobalRdrElts that match the choices.+        case concatMap (\c -> lookupGRE_RdrName c gre) choices of           -- We found no names in the env so we start guessing.           [] ->             case choices of+              -- This shouldn't happen as 'dataTcOccs' always returns at least its input.               [] -> pure (DocMonospaced (DocString (showPpr dflags x)))+               -- There was nothing in the environment so we need to               -- pick some default from what's available to us. We               -- diverge here from the old way where we would default@@ -113,17 +116,15 @@               -- type constructor names (such as in #253). So now we               -- only get type constructor links if they are actually               -- in scope.-              a:_ -> pure (outOfScope dflags a)+              a:_ -> outOfScope dflags a            -- There is only one name in the environment that matches so           -- use it.-          [a] -> pure (DocIdentifier a)-          -- But when there are multiple names available, default to-          -- type constructors: somewhat awfully GHC returns the-          -- values in the list positionally.-          a:b:_ | isTyConName a -> pure (DocIdentifier a)-                | otherwise -> pure (DocIdentifier b)+          [a] -> pure (DocIdentifier (gre_name a)) +          -- There are multiple names available.+          gres -> ambiguous dflags x gres+       DocWarning doc -> DocWarning <$> rn doc       DocEmphasis doc -> DocEmphasis <$> rn doc       DocBold doc -> DocBold <$> rn doc@@ -154,12 +155,47 @@ -- 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 :: DynFlags -> RdrName -> Doc a+outOfScope :: DynFlags -> RdrName -> ErrMsgM (Doc a) outOfScope dflags x =   case x of-    Unqual occ -> monospaced occ-    Qual mdl occ -> DocIdentifierUnchecked (mdl, occ)-    Orig _ occ -> monospaced occ-    Exact name -> monospaced name  -- Shouldn't happen since x is out of scope+    Unqual occ -> warnAndMonospace occ+    Qual mdl occ -> pure (DocIdentifierUnchecked (mdl, occ))+    Orig _ occ -> warnAndMonospace occ+    Exact name -> warnAndMonospace name  -- Shouldn't happen since x is out of scope   where+    warnAndMonospace a = do+      tell ["Warning: '" ++ showPpr dflags a ++ "' is out of scope.\n" +++            "    If you qualify the identifier, haddock can try to link it\n" +++            "    it anyway."]+      pure (monospaced a)     monospaced a = DocMonospaced (DocString (showPpr dflags a))++-- | 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 :: DynFlags+          -> RdrName+          -> [GlobalRdrElt] -- ^ More than one @gre@s sharing the same `RdrName` above.+          -> ErrMsgM (Doc Name)+ambiguous dflags x gres = do+  let noChildren = map availName (gresToAvailInfo gres)+      dflt = maximumBy (comparing (isLocalName &&& isTyConName)) noChildren+      msg = "Warning: " ++ x_str ++ " is ambiguous. It is defined\n" +++            concatMap (\n -> "    * " ++ defnLoc n ++ "\n") (map gre_name gres) +++            "    You may be able to disambiguate the identifier by qualifying it or\n" +++            "    by hiding some imports.\n" +++            "    Defaulting to " ++ x_str ++ " 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.+  when (length noChildren > 1) $ tell [msg]+  pure (DocIdentifier dflt)+  where+    isLocalName (nameSrcLoc -> RealSrcLoc {}) = True+    isLocalName _ = False+    x_str = '\'' : showPpr dflags x ++ "'"+    defnLoc = showSDoc dflags . pprNameDefnLoc
src/Haddock/Interface/Rename.hs view
@@ -21,6 +21,7 @@ import Bag (emptyBag) import GHC hiding (NoLink) import Name+import Outputable ( panic ) import RdrName (RdrName(Exact)) import PrelNames (eqTyCon_RDR) @@ -197,14 +198,15 @@ renameMaybeLKind = traverse renameLKind  renameFamilyResultSig :: LFamilyResultSig GhcRn -> RnM (LFamilyResultSig DocNameI)-renameFamilyResultSig (L loc NoSig)-    = return (L loc NoSig)-renameFamilyResultSig (L loc (KindSig ki))+renameFamilyResultSig (L loc (NoSig _))+    = return (L loc (NoSig noExt))+renameFamilyResultSig (L loc (KindSig _ ki))     = do { ki' <- renameLKind ki-         ; return (L loc (KindSig ki')) }-renameFamilyResultSig (L loc (TyVarSig bndr))+         ; return (L loc (KindSig noExt ki')) }+renameFamilyResultSig (L loc (TyVarSig _ bndr))     = do { bndr' <- renameLTyVarBndr bndr-         ; return (L loc (TyVarSig bndr')) }+         ; return (L loc (TyVarSig noExt bndr')) }+renameFamilyResultSig (L _ (XFamilyResultSig _)) = panic "haddock:renameFamilyResultSig"  renameInjectivityAnn :: LInjectivityAnn GhcRn -> RnM (LInjectivityAnn DocNameI) renameInjectivityAnn (L loc (InjectivityAnn lhs rhs))@@ -221,61 +223,60 @@   HsForAllTy { hst_bndrs = tyvars, hst_body = ltype } -> do     tyvars'   <- mapM renameLTyVarBndr tyvars     ltype'    <- renameLType ltype-    return (HsForAllTy { hst_bndrs = tyvars', hst_body = ltype' })+    return (HsForAllTy { hst_xforall = NoExt, hst_bndrs = tyvars', hst_body = ltype' })    HsQualTy { hst_ctxt = lcontext , hst_body = ltype } -> do     lcontext' <- renameLContext lcontext     ltype'    <- renameLType ltype-    return (HsQualTy { hst_ctxt = lcontext', hst_body = ltype' })+    return (HsQualTy { hst_xqual = NoExt, hst_ctxt = lcontext', hst_body = ltype' }) -  HsTyVar ip (L l n) -> return . HsTyVar ip . L l =<< rename n-  HsBangTy b ltype -> return . HsBangTy b =<< renameLType ltype+  HsTyVar _ ip (L l n) -> return . HsTyVar NoExt ip . L l =<< rename n+  HsBangTy _ b ltype -> return . HsBangTy NoExt b =<< renameLType ltype -  HsAppTy a b -> do+  HsStarTy _ isUni -> return (HsStarTy NoExt isUni)++  HsAppTy _ a b -> do     a' <- renameLType a     b' <- renameLType b-    return (HsAppTy a' b')+    return (HsAppTy NoExt a' b') -  HsFunTy a b -> do+  HsFunTy _ a b -> do     a' <- renameLType a     b' <- renameLType b-    return (HsFunTy a' b')+    return (HsFunTy NoExt a' b') -  HsListTy ty -> return . HsListTy =<< renameLType ty-  HsPArrTy ty -> return . HsPArrTy =<< renameLType ty-  HsIParamTy n ty -> liftM (HsIParamTy n) (renameLType ty)-  HsEqTy ty1 ty2 -> liftM2 HsEqTy (renameLType ty1) (renameLType ty2)+  HsListTy _ ty -> return . (HsListTy NoExt) =<< renameLType ty+  HsIParamTy _ n ty -> liftM (HsIParamTy NoExt n) (renameLType ty) -  HsTupleTy b ts -> return . HsTupleTy b =<< mapM renameLType ts-  HsSumTy ts -> HsSumTy <$> mapM renameLType ts+  HsTupleTy _ b ts -> return . HsTupleTy NoExt b =<< mapM renameLType ts+  HsSumTy _ ts -> HsSumTy NoExt <$> mapM renameLType ts -  HsOpTy a (L loc op) b -> do+  HsOpTy _ a (L loc op) b -> do     op' <- rename op     a'  <- renameLType a     b'  <- renameLType b-    return (HsOpTy a' (L loc op') b')+    return (HsOpTy NoExt a' (L loc op') b') -  HsParTy ty -> return . HsParTy =<< renameLType ty+  HsParTy _ ty -> return . (HsParTy NoExt) =<< renameLType ty -  HsKindSig ty k -> do+  HsKindSig _ ty k -> do     ty' <- renameLType ty     k' <- renameLKind k-    return (HsKindSig ty' k')+    return (HsKindSig NoExt ty' k') -  HsDocTy ty doc -> do+  HsDocTy _ ty doc -> do     ty' <- renameLType ty     doc' <- renameLDocHsSyn doc-    return (HsDocTy ty' doc')+    return (HsDocTy NoExt ty' doc') -  HsTyLit x -> return (HsTyLit x)+  HsTyLit _ x -> return (HsTyLit NoExt x) -  HsRecTy a               -> HsRecTy <$> mapM renameConDeclFieldField a-  HsCoreTy a              -> pure (HsCoreTy a)+  HsRecTy _ a               -> HsRecTy NoExt <$> mapM renameConDeclFieldField a+  (XHsType (NHsCoreTy a))   -> pure (XHsType (NHsCoreTy a))   HsExplicitListTy i a b  -> HsExplicitListTy i a <$> mapM renameLType b   HsExplicitTupleTy a b   -> HsExplicitTupleTy a <$> mapM renameLType b-  HsSpliceTy s _          -> renameHsSpliceTy s+  HsSpliceTy _ s          -> renameHsSpliceTy s   HsWildCardTy a          -> HsWildCardTy <$> renameWildCardInfo a-  HsAppsTy _              -> error "renameType: HsAppsTy"  -- | Rename splices, but _only_ those that turn out to be for types. -- I think this is actually safe for our possible inputs:@@ -284,32 +285,34 @@ --  * the input is typechecked, and only 'HsSplicedTy' should get through that -- renameHsSpliceTy :: HsSplice GhcRn -> RnM (HsType DocNameI)-renameHsSpliceTy (HsSpliced _ (HsSplicedTy t)) = renameType t-renameHsSpliceTy (HsSpliced _ _) = error "renameHsSpliceTy: not an HsSplicedTy"+renameHsSpliceTy (HsSpliced _ _ (HsSplicedTy t)) = renameType t+renameHsSpliceTy (HsSpliced _ _ _) = error "renameHsSpliceTy: not an HsSplicedTy" renameHsSpliceTy _ = error "renameHsSpliceTy: not an HsSpliced"  renameLHsQTyVars :: LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)-renameLHsQTyVars (HsQTvs { hsq_implicit = _, hsq_explicit = tvs })+renameLHsQTyVars (HsQTvs { hsq_explicit = tvs })   = do { tvs' <- mapM renameLTyVarBndr tvs-       ; return (HsQTvs { hsq_implicit = error "haddock:renameLHsQTyVars", hsq_explicit = tvs', hsq_dependent = error "haddock:renameLHsQTyVars" }) }-                -- This is rather bogus, but I'm not sure what else to do+       ; return (HsQTvs { hsq_ext = noExt+                        , hsq_explicit = tvs' }) }+renameLHsQTyVars (XLHsQTyVars _) = panic "haddock:renameLHsQTyVars"  renameLTyVarBndr :: LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI)-renameLTyVarBndr (L loc (UserTyVar (L l n)))+renameLTyVarBndr (L loc (UserTyVar x (L l n)))   = do { n' <- rename n-       ; return (L loc (UserTyVar (L l n'))) }-renameLTyVarBndr (L loc (KindedTyVar (L lv n) kind))+       ; return (L loc (UserTyVar x (L l n'))) }+renameLTyVarBndr (L loc (KindedTyVar x (L lv n) kind))   = do { n' <- rename n        ; kind' <- renameLKind kind-       ; return (L loc (KindedTyVar (L lv n') kind')) }+       ; return (L loc (KindedTyVar x (L lv n') kind')) }+renameLTyVarBndr (L _ (XTyVarBndr _ )) = error "haddock:renameLTyVarBndr"  renameLContext :: Located [LHsType GhcRn] -> RnM (Located [LHsType DocNameI]) renameLContext (L loc context) = do   context' <- mapM renameLType context   return (L loc context') -renameWildCardInfo :: HsWildCardInfo GhcRn -> RnM (HsWildCardInfo DocNameI)-renameWildCardInfo (AnonWildCard  (L l name)) = AnonWildCard . L l <$> rename name+renameWildCardInfo :: HsWildCardInfo -> RnM HsWildCardInfo+renameWildCardInfo (AnonWildCard  (L l name)) = return (AnonWildCard (L l name))  renameInstHead :: InstHead GhcRn -> RnM (InstHead DocNameI) renameInstHead InstHead {..} = do@@ -340,21 +343,21 @@  renameDecl :: HsDecl GhcRn -> RnM (HsDecl DocNameI) renameDecl decl = case decl of-  TyClD d -> do+  TyClD _ d -> do     d' <- renameTyClD d-    return (TyClD d')-  SigD s -> do+    return (TyClD noExt d')+  SigD _ s -> do     s' <- renameSig s-    return (SigD s')-  ForD d -> do+    return (SigD noExt s')+  ForD _ d -> do     d' <- renameForD d-    return (ForD d')-  InstD d -> do+    return (ForD noExt d')+  InstD _ d -> do     d' <- renameInstD d-    return (InstD d')-  DerivD d -> do+    return (InstD noExt d')+  DerivD _ d -> do     d' <- renameDerivD d-    return (DerivD d')+    return (DerivD noExt d')   _ -> error "renameDecl"  renameLThing :: (a GhcRn -> RnM (a DocNameI)) -> Located (a GhcRn) -> RnM (Located (a DocNameI))@@ -365,19 +368,21 @@ --  TyFamily flav lname ltyvars kind tckind -> do   FamDecl { tcdFam = decl } -> do     decl' <- renameFamilyDecl decl-    return (FamDecl { tcdFam = decl' })+    return (FamDecl { tcdFExt = noExt, tcdFam = decl' }) -  SynDecl { tcdLName = lname, tcdTyVars = tyvars, tcdFixity = fixity, tcdRhs = rhs, tcdFVs = _fvs } -> do+  SynDecl { tcdLName = lname, tcdTyVars = tyvars, tcdFixity = fixity, tcdRhs = rhs } -> do     lname'    <- renameL lname     tyvars'   <- renameLHsQTyVars tyvars     rhs'     <- renameLType rhs-    return (SynDecl { tcdLName = lname', tcdTyVars = tyvars', tcdFixity = fixity, tcdRhs = rhs', tcdFVs = placeHolderNames })+    return (SynDecl { tcdSExt = noExt, tcdLName = lname', tcdTyVars = tyvars'+                    , tcdFixity = fixity, tcdRhs = rhs' }) -  DataDecl { tcdLName = lname, tcdTyVars = tyvars, tcdFixity = fixity, tcdDataDefn = defn, tcdFVs = _fvs } -> do+  DataDecl { tcdLName = lname, tcdTyVars = tyvars, tcdFixity = fixity, tcdDataDefn = defn } -> do     lname'    <- renameL lname     tyvars'   <- renameLHsQTyVars tyvars     defn'     <- renameDataDefn defn-    return (DataDecl { tcdLName = lname', tcdTyVars = tyvars', tcdFixity = fixity, tcdDataDefn = defn', tcdDataCusk = PlaceHolder, tcdFVs = placeHolderNames })+    return (DataDecl { tcdDExt = noExt, 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@@ -392,7 +397,8 @@     return (ClassDecl { tcdCtxt = lcontext', tcdLName = lname', tcdTyVars = ltyvars'                       , tcdFixity = fixity                       , tcdFDs = lfundeps', tcdSigs = lsigs', tcdMeths= emptyBag-                      , tcdATs = ats', tcdATDefs = at_defs', tcdDocs = [], tcdFVs = placeHolderNames })+                      , tcdATs = ats', tcdATDefs = at_defs', tcdDocs = [], tcdCExt = NoExt })+  XTyClDecl _ -> panic "haddock:renameTyClD"    where     renameLFunDep (L loc (xs, ys)) = do@@ -413,11 +419,12 @@     ltyvars'     <- renameLHsQTyVars ltyvars     result'      <- renameFamilyResultSig result     injectivity' <- renameMaybeInjectivityAnn injectivity-    return (FamilyDecl { fdInfo = info', fdLName = lname'+    return (FamilyDecl { fdExt = noExt, fdInfo = info', fdLName = lname'                        , fdTyVars = ltyvars'                        , fdFixity = fixity                        , fdResultSig = result'                        , fdInjectivityAnn = injectivity' })+renameFamilyDecl (XFamilyDecl _) = panic "renameFamilyDecl"   renamePseudoFamilyDecl :: PseudoFamilyDecl GhcRn@@ -443,108 +450,130 @@     k'        <- renameMaybeLKind k     cons'     <- mapM (mapM renameCon) cons     -- I don't think we need the derivings, so we return Nothing-    return (HsDataDefn { dd_ND = nd, dd_ctxt = lcontext', dd_cType = cType+    return (HsDataDefn { dd_ext = noExt+                       , dd_ND = nd, dd_ctxt = lcontext', dd_cType = cType                        , dd_kindSig = k', dd_cons = cons'                        , dd_derivs = noLoc [] })+renameDataDefn (XHsDataDefn _) = panic "haddock:renameDataDefn"  renameCon :: ConDecl GhcRn -> RnM (ConDecl DocNameI)-renameCon decl@(ConDeclH98 { con_name = lname, con_qvars = ltyvars-                           , con_cxt = lcontext, con_details = details+renameCon decl@(ConDeclH98 { con_name = lname, con_ex_tvs = ltyvars+                           , con_mb_cxt = lcontext, con_args = details                            , con_doc = mbldoc }) = do       lname'    <- renameL lname-      ltyvars'  <- traverse renameLHsQTyVars ltyvars+      ltyvars'  <- mapM renameLTyVarBndr ltyvars       lcontext' <- traverse renameLContext lcontext       details'  <- renameDetails details       mbldoc'   <- mapM renameLDocHsSyn mbldoc-      return (decl { con_name = lname', con_qvars = ltyvars', con_cxt = lcontext'-                   , con_details = details', con_doc = mbldoc' })--  where-    renameDetails (RecCon (L l fields)) = do-      fields' <- mapM renameConDeclFieldField fields-      return (RecCon (L l fields'))-    renameDetails (PrefixCon ps) = return . PrefixCon =<< mapM renameLType ps-    renameDetails (InfixCon a b) = do-      a' <- renameLType a-      b' <- renameLType b-      return (InfixCon a' b')+      return (decl { con_ext = noExt, con_name = lname', con_ex_tvs = ltyvars'+                   , con_mb_cxt = lcontext'+                   , con_args = details', con_doc = mbldoc' }) -renameCon decl@(ConDeclGADT { con_names = lnames-                            , con_type = lty+renameCon decl@(ConDeclGADT { con_names = lnames, con_qvars = ltyvars+                            , con_mb_cxt = lcontext, con_args = details+                            , con_res_ty = res_ty                             , con_doc = mbldoc }) = do       lnames'   <- mapM renameL lnames-      lty'      <- renameLSigType lty+      ltyvars'  <- renameLHsQTyVars ltyvars+      lcontext' <- traverse renameLContext lcontext+      details'  <- renameDetails details+      res_ty'   <- renameLType res_ty       mbldoc'   <- mapM renameLDocHsSyn mbldoc-      return (decl { con_names = lnames'-                   , con_type = lty', con_doc = mbldoc' })+      return (decl { con_g_ext = noExt, con_names = lnames', con_qvars = ltyvars'+                   , con_mb_cxt = lcontext', con_args = details'+                   , con_res_ty = res_ty', con_doc = mbldoc' })+renameCon (XConDecl _) = panic "haddock:renameCon" +renameDetails :: HsConDeclDetails GhcRn -> RnM (HsConDeclDetails DocNameI)+renameDetails (RecCon (L l fields)) = do+  fields' <- mapM renameConDeclFieldField fields+  return (RecCon (L l fields'))+renameDetails (PrefixCon ps) = return . PrefixCon =<< mapM renameLType ps+renameDetails (InfixCon a b) = do+  a' <- renameLType a+  b' <- renameLType b+  return (InfixCon a' b')+ renameConDeclFieldField :: LConDeclField GhcRn -> RnM (LConDeclField DocNameI)-renameConDeclFieldField (L l (ConDeclField names t doc)) = do+renameConDeclFieldField (L l (ConDeclField _ names t doc)) = do   names' <- mapM renameLFieldOcc names   t'   <- renameLType t   doc' <- mapM renameLDocHsSyn doc-  return $ L l (ConDeclField names' t' doc')+  return $ L l (ConDeclField noExt names' t' doc')+renameConDeclFieldField (L _ (XConDeclField _)) = panic "haddock:renameConDeclFieldField"  renameLFieldOcc :: LFieldOcc GhcRn -> RnM (LFieldOcc DocNameI)-renameLFieldOcc (L l (FieldOcc lbl sel)) = do+renameLFieldOcc (L l (FieldOcc sel lbl)) = do   sel' <- rename sel-  return $ L l (FieldOcc lbl sel')+  return $ L l (FieldOcc sel' lbl)+renameLFieldOcc (L _ (XFieldOcc _)) = error "haddock:renameLFieldOcc"  renameSig :: Sig GhcRn -> RnM (Sig DocNameI) renameSig sig = case sig of-  TypeSig lnames ltype -> do+  TypeSig _ lnames ltype -> do     lnames' <- mapM renameL lnames     ltype' <- renameLSigWcType ltype-    return (TypeSig lnames' ltype')-  ClassOpSig is_default lnames sig_ty -> do+    return (TypeSig noExt lnames' ltype')+  ClassOpSig _ is_default lnames sig_ty -> do     lnames' <- mapM renameL lnames     ltype' <- renameLSigType sig_ty-    return (ClassOpSig is_default lnames' ltype')-  PatSynSig lnames sig_ty -> do+    return (ClassOpSig noExt is_default lnames' ltype')+  PatSynSig _ lnames sig_ty -> do     lnames' <- mapM renameL lnames     sig_ty' <- renameLSigType sig_ty-    return $ PatSynSig lnames' sig_ty'-  FixSig (FixitySig lnames fixity) -> do+    return $ PatSynSig noExt lnames' sig_ty'+  FixSig _ (FixitySig _ lnames fixity) -> do     lnames' <- mapM renameL lnames-    return $ FixSig (FixitySig lnames' fixity)-  MinimalSig src (L l s) -> do+    return $ FixSig noExt (FixitySig noExt lnames' fixity)+  MinimalSig _ src (L l s) -> do     s' <- traverse renameL s-    return $ MinimalSig src (L l s')+    return $ MinimalSig noExt src (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 co x) = do+renameForD (ForeignImport _ lname ltype x) = do   lname' <- renameL lname   ltype' <- renameLSigType ltype-  return (ForeignImport lname' ltype' co x)-renameForD (ForeignExport lname ltype co x) = do+  return (ForeignImport noExt lname' ltype' x)+renameForD (ForeignExport _ lname ltype x) = do   lname' <- renameL lname   ltype' <- renameLSigType ltype-  return (ForeignExport lname' ltype' co x)+  return (ForeignExport noExt lname' ltype' x)+renameForD (XForeignDecl _) = panic "haddock:renameForD"   renameInstD :: InstDecl GhcRn -> RnM (InstDecl DocNameI) renameInstD (ClsInstD { cid_inst = d }) = do   d' <- renameClsInstD d-  return (ClsInstD { cid_inst = d' })+  return (ClsInstD { cid_d_ext = noExt, cid_inst = d' }) renameInstD (TyFamInstD { tfid_inst = d }) = do   d' <- renameTyFamInstD d-  return (TyFamInstD { tfid_inst = d' })+  return (TyFamInstD { tfid_ext = noExt, tfid_inst = d' }) renameInstD (DataFamInstD { dfid_inst = d }) = do   d' <- renameDataFamInstD d-  return (DataFamInstD { dfid_inst = d' })+  return (DataFamInstD { dfid_ext = noExt, dfid_inst = d' })+renameInstD (XInstDecl _) = panic "haddock:renameInstD"  renameDerivD :: DerivDecl GhcRn -> RnM (DerivDecl DocNameI) renameDerivD (DerivDecl { deriv_type = ty                         , deriv_strategy = strat                         , deriv_overlap_mode = omode }) = do-  ty' <- renameLSigType ty-  return (DerivDecl { deriv_type = ty'-                    , deriv_strategy = strat+  ty'    <- renameLSigWcType ty+  strat' <- mapM (mapM renameDerivStrategy) strat+  return (DerivDecl { deriv_ext = noExt+                    , deriv_type = ty'+                    , deriv_strategy = strat'                     , deriv_overlap_mode = omode })+renameDerivD (XDerivDecl _) = panic "haddock:renameDerivD" +renameDerivStrategy :: DerivStrategy GhcRn -> RnM (DerivStrategy DocNameI)+renameDerivStrategy StockStrategy    = pure StockStrategy+renameDerivStrategy AnyclassStrategy = pure AnyclassStrategy+renameDerivStrategy NewtypeStrategy  = pure NewtypeStrategy+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@@ -552,10 +581,11 @@   ltype' <- renameLSigType ltype   lATs'  <- mapM (mapM renameTyFamInstD) lATs   lADTs' <- mapM (mapM renameDataFamInstD) lADTs-  return (ClsInstDecl { cid_overlap_mode = omode+  return (ClsInstDecl { cid_ext = noExt, cid_overlap_mode = omode                       , cid_poly_ty = ltype', cid_binds = emptyBag                       , cid_sigs = []                       , cid_tyfam_insts = lATs', cid_datafam_insts = lADTs' })+renameClsInstD (XClsInstDecl _) = panic "haddock:renameClsInstD"   renameTyFamInstD :: TyFamInstDecl GhcRn -> RnM (TyFamInstDecl DocNameI)@@ -575,10 +605,12 @@       = do { tc' <- renameL tc            ; pats' <- mapM renameLType pats            ; rhs' <- renameLType rhs-           ; return (FamEqn { feqn_tycon  = tc'+           ; return (FamEqn { feqn_ext    = noExt+                            , feqn_tycon  = tc'                             , feqn_pats   = pats'                             , feqn_fixity = fixity                             , feqn_rhs    = rhs' }) }+    rename_ty_fam_eqn (XFamEqn _) = panic "haddock:renameTyFamInstEqn"  renameLTyFamDefltEqn :: LTyFamDefltEqn GhcRn -> RnM (LTyFamDefltEqn DocNameI) renameLTyFamDefltEqn (L loc (FamEqn { feqn_tycon = tc, feqn_pats = tvs@@ -586,10 +618,12 @@   = do { tc'  <- renameL tc        ; tvs' <- renameLHsQTyVars tvs        ; rhs' <- renameLType rhs-       ; return (L loc (FamEqn { feqn_tycon  = tc'+       ; return (L loc (FamEqn { feqn_ext    = noExt+                               , feqn_tycon  = tc'                                , feqn_pats   = tvs'                                , feqn_fixity = fixity                                , feqn_rhs    = rhs' })) }+renameLTyFamDefltEqn (L _ (XFamEqn _)) = panic "haddock:renameLTyFamDefltEqn"  renameDataFamInstD :: DataFamInstDecl GhcRn -> RnM (DataFamInstDecl DocNameI) renameDataFamInstD (DataFamInstDecl { dfid_eqn = eqn })@@ -604,10 +638,12 @@       = do { tc' <- renameL tc            ; pats' <- mapM renameLType pats            ; defn' <- renameDataDefn defn-           ; return (FamEqn { feqn_tycon  = tc'+           ; return (FamEqn { feqn_ext    = noExt+                            , feqn_tycon  = tc'                             , feqn_pats   = pats'                             , feqn_fixity = fixity                             , feqn_rhs    = defn' }) }+    rename_data_fam_eqn (XFamEqn _) = panic "haddock:renameDataFamInstD"  renameImplicit :: (in_thing -> RnM out_thing)                -> HsImplicitBndrs GhcRn in_thing@@ -615,8 +651,8 @@ renameImplicit rn_thing (HsIB { hsib_body = thing })   = do { thing' <- rn_thing thing        ; return (HsIB { hsib_body = thing'-                      , hsib_vars = PlaceHolder-                      , hsib_closed = PlaceHolder }) }+                      , hsib_ext = noExt }) }+renameImplicit _ (XHsImplicitBndrs _) = panic "haddock:renameImplicit"  renameWc :: (in_thing -> RnM out_thing)          -> HsWildCardBndrs GhcRn in_thing@@ -624,7 +660,8 @@ renameWc rn_thing (HsWC { hswc_body = thing })   = do { thing' <- rn_thing thing        ; return (HsWC { hswc_body = thing'-                      , hswc_wcs = PlaceHolder }) }+                      , hswc_ext = noExt }) }+renameWc _ (XHsWildCardBndrs _) = panic "haddock:renameWc"  renameDocInstance :: DocInstance GhcRn -> RnM (DocInstance DocNameI) renameDocInstance (inst, idoc, L l n, m) = do
src/Haddock/Interface/Specialize.hs view
@@ -28,20 +28,18 @@ import qualified Data.Set as Set  -- | Instantiate all occurrences of given names with corresponding types.-specialize :: forall name a. (Ord (IdP name), DataId name, NamedThing (IdP name))-            => Data a-            => [(IdP name, HsType name)] -> a -> a+specialize :: Data a => [(Name, HsType GhcRn)] -> a -> a specialize specs = go spec_map0   where-    go :: forall x. Data x => Map (IdP name) (HsType name) -> x -> x-    go spec_map = everywhereButType @name $ mkT $ sugar . strip_kind_sig . specialize_ty_var spec_map+    go :: forall x. Data x => Map Name (HsType GhcRn) -> x -> x+    go spec_map = everywhereButType @Name $ mkT $ sugar . strip_kind_sig . specialize_ty_var spec_map      strip_kind_sig :: HsType name -> HsType name-    strip_kind_sig (HsKindSig (L _ t) _) = t+    strip_kind_sig (HsKindSig _ (L _ t) _) = t     strip_kind_sig typ = typ -    specialize_ty_var :: Map (IdP name) (HsType name) -> HsType name -> HsType name-    specialize_ty_var spec_map (HsTyVar _ (L _ name'))+    specialize_ty_var :: Map Name (HsType GhcRn) -> HsType GhcRn -> HsType GhcRn+    specialize_ty_var spec_map (HsTyVar _ _ (L _ name'))       | Just t <- Map.lookup name' spec_map = t     specialize_ty_var _ typ = typ @@ -54,35 +52,33 @@ -- -- Again, it is just a convenience function around 'specialize'. Note that -- length of type list should be the same as the number of binders.-specializeTyVarBndrs :: (Ord (IdP name), DataId name, NamedThing (IdP name))-                     => Data a-                     => LHsQTyVars name -> [HsType name]+specializeTyVarBndrs :: Data a+                     => LHsQTyVars GhcRn -> [HsType GhcRn]                      -> a -> a specializeTyVarBndrs bndrs typs =     specialize $ zip bndrs' typs   where     bndrs' = map (bname . unLoc) . hsq_explicit $ bndrs-    bname (UserTyVar (L _ name)) = name-    bname (KindedTyVar (L _ name) _) = name+    bname (UserTyVar _ (L _ name)) = name+    bname (KindedTyVar _ (L _ name) _) = name+    bname (XTyVarBndr _) = error "haddock:specializeTyVarBndrs"  -specializePseudoFamilyDecl :: (Ord (IdP name), DataId name, NamedThing (IdP name))-                           => LHsQTyVars name -> [HsType name]-                           -> PseudoFamilyDecl name-                           -> PseudoFamilyDecl name+specializePseudoFamilyDecl :: LHsQTyVars GhcRn -> [HsType GhcRn]+                           -> PseudoFamilyDecl GhcRn+                           -> PseudoFamilyDecl GhcRn specializePseudoFamilyDecl bndrs typs decl =   decl {pfdTyVars = map (specializeTyVarBndrs bndrs typs) (pfdTyVars decl)} -specializeSig :: forall name . (Ord (IdP name), DataId name, SetName (IdP name), NamedThing (IdP name))-              => LHsQTyVars name -> [HsType name]-              -> Sig name-              -> Sig name-specializeSig bndrs typs (TypeSig lnames typ) =-  TypeSig lnames (typ {hswc_body = (hswc_body typ) {hsib_body = noLoc typ'}})+specializeSig :: LHsQTyVars GhcRn -> [HsType GhcRn]+              -> Sig GhcRn+              -> Sig GhcRn+specializeSig bndrs typs (TypeSig _ lnames typ) =+  TypeSig noExt lnames (typ {hswc_body = (hswc_body typ) {hsib_body = noLoc typ'}})   where-    true_type :: HsType name+    true_type :: HsType GhcRn     true_type = unLoc (hsSigWcType typ)-    typ' :: HsType name+    typ' :: HsType GhcRn     typ' = rename fv $ specializeTyVarBndrs bndrs typs true_type     fv = foldr Set.union Set.empty . map freeVariables $ typs specializeSig _ _ sig = sig@@ -90,8 +86,7 @@  -- | Make all details of instance head (signatures, associated types) -- specialized to that particular instance type.-specializeInstHead :: (Ord (IdP name), DataId name, SetName (IdP name), NamedThing (IdP name))-                   => InstHead name -> InstHead name+specializeInstHead :: InstHead GhcRn -> InstHead GhcRn specializeInstHead ihd@InstHead { ihdInstType = clsi@ClassInst { .. }, .. } =     ihd { ihdInstType = instType' }   where@@ -110,27 +105,26 @@ -- and tuple literals resulting in types like @[] a@ or @(,,) a b c@. This -- can be fixed using 'sugar' function, that will turn such types into @[a]@ -- and @(a, b, c)@.-sugar :: forall name. (NamedThing (IdP name), DataId name)-      => HsType name -> HsType name+sugar :: HsType GhcRn -> HsType GhcRn sugar = sugarOperators . sugarTuples . sugarLists -sugarLists :: NamedThing (IdP name) => HsType name -> HsType name-sugarLists (HsAppTy (L _ (HsTyVar _ (L _ name))) ltyp)-    | isBuiltInSyntax name' && strName == "[]" = HsListTy ltyp+sugarLists :: NamedThing (IdP (GhcPass p)) => HsType (GhcPass p) -> HsType (GhcPass p)+sugarLists (HsAppTy _ (L _ (HsTyVar _ _ (L _ name))) ltyp)+    | isBuiltInSyntax name' && strName == "[]" = HsListTy NoExt ltyp   where     name' = getName name     strName = occNameString . nameOccName $ name' sugarLists typ = typ  -sugarTuples :: NamedThing (IdP name) => HsType name -> HsType name+sugarTuples :: NamedThing (IdP (GhcPass p)) => HsType (GhcPass p) -> HsType (GhcPass p) sugarTuples typ =     aux [] typ   where-    aux apps (HsAppTy (L _ ftyp) atyp) = aux (atyp:apps) ftyp-    aux apps (HsParTy (L _ typ')) = aux apps typ'-    aux apps (HsTyVar _ (L _ name))-        | isBuiltInSyntax name' && suitable = HsTupleTy HsBoxedTuple apps+    aux apps (HsAppTy _ (L _ ftyp) atyp) = aux (atyp:apps) ftyp+    aux apps (HsParTy _ (L _ typ')) = aux apps typ'+    aux apps (HsTyVar _ _ (L _ name))+        | isBuiltInSyntax name' && suitable = HsTupleTy NoExt HsBoxedTuple apps       where         name' = getName name         strName = occNameString . nameOccName $ name'@@ -140,10 +134,10 @@     aux _ _ = typ  -sugarOperators :: NamedThing (IdP name) => HsType name -> HsType name-sugarOperators (HsAppTy (L _ (HsAppTy (L _ (HsTyVar _ (L l name))) la)) lb)+sugarOperators :: NamedThing (IdP (GhcPass p)) => HsType (GhcPass p) -> HsType (GhcPass p)+sugarOperators (HsAppTy _ (L _ (HsAppTy _ (L _ (HsTyVar _ _ (L l name))) la)) lb)     | isSymOcc $ getOccName name' = mkHsOpTy la (L l name) lb-    | isBuiltInSyntax name' && getOccString name == "(->)" = HsFunTy la lb+    | isBuiltInSyntax name' && getOccString name == "(->)" = HsFunTy NoExt la lb   where     name' = getName name sugarOperators typ = typ@@ -208,15 +202,14 @@   -- | Compute set of free variables of given type.-freeVariables :: forall name. (NamedThing (IdP name), DataId name)-              => HsType name -> Set Name+freeVariables :: HsType GhcRn -> Set Name freeVariables =     everythingWithState Set.empty Set.union query   where-    query term ctx = case cast term :: Maybe (HsType name) of-        Just (HsForAllTy bndrs _) ->+    query term ctx = case cast term :: Maybe (HsType GhcRn) of+        Just (HsForAllTy _ bndrs _) ->             (Set.empty, Set.union ctx (bndrsNames bndrs))-        Just (HsTyVar _ (L _ name))+        Just (HsTyVar _ _ (L _ name))             | getName name `Set.member` ctx -> (Set.empty, ctx)             | otherwise -> (Set.singleton $ getName name, ctx)         _ -> (Set.empty, ctx)@@ -231,8 +224,7 @@ -- 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 :: (Eq (IdP name), DataId name, SetName (IdP name))-       => Set Name-> HsType name -> HsType name+rename :: Set Name -> HsType GhcRn -> HsType GhcRn rename fv typ = evalState (renameType typ) env   where     env = RenameEnv@@ -252,63 +244,56 @@   }  -renameType :: (Eq (IdP name), SetName (IdP name))-           => HsType name -> Rename (IdP name) (HsType name)-renameType (HsForAllTy bndrs lt) =-    HsForAllTy+renameType :: HsType GhcRn -> Rename (IdP GhcRn) (HsType GhcRn)+renameType (HsForAllTy x bndrs lt) =+    HsForAllTy x         <$> mapM (located renameBinder) bndrs         <*> renameLType lt-renameType (HsQualTy lctxt lt) =-    HsQualTy+renameType (HsQualTy x lctxt lt) =+    HsQualTy x         <$> located renameContext lctxt         <*> renameLType lt-renameType (HsTyVar ip name) = HsTyVar ip <$> located renameName name-renameType (HsAppTy lf la) = HsAppTy <$> renameLType lf <*> renameLType la-renameType (HsFunTy la lr) = HsFunTy <$> renameLType la <*> renameLType lr-renameType (HsListTy lt) = HsListTy <$> renameLType lt-renameType (HsPArrTy lt) = HsPArrTy <$> renameLType lt-renameType (HsTupleTy srt lt) = HsTupleTy srt <$> mapM renameLType lt-renameType (HsSumTy lt) = HsSumTy <$> mapM renameLType lt-renameType (HsOpTy la lop lb) =-    HsOpTy <$> renameLType la <*> located renameName lop <*> renameLType lb-renameType (HsParTy lt) = HsParTy <$> renameLType lt-renameType (HsIParamTy ip lt) = HsIParamTy ip <$> renameLType lt-renameType (HsEqTy la lb) = HsEqTy <$> renameLType la <*> renameLType lb-renameType (HsKindSig lt lk) = HsKindSig <$> renameLType lt <*> pure lk+renameType (HsTyVar x ip name) = HsTyVar x ip <$> located renameName name+renameType t@(HsStarTy _ _) = pure t+renameType (HsAppTy x lf la) = HsAppTy x <$> renameLType lf <*> renameLType la+renameType (HsFunTy x la lr) = HsFunTy x <$> 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 la lop lb) =+    HsOpTy x <$> renameLType la <*> located 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 lt doc) = HsDocTy <$> renameLType lt <*> pure doc-renameType (HsBangTy bang lt) = HsBangTy bang <$> renameLType lt-renameType t@(HsRecTy _) = pure t-renameType t@(HsCoreTy _) = pure t-renameType (HsExplicitListTy ip ph ltys) =-    HsExplicitListTy ip ph <$> renameLTypes ltys-renameType (HsExplicitTupleTy phs ltys) =-    HsExplicitTupleTy phs <$> renameLTypes ltys-renameType t@(HsTyLit _) = 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 (NHsCoreTy _)) = 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)-renameType (HsAppsTy _) = error "HsAppsTy: Only used before renaming"  -renameLType :: (Eq (IdP name), SetName (IdP name))-            => LHsType name -> Rename (IdP name) (LHsType name)+renameLType :: LHsType GhcRn -> Rename (IdP GhcRn) (LHsType GhcRn) renameLType = located renameType  -renameLTypes :: (Eq (IdP name), SetName (IdP name))-             => [LHsType name] -> Rename (IdP name) [LHsType name]+renameLTypes :: [LHsType GhcRn] -> Rename (IdP GhcRn) [LHsType GhcRn] renameLTypes = mapM renameLType  -renameContext :: (Eq (IdP name), SetName (IdP name))-              => HsContext name -> Rename (IdP name) (HsContext name)+renameContext :: HsContext GhcRn -> Rename (IdP GhcRn) (HsContext GhcRn) renameContext = renameLTypes -renameBinder :: (Eq (IdP name), SetName (IdP name))-             => HsTyVarBndr name -> Rename (IdP name) (HsTyVarBndr name)-renameBinder (UserTyVar lname) = UserTyVar <$> located renameName lname-renameBinder (KindedTyVar lname lkind) =-  KindedTyVar <$> located renameName lname <*> located renameType lkind-+renameBinder :: HsTyVarBndr GhcRn -> Rename (IdP GhcRn) (HsTyVarBndr GhcRn)+renameBinder (UserTyVar x lname) = UserTyVar x <$> located renameName lname+renameBinder (KindedTyVar x lname lkind) =+  KindedTyVar x <$> located renameName lname <*> located renameType lkind+renameBinder (XTyVarBndr _) = error "haddock:renameBinder"  -- | Core renaming logic. renameName :: (Eq name, SetName name) => name -> Rename name name@@ -363,5 +348,6 @@   tyVarName :: HsTyVarBndr name -> IdP name-tyVarName (UserTyVar name) = unLoc name-tyVarName (KindedTyVar (L _ name) _) = name+tyVarName (UserTyVar _ name) = unLoc name+tyVarName (KindedTyVar _ (L _ name) _) = name+tyVarName (XTyVarBndr _ ) = error "haddock:tyVarName"
src/Haddock/InterfaceFile.hs view
@@ -82,7 +82,7 @@ -- (2) set `binaryInterfaceVersionCompatibility` to [binaryInterfaceVersion] -- binaryInterfaceVersion :: Word16-#if (__GLASGOW_HASKELL__ >= 803) && (__GLASGOW_HASKELL__ < 805)+#if (__GLASGOW_HASKELL__ >= 805) && (__GLASGOW_HASKELL__ < 807) binaryInterfaceVersion = 33  binaryInterfaceVersionCompatibility :: [Word16]
src/Haddock/Types.hs view
@@ -28,6 +28,7 @@ import Control.Exception import Control.Arrow hiding ((<+>)) import Control.DeepSeq+import Control.Monad.IO.Class (MonadIO(..)) import Data.Typeable import Data.Map (Map) import Data.Data (Data)@@ -38,8 +39,6 @@ import GHC hiding (NoLink) import DynFlags (Language) import qualified GHC.LanguageExtensions as LangExt-import Coercion-import NameSet import OccName import Outputable import Control.Applicative (Applicative(..))@@ -347,7 +346,7 @@   | TypeInst  (Maybe (HsType name)) -- ^ Body (right-hand side)   | DataInst (TyClDecl name)        -- ^ Data constructors -instance (SourceTextX a, OutputableBndrId a)+instance (a ~ GhcPass p,OutputableBndrId a)          => Outputable (InstType a) where   ppr (ClassInst { .. }) = text "ClassInst"       <+> ppr clsiCtx@@ -372,7 +371,7 @@     }  -mkPseudoFamilyDecl :: FamilyDecl name -> PseudoFamilyDecl name+mkPseudoFamilyDecl :: FamilyDecl (GhcPass p) -> PseudoFamilyDecl (GhcPass p) mkPseudoFamilyDecl (FamilyDecl { .. }) = PseudoFamilyDecl     { pfdInfo = fdInfo     , pfdLName = fdLName@@ -380,11 +379,13 @@     , pfdKindSig = fdResultSig     }   where-    mkType (KindedTyVar (L loc name) lkind) =-        HsKindSig tvar lkind+    mkType (KindedTyVar _ (L loc name) lkind) =+        HsKindSig NoExt tvar lkind       where-        tvar = L loc (HsTyVar NotPromoted (L loc name))-    mkType (UserTyVar name) = HsTyVar NotPromoted name+        tvar = L loc (HsTyVar NoExt NotPromoted (L loc name))+    mkType (UserTyVar _ name) = HsTyVar NoExt NotPromoted name+    mkType (XTyVarBndr _ ) = panic "haddock:mkPseudoFamilyDecl"+mkPseudoFamilyDecl (XFamilyDecl {}) = panic "haddock:mkPseudoFamilyDecl"   -- | An instance head that may have documentation and a source location.@@ -661,19 +662,83 @@   m >>= k = WriterGhc $ runWriterGhc m >>= \ (a, msgs1) ->                fmap (second (msgs1 ++)) (runWriterGhc (k a)) +instance MonadIO ErrMsgGhc where+  liftIO m = WriterGhc (fmap (\x -> (x, [])) (liftIO m))  ----------------------------------------------------------------------------- -- * Pass sensitive types ----------------------------------------------------------------------------- -type instance PostRn DocNameI NameSet        = PlaceHolder-type instance PostRn DocNameI Fixity         = PlaceHolder-type instance PostRn DocNameI Bool           = PlaceHolder-type instance PostRn DocNameI Name           = DocName-type instance PostRn DocNameI (Located Name) = Located DocName-type instance PostRn DocNameI [Name]         = PlaceHolder-type instance PostRn DocNameI DocName        = DocName+type instance XForAllTy        DocNameI = NoExt+type instance XQualTy          DocNameI = NoExt+type instance XTyVar           DocNameI = NoExt+type instance XStarTy          DocNameI = NoExt+type instance XAppTy           DocNameI = NoExt+type instance XFunTy           DocNameI = NoExt+type instance XListTy          DocNameI = NoExt+type instance XTupleTy         DocNameI = NoExt+type instance XSumTy           DocNameI = NoExt+type instance XOpTy            DocNameI = NoExt+type instance XParTy           DocNameI = NoExt+type instance XIParamTy        DocNameI = NoExt+type instance XKindSig         DocNameI = NoExt+type instance XSpliceTy        DocNameI = NoExt+type instance XDocTy           DocNameI = NoExt+type instance XBangTy          DocNameI = NoExt+type instance XRecTy           DocNameI = NoExt+type instance XExplicitListTy  DocNameI = NoExt+type instance XExplicitTupleTy DocNameI = NoExt+type instance XTyLit           DocNameI = NoExt+type instance XWildCardTy      DocNameI = HsWildCardInfo+type instance XXType           DocNameI = NewHsTypeX -type instance PostTc DocNameI Kind     = PlaceHolder-type instance PostTc DocNameI Type     = PlaceHolder-type instance PostTc DocNameI Coercion = PlaceHolder+type instance XUserTyVar    DocNameI = NoExt+type instance XKindedTyVar  DocNameI = NoExt+type instance XXTyVarBndr   DocNameI = NoExt++type instance XCFieldOcc   DocNameI = DocName+type instance XXFieldOcc   DocNameI = NoExt++type instance XFixitySig   DocNameI = NoExt+type instance XFixSig      DocNameI = NoExt+type instance XPatSynSig   DocNameI = NoExt+type instance XClassOpSig  DocNameI = NoExt+type instance XTypeSig     DocNameI = NoExt+type instance XMinimalSig  DocNameI = NoExt++type instance XForeignExport  DocNameI = NoExt+type instance XForeignImport  DocNameI = NoExt+type instance XConDeclGADT    DocNameI = NoExt+type instance XConDeclH98     DocNameI = NoExt++type instance XDerivD     DocNameI = NoExt+type instance XInstD      DocNameI = NoExt+type instance XForD       DocNameI = NoExt+type instance XSigD       DocNameI = NoExt+type instance XTyClD      DocNameI = NoExt++type instance XNoSig      DocNameI = NoExt+type instance XCKindSig   DocNameI = NoExt+type instance XTyVarSig   DocNameI = NoExt++type instance XCFamEqn       DocNameI _ _ = NoExt++type instance XCClsInstDecl DocNameI = NoExt+type instance XCDerivDecl   DocNameI = NoExt+type instance XViaStrategy  DocNameI = LHsSigType DocNameI+type instance XDataFamInstD DocNameI = NoExt+type instance XTyFamInstD   DocNameI = NoExt+type instance XClsInstD     DocNameI = NoExt+type instance XCHsDataDefn  DocNameI = NoExt+type instance XCFamilyDecl  DocNameI = NoExt+type instance XClassDecl    DocNameI = NoExt+type instance XDataDecl     DocNameI = NoExt+type instance XSynDecl      DocNameI = NoExt+type instance XFamDecl      DocNameI = NoExt++type instance XHsIB      DocNameI _ = NoExt+type instance XHsWC      DocNameI _ = NoExt++type instance XHsQTvs        DocNameI = NoExt+type instance XConDeclField  DocNameI = NoExt+
src/Haddock/Utils.hs view
@@ -62,8 +62,8 @@  import GHC import Name-import NameSet ( emptyNameSet )-import HsTypes (selectorFieldOcc)+import HsTypes (extFieldOcc)+import Outputable ( panic )  import Control.Monad ( liftM ) import Data.Char ( isAlpha, isAlphaNum, isAscii, ord, chr )@@ -131,16 +131,19 @@  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 lname (mkEmptySigWcType (go (hsSigType ltype))))+addClassContext cls tvs0 (L pos (ClassOpSig _ _ lname ltype))+  = L pos (TypeSig noExt lname (mkEmptySigWcType (go (hsSigType ltype))))           -- The mkEmptySigWcType is suspicious   where     go (L loc (HsForAllTy { hst_bndrs = tvs, hst_body = ty }))-       = L loc (HsForAllTy { hst_bndrs = tvs, hst_body = go ty })+       = L loc (HsForAllTy { hst_xforall = noExt+                           , hst_bndrs = tvs, hst_body = go ty })     go (L loc (HsQualTy { hst_ctxt = ctxt, hst_body = ty }))-       = L loc (HsQualTy { hst_ctxt = add_ctxt ctxt, hst_body = ty })+       = L loc (HsQualTy { hst_xqual = noExt+                         , hst_ctxt = add_ctxt ctxt, hst_body = ty })     go (L loc ty)-       = L loc (HsQualTy { hst_ctxt = add_ctxt (L loc []), hst_body = L loc ty })+       = L loc (HsQualTy { hst_xqual = noExt+                         , hst_ctxt = add_ctxt (L loc []), hst_body = L loc ty })      extra_pred = nlHsTyConApp cls (lHsQTyVarsToTypes tvs0)     add_ctxt (L loc preds) = L loc (extra_pred : preds)@@ -149,7 +152,7 @@  lHsQTyVarsToTypes :: LHsQTyVars GhcRn -> [LHsType GhcRn] lHsQTyVarsToTypes tvs-  = [ noLoc (HsTyVar NotPromoted (noLoc (hsLTyVarName tv)))+  = [ noLoc (HsTyVar NoExt NotPromoted (noLoc (hsLTyVarName tv)))     | tv <- hsQTvExplicit tvs ]  --------------------------------------------------------------------------------@@ -159,10 +162,10 @@  restrictTo :: [Name] -> LHsDecl GhcRn -> LHsDecl GhcRn restrictTo names (L loc decl) = L loc $ case decl of-  TyClD d | isDataDecl d  ->-    TyClD (d { tcdDataDefn = restrictDataDefn names (tcdDataDefn d) })-  TyClD d | isClassDecl d ->-    TyClD (d { tcdSigs = restrictDecls names (tcdSigs d),+  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 @@ -175,42 +178,28 @@       []    -> defn { dd_ND = DataType, dd_cons = [] }       [con] -> defn { dd_cons = [con] }       _ -> error "Should not happen"+restrictDataDefn _ (XHsDataDefn _) = error "restrictDataDefn"  restrictCons :: [Name] -> [LConDecl GhcRn] -> [LConDecl GhcRn] restrictCons names decls = [ L p d | L p (Just d) <- map (fmap keep) decls ]   where     keep d | any (\n -> n `elem` names) (map unLoc $ getConNames d) =-      case getConDetails h98d of+      case con_args d of         PrefixCon _ -> Just d         RecCon fields           | all field_avail (unL fields) -> Just d-          | otherwise -> Just (h98d { con_details = PrefixCon (field_types (map unL (unL fields))) })+          | otherwise -> Just (d { con_args = PrefixCon (field_types (map unL (unL 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       where-        h98d = h98ConDecl d-        h98ConDecl c@ConDeclH98{} = c-        h98ConDecl c@ConDeclGADT{} = c'-          where-            (details,_res_ty,cxt,tvs) = gadtDeclDetails (con_type c)-            c' :: ConDecl GhcRn-            c' = ConDeclH98-                   { con_name = head (con_names c)-                   , con_qvars = Just $ HsQTvs { hsq_implicit = mempty-                                               , hsq_explicit = tvs-                                               , hsq_dependent = emptyNameSet }-                   , con_cxt = Just cxt-                   , con_details = details-                   , con_doc = con_doc c-                   }-         field_avail :: LConDeclField GhcRn -> Bool-        field_avail (L _ (ConDeclField fs _ _))-            = all (\f -> selectorFieldOcc (unLoc f) `elem` names) fs-        field_types flds = [ t | ConDeclField _ t _ <- flds ]+        field_avail (L _ (ConDeclField _ fs _ _))+            = all (\f -> extFieldOcc (unLoc f) `elem` names) fs+        field_avail (L _ (XConDeclField _)) = panic "haddock:field_avail"+        field_types flds = [ t | ConDeclField _ _ t _ <- flds ]      keep _ = Nothing @@ -221,13 +210,14 @@ restrictATs :: [Name] -> [LFamilyDecl GhcRn] -> [LFamilyDecl GhcRn] restrictATs names ats = [ at | at <- ats , unL (fdLName (unL at)) `elem` names ] -emptyHsQTvs :: LHsQTyVars Name+emptyHsQTvs :: LHsQTyVars GhcRn -- This function is here, rather than in HsTypes, because it *renamed*, but -- does not necessarily have all the rigt kind variables.  It is used -- in Haddock just for printing, so it doesn't matter-emptyHsQTvs = HsQTvs { hsq_implicit = error "haddock:emptyHsQTvs"-                     , hsq_explicit = []-                     , hsq_dependent = error "haddock:emptyHsQTvs" }+emptyHsQTvs = HsQTvs { hsq_ext = HsQTvsRn+                       { hsq_implicit = error "haddock:emptyHsQTvs"+                       , hsq_dependent = error "haddock:emptyHsQTvs" }+                     , hsq_explicit = [] }   --------------------------------------------------------------------------------