Skip to content

Instantly share code, notes, and snippets.

@gibiansky
Created September 5, 2015 08:36
Show Gist options
  • Save gibiansky/4c54f767bf21a6954b23 to your computer and use it in GitHub Desktop.
Save gibiansky/4c54f767bf21a6954b23 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.2">
<title>Hacking on GHC</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400">
<style>
/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
/* Remove the comments around the @import statement below when using this as a custom stylesheet */
/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400";*/
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
audio,canvas,video{display:inline-block}
audio:not([controls]){display:none;height:0}
[hidden],template{display:none}
script{display:none!important}
html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
body{margin:0}
a{background:transparent}
a:focus{outline:thin dotted}
a:active,a:hover{outline:0}
h1{font-size:2em;margin:.67em 0}
abbr[title]{border-bottom:1px dotted}
b,strong{font-weight:bold}
dfn{font-style:italic}
hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}
mark{background:#ff0;color:#000}
code,kbd,pre,samp{font-family:monospace;font-size:1em}
pre{white-space:pre-wrap}
q{quotes:"\201C" "\201D" "\2018" "\2019"}
small{font-size:80%}
sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
sup{top:-.5em}
sub{bottom:-.25em}
img{border:0}
svg:not(:root){overflow:hidden}
figure{margin:0}
fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
legend{border:0;padding:0}
button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
button,input{line-height:normal}
button,select{text-transform:none}
button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}
button[disabled],html input[disabled]{cursor:default}
input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}
input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}
button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
textarea{overflow:auto;vertical-align:top}
table{border-collapse:collapse;border-spacing:0}
*,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
html,body{font-size:100%}
body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto}
a:hover{cursor:pointer}
img,object,embed{max-width:100%;height:auto}
object,embed{height:100%}
img{-ms-interpolation-mode:bicubic}
#map_canvas img,#map_canvas embed,#map_canvas object,.map_canvas img,.map_canvas embed,.map_canvas object{max-width:none!important}
.left{float:left!important}
.right{float:right!important}
.text-left{text-align:left!important}
.text-right{text-align:right!important}
.text-center{text-align:center!important}
.text-justify{text-align:justify!important}
.hide{display:none}
.antialiased,body{-webkit-font-smoothing:antialiased}
img{display:inline-block;vertical-align:middle}
textarea{height:auto;min-height:50px}
select{width:100%}
p.lead,.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{font-size:1.21875em;line-height:1.6}
.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
a{color:#2156a5;text-decoration:underline;line-height:inherit}
a:hover,a:focus{color:#1d4b8f}
a img{border:none}
p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
p aside{font-size:.875em;line-height:1.35;font-style:italic}
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
h1{font-size:2.125em}
h2{font-size:1.6875em}
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
h4,h5{font-size:1.125em}
h6{font-size:1em}
hr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}
em,i{font-style:italic;line-height:inherit}
strong,b{font-weight:bold;line-height:inherit}
small{font-size:60%;line-height:inherit}
code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em}
ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
ul.square{list-style-type:square}
ul.circle{list-style-type:circle}
ul.disc{list-style-type:disc}
ul.no-bullet{list-style:none}
ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
dl dt{margin-bottom:.3125em;font-weight:bold}
dl dd{margin-bottom:1.25em}
abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
abbr{text-transform:none}
blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
blockquote cite:before{content:"\2014 \0020"}
blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
@media only screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
h1{font-size:2.75em}
h2{font-size:2.3125em}
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
h4{font-size:1.4375em}}table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
table thead,table tfoot{background:#f7f8f7;font-weight:bold}
table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
.clearfix:before,.clearfix:after,.float-group:before,.float-group:after{content:" ";display:table}
.clearfix:after,.float-group:after{clear:both}
*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
.keyseq{color:rgba(51,51,51,.8)}
kbd{display:inline-block;color:rgba(0,0,0,.8);font-size:.75em;line-height:1.4;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:-.15em .15em 0 .15em;padding:.2em .6em .2em .5em;vertical-align:middle;white-space:nowrap}
.keyseq kbd:first-child{margin-left:0}
.keyseq kbd:last-child{margin-right:0}
.menuseq,.menu{color:rgba(0,0,0,.8)}
b.button:before,b.button:after{position:relative;top:-1px;font-weight:400}
b.button:before{content:"[";padding:0 3px 0 2px}
b.button:after{content:"]";padding:0 2px 0 3px}
p a>code:hover{color:rgba(0,0,0,.9)}
#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
#header:before,#header:after,#content:before,#content:after,#footnotes:before,#footnotes:after,#footer:before,#footer:after{content:" ";display:table}
#header:after,#content:after,#footnotes:after,#footer:after{clear:both}
#content{margin-top:1.25em}
#content:before{content:none}
#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8}
#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px}
#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap}
#header .details span:first-child{margin-left:-.125em}
#header .details span.email a{color:rgba(0,0,0,.85)}
#header .details br{display:none}
#header .details br+span:before{content:"\00a0\2013\00a0"}
#header .details br+span.author:before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
#header .details br+span#revremark:before{content:"\00a0|\00a0"}
#header #revnumber{text-transform:capitalize}
#header #revnumber:after{content:"\00a0"}
#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
#toc{border-bottom:1px solid #efefed;padding-bottom:.5em}
#toc>ul{margin-left:.125em}
#toc ul.sectlevel0>li>a{font-style:italic}
#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
#toc a{text-decoration:none}
#toc a:active{text-decoration:underline}
#toctitle{color:#7a2518;font-size:1.2em}
@media only screen and (min-width:768px){#toctitle{font-size:1.375em}
body.toc2{padding-left:15em;padding-right:0}
#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
#toc.toc2 #toctitle{margin-top:0;font-size:1.2em}
#toc.toc2>ul{font-size:.9em;margin-bottom:0}
#toc.toc2 ul ul{margin-left:0;padding-left:1em}
#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
body.toc2.toc-right{padding-left:0;padding-right:15em}
body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}}@media only screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
#toc.toc2{width:20em}
#toc.toc2 #toctitle{font-size:1.375em}
#toc.toc2>ul{font-size:.95em}
#toc.toc2 ul ul{padding-left:1.25em}
body.toc2.toc-right{padding-left:0;padding-right:20em}}#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
#content #toc>:first-child{margin-top:0}
#content #toc>:last-child{margin-bottom:0}
#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
#footer-text{color:rgba(255,255,255,.8);line-height:1.44}
.sect1{padding-bottom:.625em}
@media only screen and (min-width:768px){.sect1{padding-bottom:1.25em}}.sect1+.sect1{border-top:1px solid #efefed}
#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
#content h1>a.anchor:before,h2>a.anchor:before,h3>a.anchor:before,#toctitle>a.anchor:before,.sidebarblock>.content>.title>a.anchor:before,h4>a.anchor:before,h5>a.anchor:before,h6>a.anchor:before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0}
.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{color:rgba(0,0,0,.85)}
table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit}
.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
.admonitionblock>table td.icon{text-align:center;width:80px}
.admonitionblock>table td.icon img{max-width:none}
.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)}
.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
.exampleblock>.content>:first-child{margin-top:0}
.exampleblock>.content>:last-child{margin-bottom:0}
.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
.sidebarblock>:first-child{margin-top:0}
.sidebarblock>:last-child{margin-bottom:0}
.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em}
.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal}
@media only screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}@media only screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
.listingblock pre.highlightjs{padding:0}
.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
.listingblock pre.prettyprint{border-width:0}
.listingblock>.content{position:relative}
.listingblock code[data-lang]:before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
.listingblock:hover code[data-lang]:before{display:block}
.listingblock.terminal pre .command:before{content:attr(data-prompt);padding-right:.5em;color:#999}
.listingblock.terminal pre .command:not([data-prompt]):before{content:"$"}
table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0}
table.pyhltable td.code{padding-left:.75em;padding-right:0}
pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8}
pre.pygments .lineno{display:inline-block;margin-right:.25em}
table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
.quoteblock blockquote{margin:0;padding:0;border:0}
.quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right}
.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)}
.quoteblock .quoteblock blockquote{padding:0 0 0 .75em}
.quoteblock .quoteblock blockquote:before{display:none}
.verseblock{margin:0 1em 1.25em 1em}
.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
.verseblock pre strong{font-weight:400}
.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
.quoteblock .attribution br,.verseblock .attribution br{display:none}
.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.05em;color:rgba(0,0,0,.6)}
.quoteblock.abstract{margin:0 0 1.25em 0;display:block}
.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0}
.quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none}
table.tableblock{max-width:100%;border-collapse:separate}
table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0}
table.spread{width:100%}
table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0}
table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0}
table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0}
table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0}
table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0}
table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0}
table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0}
table.frame-all{border-width:1px}
table.frame-sides{border-width:0 1px}
table.frame-topbot{border-width:1px 0}
th.halign-left,td.halign-left{text-align:left}
th.halign-right,td.halign-right{text-align:right}
th.halign-center,td.halign-center{text-align:center}
th.valign-top,td.valign-top{vertical-align:top}
th.valign-bottom,td.valign-bottom{vertical-align:bottom}
th.valign-middle,td.valign-middle{vertical-align:middle}
table thead th,table tfoot th{font-weight:bold}
tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
p.tableblock>code:only-child{background:none;padding:0}
p.tableblock{font-size:1em}
td>div.verse{white-space:pre}
ol{margin-left:1.75em}
ul li ol{margin-left:1.5em}
dl dd{margin-left:1.125em}
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none}
ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em}
ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em}
ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px}
ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden}
ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block}
ul.inline>li>*{display:block}
.unstyled dl dt{font-weight:400;font-style:normal}
ol.arabic{list-style-type:decimal}
ol.decimal{list-style-type:decimal-leading-zero}
ol.loweralpha{list-style-type:lower-alpha}
ol.upperalpha{list-style-type:upper-alpha}
ol.lowerroman{list-style-type:lower-roman}
ol.upperroman{list-style-type:upper-roman}
ol.lowergreek{list-style-type:lower-greek}
.hdlist>table,.colist>table{border:0;background:none}
.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
td.hdlist1{padding-right:.75em;font-weight:bold}
td.hdlist1,td.hdlist2{vertical-align:top}
.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1}
.colist>table tr>td:last-of-type{padding:.25em 0}
.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd}
.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0}
.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em}
.imageblock>.title{margin-bottom:0}
.imageblock.thumb,.imageblock.th{border-width:6px}
.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
.image.left{margin-right:.625em}
.image.right{margin-left:.625em}
a.image{text-decoration:none}
span.footnote,span.footnoteref{vertical-align:super;font-size:.875em}
span.footnote a,span.footnoteref a{text-decoration:none}
span.footnote a:active,span.footnoteref a:active{text-decoration:underline}
#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em 0;border-width:1px 0 0 0}
#footnotes .footnote{padding:0 .375em;line-height:1.3;font-size:.875em;margin-left:1.2em;text-indent:-1.2em;margin-bottom:.2em}
#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none}
#footnotes .footnote:last-of-type{margin-bottom:0}
#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
.gist .file-data>table td.line-data{width:99%}
div.unbreakable{page-break-inside:avoid}
.big{font-size:larger}
.small{font-size:smaller}
.underline{text-decoration:underline}
.overline{text-decoration:overline}
.line-through{text-decoration:line-through}
.aqua{color:#00bfbf}
.aqua-background{background-color:#00fafa}
.black{color:#000}
.black-background{background-color:#000}
.blue{color:#0000bf}
.blue-background{background-color:#0000fa}
.fuchsia{color:#bf00bf}
.fuchsia-background{background-color:#fa00fa}
.gray{color:#606060}
.gray-background{background-color:#7d7d7d}
.green{color:#006000}
.green-background{background-color:#007d00}
.lime{color:#00bf00}
.lime-background{background-color:#00fa00}
.maroon{color:#600000}
.maroon-background{background-color:#7d0000}
.navy{color:#000060}
.navy-background{background-color:#00007d}
.olive{color:#606000}
.olive-background{background-color:#7d7d00}
.purple{color:#600060}
.purple-background{background-color:#7d007d}
.red{color:#bf0000}
.red-background{background-color:#fa0000}
.silver{color:#909090}
.silver-background{background-color:#bcbcbc}
.teal{color:#006060}
.teal-background{background-color:#007d7d}
.white{color:#bfbfbf}
.white-background{background-color:#fafafa}
.yellow{color:#bfbf00}
.yellow-background{background-color:#fafa00}
span.icon>.fa{cursor:default}
.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c}
.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
.admonitionblock td.icon .icon-warning:before{content:"\f071";color:#bf6900}
.admonitionblock td.icon .icon-caution:before{content:"\f06d";color:#bf3400}
.admonitionblock td.icon .icon-important:before{content:"\f06a";color:#bf0000}
.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
.conum[data-value] *{color:#fff!important}
.conum[data-value]+b{display:none}
.conum[data-value]:after{content:attr(data-value)}
pre .conum[data-value]{position:relative;top:-.125em}
b.conum *{color:inherit!important}
.conum:not([data-value]):empty{display:none}
h1,h2{letter-spacing:-.01em}
dt,th.tableblock,td.content{text-rendering:optimizeLegibility}
p,td.content{letter-spacing:-.01em}
p strong,td.content strong{letter-spacing:-.005em}
p,blockquote,dt,td.content{font-size:1.0625rem}
p{margin-bottom:1.25rem}
.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
.print-only{display:none!important}
@media print{@page{margin:1.25cm .75cm}
*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
a{color:inherit!important;text-decoration:underline!important}
a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
a[href^="http:"]:not(.bare):after,a[href^="https:"]:not(.bare):after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
abbr[title]:after{content:" (" attr(title) ")"}
pre,blockquote,tr,img{page-break-inside:avoid}
thead{display:table-header-group}
img{max-width:100%!important}
p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
#toc,.sidebarblock,.exampleblock>.content{background:none!important}
#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important}
.sect1{padding-bottom:0!important}
.sect1+.sect1{border:0!important}
#header>h1:first-child{margin-top:1.25rem}
body.book #header{text-align:center}
body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em 0}
body.book #header .details{border:0!important;display:block;padding:0!important}
body.book #header .details span:first-child{margin-left:0!important}
body.book #header .details br{display:block}
body.book #header .details br+span:before{content:none!important}
body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
.listingblock code[data-lang]:before{display:block}
#footer{background:none!important;padding:0 .9375em}
#footer-text{color:rgba(0,0,0,.6)!important;font-size:.9em}
.hide-on-print{display:none!important}
.print-only{display:block!important}
.hide-for-print{display:none!important}
.show-for-print{display:inherit!important}}
</style>
</head>
<body class="article">
<div id="header">
</div>
<div id="content">
<div class="sect1">
<h2 id="_hacking_on_ghc">Hacking on GHC</h2>
<div class="sectionbody">
<div class="paragraph">
<p>After visiting CUFP and meeting a bunch of exciting folks, my desire to contribute to GHC and get
some of my own changes into the Haskell language rose drastically. Starting contributing is quite
intimidating, though; although I&#8217;d done it a bit before, it was quite a big challenge to do so
again.</p>
</div>
<div class="paragraph">
<p>This time, I figured I&#8217;d document the process in its entirety, so that others like me could follow
and commit their own changes to GHC. To be honest, much of this document is useless and is already
documentd on the GHC wiki; treat it more of as a story or experience report rather than as a factual
reference for anything useful.</p>
</div>
<div class="sect2">
<h3 id="_day_1">Day 1</h3>
<div class="paragraph">
<p>Day 1 of the adventure begins now!</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_setting_up_an_environment">Setting up an environment</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The first large barrier to working on GHC is getting it set up. I had most of my tools set up
already, so it was a matter of following the <a href="https://ghc.haskell.org/trac/ghc/wiki/Newcomers">instructions on the Newcomers page</a>.</p>
</div>
<div class="paragraph">
<p>I started by cloning GHC. I keep all my code in <code>~/code</code>, so I went ahead and cloned to
<code>~/code/ghc</code>. This took about ten minutes.</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ cd ~/code/ghc
$ git clone --recursive git://git.haskell.org/ghc.git
Cloning into 'ghc'...
Submodule 'libffi-tarballs' registered for path 'libffi-tarballs'
Submodule 'libraries/Cabal' registered for path 'libraries/Cabal'
Submodule 'libraries/Win32' registered for path 'libraries/Win32'
Submodule 'libraries/array' registered for path 'libraries/array'
Submodule 'libraries/binary' registered for path 'libraries/binary'
Submodule 'libraries/bytestring' registered for path 'libraries/bytestring'
Submodule 'libraries/containers' registered for path 'libraries/containers'
Submodule 'libraries/deepseq' registered for path 'libraries/deepseq'
Submodule 'libraries/directory' registered for path 'libraries/directory'
Submodule 'libraries/dph' registered for path 'libraries/dph'
Submodule 'libraries/filepath' registered for path 'libraries/filepath'
Submodule 'libraries/haskeline' registered for path 'libraries/haskeline'
Submodule 'libraries/hoopl' registered for path 'libraries/hoopl'
Submodule 'libraries/hpc' registered for path 'libraries/hpc'
Submodule 'libraries/parallel' registered for path 'libraries/parallel'
Submodule 'libraries/pretty' registered for path 'libraries/pretty'
Submodule 'libraries/primitive' registered for path 'libraries/primitive'
Submodule 'libraries/process' registered for path 'libraries/process'
Submodule 'libraries/random' registered for path 'libraries/random'
Submodule 'libraries/stm' registered for path 'libraries/stm'
Submodule 'libraries/terminfo' registered for path 'libraries/terminfo'
Submodule 'libraries/time' registered for path 'libraries/time'
Submodule 'libraries/transformers' registered for path 'libraries/transformers'
Submodule 'libraries/unix' registered for path 'libraries/unix'
Submodule 'libraries/vector' registered for path 'libraries/vector'
Submodule 'libraries/xhtml' registered for path 'libraries/xhtml'
Submodule 'nofib' registered for path 'nofib'
Submodule 'utils/haddock' registered for path 'utils/haddock'
Submodule 'utils/hsc2hs' registered for path 'utils/hsc2hs'
Cloning into 'libffi-tarballs'...
Cloning into 'libraries/Cabal'...
Cloning into 'libraries/Win32'...
Cloning into 'libraries/array'...
Cloning into 'libraries/binary'...
Cloning into 'libraries/bytestring'...
Cloning into 'libraries/containers'...
Cloning into 'libraries/deepseq'...
Cloning into 'libraries/directory'...
Cloning into 'libraries/dph'...
Cloning into 'libraries/filepath'...
Cloning into 'libraries/haskeline'...
Cloning into 'libraries/hoopl'...
Cloning into 'libraries/hpc'...
Cloning into 'libraries/parallel'...
Cloning into 'libraries/pretty'...
Cloning into 'libraries/primitive'...
Cloning into 'libraries/process'...
Cloning into 'libraries/random'...
Cloning into 'libraries/stm'...
Cloning into 'libraries/terminfo'...
Cloning into 'libraries/time'...
Cloning into 'libraries/transformers'...
Cloning into 'libraries/unix'...
Cloning into 'libraries/vector'...
Cloning into 'libraries/xhtml'...
Cloning into 'nofib'...
Cloning into 'utils/haddock'...
Cloning into 'utils/hsc2hs'...</pre>
</div>
</div>
<div class="paragraph">
<p>Once the GHC repository and all submodules are cloned, you must set up how you want to build GHC. To
do so, you create a <code>build.mk</code> file with your own configuration; in my case, I wanted to build my
compiler quickly, and so stole the configuration from the
<a href="https://ghc.haskell.org/trac/ghc/wiki/Building/Using#HowtomakeGHCbuildquickly">GHC wiki page</a> on how
to make a quickly building stage 2 compiler. There are also a bunch of pre-configured builds, so you
can edit <code>build.mk</code> and just uncomment one of the lines to choose a build configuration. I went
ahead and copied the GHC wiki suggestion and just inserted the following at the top of <code>build.mk</code> (a
copied version of <code>build.mk.sample</code>):</p>
</div>
<div class="listingblock">
<div class="content">
<pre># My build settings for hacking on stage 2
SRC_HC_OPTS = -H32m -O -fasm
GhcStage1HcOpts = -O -fasm
GhcStage2HcOpts = -O0 -DDEBUG -Wall
GhcLibHcOpts = -O -fasm
GhcLibWays = v
SplitObjs = NO</pre>
</div>
</div>
<div class="paragraph">
<p>I next ran <code>./boot</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ ./boot
Creating libraries/array/ghc.mk
Creating libraries/array/GNUmakefile
Creating libraries/base/ghc.mk
Creating libraries/base/GNUmakefile
Creating libraries/bin-package-db/ghc.mk
... and so on...
Booting .
Booting libraries/base/
Booting libraries/directory/
Booting libraries/integer-gmp/
Booting libraries/process/
Booting libraries/terminfo/
Booting libraries/time/
Booting libraries/unix/</pre>
</div>
</div>
<div class="paragraph">
<p>After that comes <code>./configure</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ ./configure
... everything was ok until...
checking for DocBook DTD... I/O error : Attempt to load network entity http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd
conftest.xml:5: warning: failed to load external entity "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
]&gt;
^
conftest.xml:6: element book: validity error : No declaration for attribute id of element book
&lt;book id="test"&gt;
^
conftest-book.xml:2: parser error : Entity 'ldquo' not defined
&lt;title&gt;A DocBook &amp;ldquo;Test Document&amp;rdquo;&lt;/title&gt;
^
conftest-book.xml:2: parser error : Entity 'rdquo' not defined
&lt;title&gt;A DocBook &amp;ldquo;Test Document&amp;rdquo;&lt;/title&gt;
^
conftest-book.xml:11: parser error : chunk is not well balanced
^
conftest.xml:7: parser error : Failure to process entity conftest-book
&amp;conftest-book;
^
conftest.xml:7: parser error : Entity 'conftest-book' not defined
&amp;conftest-book;
^
failed
configure: WARNING: cannot find a DTD for DocBook XML V4.5, you will not be able to validate your documentation
configure: WARNING: check your XML_CATALOG_FILES environment variable and/or /etc/xml/catalog
checking for xsltproc... /usr/bin/xsltproc
checking for DocBook XSL stylesheet... no
configure: WARNING: cannot find DocBook XSL stylesheets, you will not be able to build the documentation
checking for dblatex... /usr/local/bin/dblatex
checking for ghc-pkg matching /Users/silver/.stack/programs/x86_64-osx/ghc-7.10.1/bin/ghc... /Users/silver/.stack/programs/x86_64-osx/ghc-7.10.1/bin/ghc-pkg
checking for happy... no
checking for version of happy...
configure: error: Happy version 1.19.4 or later is required to compile GHC.</pre>
</div>
</div>
<div class="paragraph">
<p>Turns out I was missing a few things: <code>happy</code>, <code>alex</code>, and something related to docbook. Installing <code>happy</code>
was easy with <code>stack install happy</code>; same for <code>alex</code>. After doing so <code>./configure</code> succeeded, so
perhaps DocBook wasn&#8217;t really an issue.</p>
</div>
<div class="paragraph">
<p>Finally we get to the long-running part: <code>make</code></p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ make
+ test -f mk/config.mk.old
+ cp -p mk/config.mk mk/config.mk.old
touch -r mk/config.mk.old mk/config.mk
+ test -f mk/project.mk.old
+ cp -p mk/project.mk mk/project.mk.old
touch -r mk/project.mk.old mk/project.mk
+ test -f compiler/ghc.cabal.old
+ cp -p compiler/ghc.cabal compiler/ghc.cabal.old
touch -r compiler/ghc.cabal.old compiler/ghc.cabal
===--- building phase 0
/Applications/Xcode.app/Contents/Developer/usr/bin/make --no-print-directory -f ghc.mk phase=0 phase_0_builds
ghc.mk:153: *** dyn is not in $(GhcLibWays), but $(DYNAMIC_GHC_PROGRAMS) is YES. Stop.
make: *** [all] Error 2</pre>
</div>
</div>
<div class="paragraph">
<p>This quickly fails with the error message above. It looks like the issue is that the variable
<code>DYNAMIC_GHC_PROGRAMS</code> defaults to <code>YES</code> which contradicts the fact that my copied <code>build.mk</code> sets
<code>GhcLibWays</code> to <code>v</code> and not something including <code>dyn</code>. I have no idea what this means, and after
Googling, stumble upon <a href="https://ghc.haskell.org/trac/ghc/wiki/DynamicGhcPrograms">this page</a>. This
still doesn&#8217;t make things quite clear, but in the interest of time I just add <code>dyn</code> to <code>GhcLibWays</code>
and hope it fixes things, and run <code>make -j8</code> again. This time, it starts compiling things!</p>
</div>
<div class="paragraph">
<p>Looking at <code>htop</code>, it seems like at least for the first while, nothing really gets parallelized, at
least while building <code>Cabal</code>. Once <code>Cabal</code> is compiled though, the compile happily pegs my CPUs at
100% utilization.</p>
</div>
<div class="paragraph">
<p>Everything seems to go well for about 15-20 minutes until this happens:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>sed 1d docs/users_guide/flags.xml &gt;&gt; docs/man/flags.xml
"inplace/bin/ghc-stage1" -optc-m64 -optc-fno-stack-protector -optc-Wall -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Iincludes -optc-Iincludes/dist -optc-Iincludes/dist-derivedconstants/header -optc-Iincludes/dist-ghcconstants/header -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-fno-strict-aliasing -optc-fno-common -optc-DDTRACE -optc-Irts/dist/build/autogen -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -static -H32m -O -fasm -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Irts -Irts/dist/build -DCOMPILING_RTS -this-package-key rts -dcmm-lint -DDTRACE -i -irts -irts/dist/build -irts/dist/build/autogen -Irts/dist/build -Irts/dist/build/autogen -O2 -c rts/hooks/OutOfHeap.c -o rts/dist/build/hooks/OutOfHeap.o
"inplace/bin/ghc-stage1" -optc-m64 -optc-fno-stack-protector -optc-Wall -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Iincludes -optc-Iincludes/dist -optc-Iincludes/dist-derivedconstants/header -optc-Iincludes/dist-ghcconstants/header -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-fno-strict-aliasing -optc-fno-common -optc-DDTRACE -optc-Irts/dist/build/autogen -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -static -H32m -O -fasm -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Irts -Irts/dist/build -DCOMPILING_RTS -this-package-key rts -dcmm-lint -DDTRACE -i -irts -irts/dist/build -irts/dist/build/autogen -Irts/dist/build -Irts/dist/build/autogen -O2 -c rts/hooks/StackOverflow.c -o rts/dist/build/hooks/StackOverflow.o
Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main.
Call hs_init_ghc() from your main() function to set these options.
Build the book set list...
Build the book set list...
warning: failed to load external entity "/System/Library/Frameworks/Python.framework/Versions/2.7/share/dblatex/xsl/latex_book_fast.xsl"
compilation error: file /private/var/folders/0l/vg6g5pdd32l6ggh_xdngnkwh0000gn/T/tmpi_nTXo/custom.xsl line 6 element import
xsl:import : unable to load /System/Library/Frameworks/Python.framework/Versions/2.7/share/dblatex/xsl/latex_book_fast.xsl
warning: failed to load external entity "/System/Library/Frameworks/Python.framework/Versions/2.7/share/dblatex/xsl/common/mkdoclist.xsl"
compilation error: file doclist.xsl line 7 element import
xsl:import : unable to load /System/Library/Frameworks/Python.framework/Versions/2.7/share/dblatex/xsl/common/mkdoclist.xsl
warning: failed to load external entity "/System/Library/Frameworks/Python.framework/Versions/2.7/share/dblatex/xsl/latex_book_fast.xsl"
compilation error: file /private/var/folders/0l/vg6g5pdd32l6ggh_xdngnkwh0000gn/T/tmphVadXL/custom.xsl line 6 element import
xsl:import : unable to load /System/Library/FramewoUnexpected error occured
Error: xsltproc failed
rks/Python.framework/Versions/2.7/share/dblatex/xsl/latex_book_fast.xsl
warning: failed to load external entity "/System/Library/Frameworks/Python.framework/Versions/2.7/share/dblatex/xsl/common/mkdoclist.xsl"
compilation error: file doclist.xsl line 7 element import
xsl:import : unable to load /System/Library/Frameworks/Python.framework/Versions/2.7/share/dblatex/xsl/common/mkdoclist.xsl
Unexpected error occured
Error: xsltproc failed
make[1]: *** [utils/haddock/doc/haddock.ps] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [utils/haddock/doc/haddock.pdf] Error 1
make: *** [all] Error 2</pre>
</div>
</div>
<div class="paragraph">
<p>This seems once more related to the DocBook issues from before. Perhaps I don&#8217;t have <code>xsltproc</code>,
whatever that is?</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ which xsltproc
/usr/bin/xsltproc</pre>
</div>
</div>
<div class="paragraph">
<p>Nope, that&#8217;s not it. It does look like it&#8217;s unable to load some sort of libraries though, looking at
these lines:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>xsl:import : unable to load /System/Library/Frameworks/Python.framework/Versions/2.7/share/dblatex/xsl/latex_book_fast.xsl
xsl:import : unable to load /System/Library/FramewoUnexpected error occured
Error: xsltproc failed</pre>
</div>
</div>
<div class="paragraph">
<p>On a whim, I tried adding DocBook support:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ brew install docbook
$ export XML_CATALOG_FILES=`brew --prefix`/etc/xml/catalog</pre>
</div>
</div>
<div class="paragraph">
<p>Sadly this didn&#8217;t seem to affect much&#8201;&#8212;&#8201;still the same errors&#8230;&#8203;</p>
</div>
<div class="paragraph">
<p>I tried with another package, which perhaps provides some data files for DocBook, maybe the ones
that the GHC build can&#8217;t import:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ brew install docbook-xsl</pre>
</div>
</div>
<div class="paragraph">
<p>Nope, this is still useless. At this point, I gave up on fixing this issue through getting DocBook
to work and instead decided to disable whatever Haddock was trying to do, which
<a href="https://ghc.haskell.org/trac/ghc/wiki/Building/Docs">this page</a> told me how to do: add <code>HADDOCK_DOCKS = NO</code> to my <code>build.mk</code>.</p>
</div>
<div class="paragraph">
<p>I then realized that in order for this to affect anything, I&#8217;d have to run <code>./configure</code> again, and
it would maybe have to rerun a bunch of <code>make</code> stuff. Instead of risking that, I edited
<code>mk/config.mk</code>, and found these lines:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>BUILD_DOCBOOK_PS = YES
BUILD_DOCBOOK_PDF = YES</pre>
</div>
</div>
<div class="paragraph">
<p>and changed <code>YES</code> to <code>NO</code>.</p>
</div>
<div class="paragraph">
<p>At this point, compilation happily proceeded onwards. This was probably the wrong way to handle
things, but it worked. After a little while, I see it configuring <code>base-4.8</code> - great!</p>
</div>
<div class="paragraph">
<p>After all of this is done, I test that it works:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ inplace/bin/ghc-stage2 --version
The Glorious Glasgow Haskell Compilation System, version 7.11.20150904</pre>
</div>
</div>
<div class="paragraph">
<p>Hooray!</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_making_a_test_parser_change">Making a Test Parser Change</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The changes I&#8217;d like to make pertain to the parser. In order to make sure I can change the parser,
I&#8217;m going to make a tiny change to the parser file <code>Parser.y</code> and see if I can prove that the change
goes through to the final compiler. I think that even though I&#8217;m fiddling with the parser, I can
stick to just rebuilding the Stage 2 compiler, so I edit the <code>build.mk</code> to reflect that. From the
<a href="https://ghc.haskell.org/trac/ghc/wiki/Newcomers">Newcomers page</a>, it&#8217;s not quite clear exactly how to
make it only build Stage 2, even though it suggests doing so. There&#8217;s some more info on the
<a href="https://ghc.haskell.org/trac/ghc/wiki/Building/Using#Commonbuild.mkoptions">Build System</a> page, which
suggests using the commands <code>make stage=2</code> or <code>make 2</code> from the <code>ghc</code> subdirectory. I try it and it
completes quickly.</p>
</div>
<div class="paragraph">
<p>My parser change concerns expressions; I find that the awkwardly named <code>exp10</code> rule in
<code>compiler/parser/Parser.y</code> is the main rule for expressions. My first nonsensical change (as a test)
is to add the following option:</p>
</div>
<div class="listingblock">
<div class="content">
<pre> | 'soup' stmtlist {% ams (L (comb2 $1 $2)
(mkHsDo DoExpr (snd $ unLoc $2)))
(mj AnnDo $1:(fst $ unLoc $2)) }</pre>
</div>
</div>
<div class="paragraph">
<p>This is a rule that treats the new <code>soup</code> keyword as a <code>do</code> block.</p>
</div>
<div class="paragraph">
<p>Unsurprisingly, this doesn&#8217;t work&#8201;&#8212;&#8201;the lexer isn&#8217;t updated. Alright, I guess I have to make a more
reasonable first change. As suggested by the GHC wiki, I find an error message:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>"parse error in lambda: no expression after '-&gt;'"</pre>
</div>
</div>
<div class="paragraph">
<p>and change it to something obviously different</p>
</div>
<div class="listingblock">
<div class="content">
<pre>"HELP ME! What's going on?! parse error in lambda: no expression after '-&gt;'"</pre>
</div>
</div>
<div class="paragraph">
<p><code>make 2</code> happily reruns <code>happy</code> and generates me a new <code>ghc</code>. I create <code>Test.hs</code>:</p>
</div>
<div class="listingblock">
<div class="title">Test.hs</div>
<div class="content">
<pre>module Test where
test = \x -&gt;</pre>
</div>
</div>
<div class="paragraph">
<p>And run a command to test my error message:</p>
</div>
<div class="listingblock">
<div class="content">
<pre># ../inplace/bin/ghc-stage2 Test.hs
[1 of 1] Compiling Test ( Test.hs, Test.o )
Test.hs:3:8: error:
HELP ME! What's going on?! parse error in lambda: no expression after '-&gt;'</pre>
</div>
</div>
<div class="paragraph">
<p>Hooray! I&#8217;ve proven that my development cycle work.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_making_my_actual_change">Making my actual change</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Today, I&#8217;d like to make a parser change that allows code like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>main = do
fileExists &lt;- doesFileExist "my_file.txt"
when fileExists do
putStrLn "It exists!"</pre>
</div>
</div>
<div class="paragraph">
<p>The main change is in the <code>when</code>: I&#8217;d like the traditional <code>$</code> to be optional, allowing a naked
<code>do</code>. I imagine there is a good reason why this hasn&#8217;t been done, so I expect to fail due to
shift-reduce conflicts or some other parser nonsense.</p>
</div>
<div class="paragraph">
<p>I start off by making a test file containing the code above, calling it <code>Test1.hs</code>.</p>
</div>
<div class="paragraph">
<p>I trace down function application to a rule named <code>fexp</code>, which expands to a left-recursive rule
<code>fexp aexp</code>, with <code>aexp</code> probably standing for "argument expression" and <code>fexp</code> probably standing
for "function expression". It seems like I want <code>aexp</code> to accept raw <code>do</code> blocks; looking at that
rule, it seems to boil down to <code>aexp1</code>, which in turn redirects to <code>aexp2</code>, which is quite meaty.</p>
</div>
<div class="paragraph">
<p>As a first pass, I just copy the <code>do</code> rule from <code>exp</code> to <code>aexp2</code>. Let&#8217;s see what happens!</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ ../inplace/bin/ghc-stage2 Test1.hs
[1 of 1] Compiling Main ( Test1.hs, Test1.o )
Test1.hs:2:17: error:
Variable not in scope: doesFileExist :: [Char] -&gt; m t0
Test1.hs:3:3: error:
Variable not in scope: when :: t0 -&gt; IO () -&gt; m b</pre>
</div>
</div>
<div class="paragraph">
<p>It parses!</p>
</div>
<div class="paragraph">
<p>However, when building <code>Parser.y</code> I noticed one some worrying lines:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>unused rules: 1
reduce/reduce conflicts: 39</pre>
</div>
</div>
<div class="paragraph">
<p>These didn&#8217;t appear before, so before declaring victory I&#8217;d like to know what&#8217;s going on. Surely
it&#8217;s not this easy! I&#8217;m not 100% sure what reduce/reduce conflicts are, and googling brings me to a
<a href="http://www.gnu.org/software/bison/manual/html_node/Reduce_002fReduce.html">Bison documentation page</a>
on the issue. The key phrase is:</p>
</div>
<div class="quoteblock">
<blockquote>
<div class="paragraph">
<p>A reduce/reduce conflict occurs if there are two or more rules that apply to the same sequence of input. This usually indicates a serious error in the grammar.</p>
</div>
</blockquote>
<div class="attribution">
&#8212; Bison docs
</div>
</div>
<div class="paragraph">
<p>Well, that&#8217;s sad, although pretty expected, since we literally duplicated a rule.</p>
</div>
<div class="paragraph">
<p>In order to resolve this, we really need to understand why <code>aexp2</code> ane <code>exp10</code> are different rules.
<code>exp10</code> has <code>fexp</code> as one of its rules; <code>fexp</code> can be <strong>just</strong> a <code>aexp</code>, which can be just an <code>aexp1</code>,
which can be just an <code>aexp2</code>, so as a result <code>aexp2</code> can parse directly as an <code>exp10</code>. Not the other
way around, however!</p>
</div>
<div class="paragraph">
<p>This means that in order to make <code>do</code> blocks behave the way we want, we need to move them from
<code>exp10</code> to <code>aexp2</code>.</p>
</div>
<div class="paragraph">
<p>This is much better. Running <code>make 2</code> now, I don&#8217;t get any reduce/reduce conflicts or unused rules,
and my <code>Test1.hs</code> still passes my brief test (it parses).</p>
</div>
<div class="paragraph">
<p>This <strong>still</strong> seems too easy! How can I discover where this breaks?</p>
</div>
<div class="paragraph">
<p>There&#8217;s a clear answer: use GHC&#8217;s parser test suite.</p>
</div>
<div class="paragraph">
<p>Sadly, it&#8217;s midnight, and I need to be awake much too soon, and I haven&#8217;t gone to sleep yet. So this
is the end of day one. Day two will consist of running my new compiler on a test suite, making some
changes, and maybe trying to add a LANGUAGE pragma for this change and then making a Phabricator
patch/diff/commit/PR/whatever they&#8217;re called in GHC land.</p>
</div>
<div class="sect2">
<h3 id="_end_of_day_1">End of Day 1</h3>
</div>
<div class="sect2">
<h3 id="_day_2">Day 2</h3>
<div class="paragraph">
<p>I quickly find a <a href="https://ghc.haskell.org/trac/ghc/wiki/Building/RunningTests/Running">page about running the test suite</a>,
which tells me exactly what I need to know. I <code>cd</code> to <code>testsuite/tests/parser</code> and run <code>make THREADS=8</code>
and quickly get a result:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>OVERALL SUMMARY for test run started at Sat Sep 5 00:07:17 2015 PDT
0:00:13 spent to go through
193 total tests, which gave rise to
449 test cases, of which
257 were skipped
0 had missing libraries
189 expected passes
3 expected failures
0 caused framework failures
0 unexpected passes
0 unexpected failures
0 unexpected stat failures</pre>
</div>
</div>
<div class="paragraph">
<p>No changes in the parser test suite from my minor change.</p>
</div>
<div class="paragraph">
<p>I guess I should add a few tests!</p>
</div>
<div class="paragraph">
<p>My first test will just check that my feature does what it claims to do. It goes in
<code>should_compile</code>. It seems like there are files called <code>EmptyDecls.hs</code> and <code>DoAndIfThenElse.hs</code>,
so I decide I should come up with a name for my extension and use it to name the test case. The
extension will be called <code>ArgumentDo</code> (bikeshedding later) and goes in <code>ArgumentDo.hs</code>:</p>
</div>
<div class="listingblock">
<div class="title">ArgumentDo.hs</div>
<div class="content">
<pre>{-# LANGUAGE ArgumentDo #-}
module ArgumentDo where
when :: Bool -&gt; IO () -&gt; IO ()
when True a = a
when False _ = return ()
foo :: IO ()
foo = when True do
return ()</pre>
</div>
</div>
<div class="paragraph">
<p>Running <code>make</code> again, I get the same numbers, so it seems just adding the file isn&#8217;t enough. Luckily
there&#8217;s <a href="https://ghc.haskell.org/trac/ghc/wiki/Building/RunningTests/Adding">a page on adding new test cases</a>,
and it says I have to edit <code>all.T</code>. I add the line:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>test('ArgumentDo', normal, compile, [''])</pre>
</div>
</div>
<div class="paragraph">
<p>Running <code>make</code> now yields:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>Unexpected results from:
TEST="ArgumentDo"
OVERALL SUMMARY for test run started at Sat Sep 5 00:15:59 2015 PDT
0:00:14 spent to go through
194 total tests, which gave rise to
452 test cases, of which
259 were skipped
0 had missing libraries
189 expected passes
3 expected failures
0 caused framework failures
0 unexpected passes
1 unexpected failures
0 unexpected stat failures
Unexpected failures:
should_compile ArgumentDo [exit code non-0] (normal)</pre>
</div>
</div>
<div class="paragraph">
<p>Good news: it picked up the test. Bad news: the test seems to fail! Luckily, the test suite dumps
<code>X.comp.stderr</code> files (where <code>X</code> is the filename of the test), so I can look in
<code>should_compile/ArgumentDo.comp.stderr</code> to see what went wrong:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>ArgumentDo.hs:1:14: error: Unsupported extension: ArgumentDo</pre>
</div>
</div>
<div class="paragraph">
<p>Oh, of course! I forgot to add the <code>ArgumentDo</code> language extension. Let&#8217;s add this extension, even
though for now it will do nothing (I don&#8217;t know how to make the parser depend on extensions yet).</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_adding_a_language_pragma">Adding a Language Pragma</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I take <code>DoAndIfThenElse</code> as an example: it&#8217;s a simple extension. Grepping through the source code
shows me that I need to change <code>main/DynFlags.hs</code>. I search for <code>DoAndIfThenElse</code> in that file and
make some very similar lines in each place for <code>ArgumentDo</code>, and run <code>make 2</code> again. Compilation
takes somewhat longer this time; more things depend on <code>DynFlags.hs</code> than I expected. I guess it
makes sense, since language extensions pervade the entire way the compiler operates. I begin to
wonder if I should have attached <code>-j8</code> to make <code>make 2</code> command; restarting it tells me that yes, I
do indeed what that. It goes 8 times faster (ish).</p>
</div>
<div class="paragraph">
<p>Once that&#8217;s done, I run <code>make</code> in the test directory again. This time it succeeds:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>OVERALL SUMMARY for test run started at Sat Sep 5 00:26:34 2015 PDT
0:00:14 spent to go through
194 total tests, which gave rise to
452 test cases, of which
259 were skipped
0 had missing libraries
190 expected passes
3 expected failures
0 caused framework failures
0 unexpected passes
0 unexpected failures
0 unexpected stat failures</pre>
</div>
</div>
<div class="paragraph">
<p>That said, I know these tests aren&#8217;t enough. I&#8217;ve almost certainly enabled some weird parses that
weren&#8217;t valid before, and I&#8217;ll need to write code to eliminate those parses and then test that those
parses were indeed elimianted. But that can come later; first, let&#8217;s make this extension actually
enable and disable the feature.</p>
</div>
<div class="paragraph">
<p>To test this, I add a corresponding test in <code>should_fail</code>, that mirrors <code>ArgumentDo.hs</code> but lacks
the LANGUAGE pragma at the top, and then edit <code>all.T</code>.</p>
</div>
<div class="paragraph">
<p>After adding that test, I see that it fails (that is, the program unexpectedly works):</p>
</div>
<div class="listingblock">
<div class="content">
<pre>Unexpected results from:
TEST="ArgumentDo"
OVERALL SUMMARY for test run started at Sat Sep 5 00:30:02 2015 PDT
0:00:14 spent to go through
195 total tests, which gave rise to
453 test cases, of which
259 were skipped
0 had missing libraries
190 expected passes
3 expected failures
1 caused framework failures
0 unexpected passes
1 unexpected failures
0 unexpected stat failures
Unexpected failures:
should_fail ArgumentDo [exit code 0] (normal)</pre>
</div>
</div>
<div class="paragraph">
<p>In order to make this fail as expected, we&#8217;ll check that a <code>do</code> block doesn&#8217;t occur in places it&#8217;s
not supposed to. Looking at the parser around lines 2245 in <code>Parser.y</code>, it seems like the new places we&#8217;ve allowed the <code>do</code> blocks
are:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>as an argument to <code>fexp</code></p>
</li>
<li>
<p>after <code>static</code></p>
</li>
<li>
<p>after a <code>@</code> (is that parsing a pattern as an expression and then reinterpreting it?) see the
section on <a href="https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/Parser">overparsing</a></p>
</li>
<li>
<p>after a <code>~</code> (same thing?)</p>
</li>
<li>
<p>as the left hand side to a record constructor, e.g. <code>a { x = y}</code>, where the <code>a</code> is</p>
</li>
<li>
<p>in some arrow notation that uses <code>(|</code> and <code>|)</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For now let me just take care of the first case. From the
<a href="https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/Parser">Parser page</a>, it seems like
<code>RdrHsSyn.hs</code> is the right place to do parse tree validation, so I stick a <code>checkArgumentDo</code> in
there and export it. These changes take a very long back-and-forth with the compiler which makes me
grateful I&#8217;m working in Haskell; I have no idea how the parser or its API works, but I can just
muddle forward because I can rely on the type checker catching terrible mistakes.</p>
</div>
<div class="listingblock">
<div class="content">
<pre>-- | Yield a parse error if we have a function applied directly to a do block
-- and ArgumentDo is not enabled.
checkArgumentDo :: LHsExpr RdrName -&gt; P (LHsExpr RdrName)
checkArgumentDo appExpr = do
pState &lt;- getPState
if isNakedDo
then if xopt Opt_ArgumentDo (dflags pState)
then return appExpr
else parseErr
else return appExpr
where
isNakedDo =
case unLoc appExpr of
HsApp _ arg -&gt; case unLoc arg of
HsDo{} -&gt; True
_ -&gt; False
_ -&gt; False
parseErr =
parseErrorSDoc (getLoc appExpr)
(text "Unexpected do block in function application:"
$$ nest 4 (ppr appExpr)
$$ text "Perhaps you meant to use ArgumentDo?")</pre>
</div>
</div>
<div class="paragraph">
<p>Next I need to use this. Since it checks for function application, I can use it directly in the rule
for function application where it says <code>fexp aexp</code>. That section goes from:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>fexp :: { LHsExpr RdrName }
: fexp aexp { sLL $1 $&gt; $ HsApp $1 $2 }
: ...</pre>
</div>
</div>
<div class="paragraph">
<p>and becomes:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>fexp :: { LHsExpr RdrName }
: fexp aexp {% checkArgumentDo (sLL $1 $&gt; $ (HsApp $1 $2)) }
: ...</pre>
</div>
</div>
<div class="paragraph">
<p>I believe I&#8217;m done! I&#8217;m going to go ahead and test again. Let&#8217;s see how badly everything breaks.</p>
</div>
<div class="paragraph">
<p>My test still fails:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>Unexpected results from:
TEST="ArgumentDo"
OVERALL SUMMARY for test run started at Sat Sep 5 01:13:42 2015 PDT
0:00:14 spent to go through
195 total tests, which gave rise to
453 test cases, of which
259 were skipped
0 had missing libraries
190 expected passes
3 expected failures
1 caused framework failures
0 unexpected passes
1 unexpected failures
0 unexpected stat failures
Unexpected failures:
should_fail ArgumentDo [stderr mismatch] (normal)</pre>
</div>
</div>
<div class="paragraph">
<p>This time, it&#8217;s because it returns stderr:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>ArgumentDo.hs:8:7: error:
Unexpected do block in function application:
when True (do { return () })
Perhaps you meant to use ArgumentDo?</pre>
</div>
</div>
<div class="paragraph">
<p>That&#8217;s awesome! I just need to stick that into a golden file and I&#8217;m good to go. I put it in
<code>should_fail/ArgumentDo.stderr</code> and rerun. It works!</p>
</div>
<div class="listingblock">
<div class="content">
<pre>OVERALL SUMMARY for test run started at Sat Sep 5 01:15:20 2015 PDT
0:00:14 spent to go through
195 total tests, which gave rise to
453 test cases, of which
259 were skipped
0 had missing libraries
191 expected passes
3 expected failures
1 caused framework failures
0 unexpected passes
0 unexpected failures
0 unexpected stat failures</pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_phabricator_and_review">Phabricator and review</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Next up, let&#8217;s make a Phabricator patch to get this in front of some other Haskell devs. I&#8217;d like to
get some feedback and see what I&#8217;m missing! This still seems way too easy&#8201;&#8212;&#8201;there has to be a
reason this hasn&#8217;t been done. Why haven&#8217;t I run into it yet?</p>
</div>
<div class="paragraph">
<p>I&#8217;ll follow the instructions on the
<a href="https://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBugs">contributing a patch</a> page.</p>
</div>
<div class="paragraph">
<p>First, it has to be on Trac. Alright, I can make a bug report. I made one
<a href="https://ghc.haskell.org/trac/ghc/ticket/10843#ticket">here</a>.</p>
</div>
<div class="paragraph">
<p>Next up, I need to make a commit! I do so:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git checkout -b argument-do
$ git add compiler/main/DynFlags.hs compiler/parser/Parser.y compiler/parser/RdrHsSyn.hs \
testsuite/tests/parser/should_compile/all.T testsuite/tests/parser/should_fail/all.T \
testsuite/tests/parser/should_compile/ArgumentDo.hs \
testsuite/tests/parser/should_fail/ArgumentDo.stderr \
testsuite/tests/parser/should_fail/ArgumentDo.hs \
$ git commit -m 'Support ArgumentDo (fixes #10843)'</pre>
</div>
</div>
<div class="paragraph">
<p>I try to follow the Git commit message structure suggestions.</p>
</div>
<div class="paragraph">
<p>Alright, next up: Phabricator! I&#8217;ve already signed up before, so I just need to use
<a href="https://ghc.haskell.org/trac/ghc/wiki/Phabricator">the guide</a> to figure out the Arcanist CLI commands
or whatever.</p>
</div>
<div class="paragraph">
<p>Wow, it looks like all I have to do is run <code>arc diff</code>. That&#8217;s easy and awesome! Sadly&#8230;&#8203; I get the
following response:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>zsh: segmentation fault arc diff</pre>
</div>
</div>
<div class="paragraph">
<p>I should just reinstall Arcanist. It&#8217;s been a while.</p>
</div>
<div class="paragraph">
<p>That doesn&#8217;t help, but for some reason <code>brew uninstall php55</code> does.</p>
</div>
<div class="paragraph">
<p><code>arc diff</code> tells me:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>You have untracked files in this working copy.
Working copy: /Users/silver/code/ghc/
Untracked changes in working copy:
(To ignore this change, add it to ".git/info/exclude".)
libraries/integer-gmp/gmp/objs/__.SYMDEF SORTED</pre>
</div>
</div>
<div class="paragraph">
<p>Sure, I&#8217;ll just <code>rm</code> them. <code>arc diff</code> asks me a few questions and for some info, which is all easy
to fill in, and finally gives me a <a href="https://phabricator.haskell.org/D1219">URL</a> for my revision!
Hooray!</p>
</div>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2015-09-05 01:31:06 PDT
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment