<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.Code, li.Code, div.Code
        {mso-style-name:Code;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:14.2pt;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        font-weight:bold;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
.MsoPapDefault
        {mso-style-type:export-only;
        margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Dear GHC developers and friends<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I would like to urge you to review, and help to improve, this patch.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Adding linear types to Haskell is a big change that touches a lot of code.   That makes the patch a bit daunting.  But GHC is
<i>supposed</i> to be a laboratory for advanced stuff, and this is a great example.   The authors (esp Arnaud, Krzysztof, and Jean-Philippe) have invested a
<i>lot</i> of effort in the <a href="https://www.microsoft.com/en-us/research/publication/linear-haskell-practical-linearity-higher-order-polymorphic-language/">
paper</a>, the <a href="https://github.com/tweag/ghc-proposals/blob/linear-types2/proposals/0000-linear-types.rst">
proposal</a>, and now the <a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/852">
patch</a>.  And lots of people are interested in the result.  In short, we owe it to them to give their work serious attention.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">But please don’t think “oh, I’m not qualified and anyway Simon will look at it”.  I will, of course, but like you I’m too busy.  And a far-reaching change like this needs many eyes.   Moreover, assuming it’s committed, this code will be
 us for a long time;       most future developers will be no better qualified than you, but they’ll still have to deal with it!  So if you get bamboozled, make constructive suggestions about what sorts of Notes or explanation would un-bamboozle you.  Don’t
 just assume you are too stupid; that way likes an un-maintainable code base.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So please jump in there.  This is  your compiler.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Simon<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> ghc-devs <ghc-devs-bounces@haskell.org>
<b>On Behalf Of </b>Spiwack, Arnaud<br>
<b>Sent:</b> 03 May 2019 10:52<br>
<b>To:</b> GHC developers <ghc-devs@haskell.org><br>
<b>Cc:</b> Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io><br>
<b>Subject:</b> Linear Types: ready for review<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
Dear GHC devs,<br>
<br>
The linear types patch is ready for review!<br>
<a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/852">https://gitlab.haskell.org/ghc/ghc/merge_requests/852</a><br>
<br>
It is a fairly large patch (~3500loc of change to the compiler itself,<br>
with a ~2000loc diff on the testsuite). And it's gone through a lot of<br>
redesigns. The issue with a patch like this is that it is rather easy<br>
to get reviewer fatigue and just let things through.<br>
<br>
This is why I want to encourage as many people as possible to give a<br>
thorough review of part of the patch. Even 15 minutes of your time<br>
would be tremendously helpful!<br>
<br>
Here is what I suggest: pick a part of the compiler you know well, and<br>
look at how the patch affects it. If there is something that you don't<br>
understand let us know! Either in the MR discussion, or send an email<br>
to Krzysztof and me. We will answer and update the documentation.<br>
<br>
---<br>
<br>
If you are still unsure where to start, here are what we consider to<br>
be the main entry points to the patch:<br>
<br>
- The file Multiplicity, which defines type Mult = Type, the Scaled<br>
  type and functions unrestricted, linear, pattern synonyms One and<br>
  Omega, quick submultiplicity test submult<br>
- The change to FunTy and new mkFunTy in TyCoRep, where the<br>
  multiplicity argument is added<br>
- The change to funTyCon in TysPrim<br>
- The new unrestrictedFunTyCon and multiplicityTy in TysWiredIn<br>
- Var has now a new field varMult; functions such as<br>
  updateVarTypeAndMult can be used to update multiplicity (e.g. when<br>
  zonking). In Core, the multiplicity of a lambda is indicated by its<br>
  varMult; multiplicity of a case expression is indicated by varMult<br>
  of the case binder.<br>
- The functions mkDataConRepXin basicTypes/MkId and and<br>
  dataConUserType function in basicTypes/DataCon, which are adding<br>
  multiplicity variables to constructors. The change to wrapper_reqd<br>
  means that all data constructors have a wrapper now.<br>
- The file UsageEnv defines a map from a variable to its multiplicity,<br>
  used when typechecking<br>
- Calls to submult and tcSubMult, which guide multiplicity checking in<br>
  the type checker<br>
- ensureSubMult and its calls, which guide multiplicity checking in<br>
  Lint<br>
  <br>
---<br>
<br>
A more in-depth documentation and overview of the patch is on the<br>
wiki: <a href="https://gitlab.haskell.org/ghc/ghc/wikis/linear-types/implementation">
https://gitlab.haskell.org/ghc/ghc/wikis/linear-types/implementation</a><br>
<br>
It has a table of contents which you can use as yet another way to<br>
find a starting point.<br>
<br>
---<br>
<br>
If any of these resources are lacking, let us know too! We'll make<br>
sure to update them.<br>
<br>
---<br>
<br>
Finally, I'll be holding a project session on Linear Types in ZüriHac<br>
next month. Where we can have further, more in-depth discussion about<br>
the patch, finalise its documentation, and address outstanding<br>
requests from reviews.<br>
<br>
<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>