<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} .ms-cui-menu {background-color:#ffffff;border:1px rgb(171, 171, 171) solid;font-family:'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif;font-size:11pt;color:rgb(51, 51, 51);} .ms-cui-menusection-title {display:none;} .ms-cui-ctl {vertical-align:text-top;text-decoration:none;color:rgb(51, 51, 51);} .ms-cui-ctl-on {background-color:rgb(223, 237, 250);opacity: 0.8;} .ms-cui-img-cont-float {display:inline-block;margin-top:2px} .ms-cui-smenu-inner {padding-top:0px;} .ms-owa-paste-option-icon {margin: 2px 4px 0px 4px;vertical-align:sub;padding-bottom: 2px;display:inline-block;} .ms-rtePasteFlyout-option:hover {background-color:rgb(223, 237, 250) !important;opacity:1 !important;} .ms-rtePasteFlyout-option {padding:8px 4px 8px 4px;outline:none;} .ms-cui-menusection {float:left; width:85px;height:24px;overflow:hidden}.wf {speak:none; font-weight:normal; font-variant:normal; text-transform:none; -webkit-font-smoothing:antialiased; vertical-align:middle; display:inline-block;}.wf-family-owa {font-family:'o365Icons'}@font-face {  font-family:'o365IconsIE8';  src:url('prem/15.0.913.22/resources/styles/office365icons.ie8.eot?#iefix') format('embedded-opentype'),         url('prem/15.0.913.22/resources/styles/office365icons.ie8.woff') format('woff'),         url('prem/15.0.913.22/resources/styles/office365icons.ie8.ttf') format('truetype');  font-weight:normal;  font-style:normal;}@font-face {  font-family:'o365IconsMouse';  src:url('prem/15.0.913.22/resources/styles/office365icons.mouse.eot?#iefix') format('embedded-opentype'),         url('prem/15.0.913.22/resources/styles/office365icons.mouse.woff') format('woff'),         url('prem/15.0.913.22/resources/styles/office365icons.mouse.ttf') format('truetype');  font-weight:normal;  font-style:normal;}.wf-family-owa {font-family:'o365IconsMouse'}.ie8 .wf-family-owa {font-family:'o365IconsIE8'}.ie8 .wf-owa-play-large:before {content:'\e254';}.notIE8 .wf-owa-play-large:before {content:'\e054';}.ie8 .wf-owa-play-large {color:#FFFFFF/*$WFWhiteColor*/;}.notIE8 .wf-owa-play-large {border-color:#FFFFFF/*$WFWhiteColor*/; width:1.4em; height:1.4em; border-width:.1em; border-style:solid; border-radius:.8em; text-align:center; box-sizing:border-box; -moz-box-sizing:border-box; padding:0.1em; color:#FFFFFF/*$WFWhiteColor*/;}.ie8 .wf-size-play-large {width:40px; height:40px; font-size:30px}.notIE8 .wf-size-play-large {width:40px; height:40px; font-size:30px}
<!--
p
        {margin-top:0;
        margin-bottom:0}
.ms-cui-menu
        {background-color:#ffffff;
        border:1px rgb(171,171,171) solid;
        font-family:'Segoe UI WPC','Segoe UI',Tahoma,'Microsoft Sans Serif',Verdana,sans-serif;
        font-size:11pt;
        color:rgb(51,51,51)}
.ms-cui-ctl
        {vertical-align:text-top;
        text-decoration:none;
        color:rgb(51,51,51)}
.ms-cui-ctl-on
        {background-color:rgb(223,237,250)}
.ms-cui-img-cont-float
        {display:inline-block;
        margin-top:2px}
.ms-cui-smenu-inner
        {padding-top:0px}
.ms-owa-paste-option-icon
        {margin:2px 4px 0px 4px;
        vertical-align:sub;
        padding-bottom:2px;
        display:inline-block}
.ms-rtePasteFlyout-option
        {padding:8px 4px 8px 4px;
        outline:none}
.ms-cui-menusection
        {float:left;
        width:85px;
        height:24px;
        overflow:hidden}
.wf
        {speak:none;
        font-weight:normal;
        font-variant:normal;
        text-transform:none;
        vertical-align:middle;
        display:inline-block}
.wf-family-owa
        {font-family:'o365Icons'}
@font-face
        {font-family:'o365IconsIE8';
        font-weight:normal;
        font-style:normal}
@font-face
        {font-family:'o365IconsMouse';
        font-weight:normal;
        font-style:normal}
.wf-family-owa
        {font-family:'o365IconsMouse'}
.ie8 .wf-family-owa
        {font-family:'o365IconsIE8'}
.notIE8 .wf-owa-play-large
        {border-color:#FFFFFF;
        width:1.4em;
        height:1.4em;
        border-width:.1em;
        border-style:solid;
        text-align:center;
        padding:0.1em;
        color:#FFFFFF}
.ie8 .wf-size-play-large
        {width:40px;
        height:40px;
        font-size:30px}
.notIE8 .wf-size-play-large
        {width:40px;
        height:40px;
        font-size:30px}
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:"Segoe UI"}
@font-face
        {font-family:o365IconsIE8}
@font-face
        {font-family:o365IconsMouse}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
a:link, span.MsoHyperlink
        {color:#0563C1;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:#954F72;
        text-decoration:underline}
p.Code, li.Code, div.Code
        {margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Courier New";
        color:#1F497D}
span.CodeChar
        {font-family:"Courier New";
        color:#1F497D}
p.ms-cui-menu, li.ms-cui-menu, div.ms-cui-menu
        {margin:0cm;
        margin-bottom:.0001pt;
        background:white;
        border:none;
        padding:0cm;
        font-size:11.0pt;
        font-family:"Segoe UI","sans-serif";
        color:#333333}
p.ms-cui-menusection-title, li.ms-cui-menusection-title, div.ms-cui-menusection-title
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
p.ms-cui-ctl, li.ms-cui-ctl, div.ms-cui-ctl
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:#333333}
p.ms-cui-ctl-on, li.ms-cui-ctl-on, div.ms-cui-ctl-on
        {margin:0cm;
        margin-bottom:.0001pt;
        background:#DFEDFA;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
p.ms-cui-img-cont-float, li.ms-cui-img-cont-float, div.ms-cui-img-cont-float
        {margin-top:1.5pt;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
p.ms-cui-smenu-inner, li.ms-cui-smenu-inner, div.ms-cui-smenu-inner
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
p.ms-owa-paste-option-icon, li.ms-owa-paste-option-icon, div.ms-owa-paste-option-icon
        {margin-top:1.5pt;
        margin-right:3.0pt;
        margin-bottom:0cm;
        margin-left:3.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        vertical-align:sub}
p.ms-rtepasteflyout-option, li.ms-rtepasteflyout-option, div.ms-rtepasteflyout-option
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
p.ms-cui-menusection, li.ms-cui-menusection, div.ms-cui-menusection
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
p.wf, li.wf, div.wf
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
p.wf-family-owa, li.wf-family-owa, div.wf-family-owa
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:o365IconsMouse}
p.wf-owa-play-large, li.wf-owa-play-large, div.wf-owa-play-large
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
p.wf-size-play-large, li.wf-size-play-large, div.wf-size-play-large
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
p.wf-family-owa1, li.wf-family-owa1, div.wf-family-owa1
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:o365IconsIE8}
p.wf-owa-play-large1, li.wf-owa-play-large1, div.wf-owa-play-large1
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:white}
p.wf-owa-play-large2, li.wf-owa-play-large2, div.wf-owa-play-large2
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:center;
        border:none;
        padding:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:white}
p.wf-size-play-large1, li.wf-size-play-large1, div.wf-size-play-large1
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:22.5pt;
        font-family:"Times New Roman","serif"}
p.wf-size-play-large2, li.wf-size-play-large2, div.wf-size-play-large2
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:22.5pt;
        font-family:"Times New Roman","serif"}
span.EmailStyle38
        {font-family:"Calibri","sans-serif";
        color:#1F497D}
.MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:72.0pt 72.0pt 72.0pt 72.0pt}
-->
--></style>
</head>
<body dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>PS.<br>
</p>
<p><br>
</p>
<p>Unique also looks like a case where Ints are used and (>= 0) is asserted. Can these cases be converted to Word as per earlier discussions?<br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<div dir="ltr" style="color: rgb(40, 40, 40);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Van:</b> p.k.f.holzenspies@utwente.nl <p.k.f.holzenspies@utwente.nl><br>
<b>Verzonden:</b> maandag 18 augustus 2014 15:49<br>
<b>Aan:</b> simonpj@microsoft.com; ghc-devs@haskell.org<br>
<b>Onderwerp:</b> RE: Unique as special boxing type & hidden constructors</font>
<div> </div>
</div>
<div>
<div style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Dear Simon, et al,<br>
</p>
<p><br>
</p>
<p>Looking at Unique, there are a few more design choices that may be outdated, and since I'm polishing things now, anyway, I figured I could update it on more fronts.<br>
</p>
<p><br>
</p>
<p>1) There is a #ifdef define(__GLASGOW_HASKELL__), which confused me somewhat. Similar things occur elsewhere in the code. Isn't the assumption that GHC is being used? Is this old portability stuff that may be removed?<br>
</p>
<p><br>
</p>
<p>2) Uniques are produced from a Char and an Int. The function to build Uniques (mkUnique) is not exported, according to the comments, so as to see all characters used. Access to these different "classes" of Uniques is given through specialised mkXXXUnique
 functions. Does anyone have a problem with something like:<br>
</p>
<p><br>
</p>
<p>> data UniqueClass<br>
</p>
<p>>   = UniqDesugarer<br>
</p>
<p>>   | UniqAbsCFlattener<br>
</p>
<p>>   | UniqSimplStg<br>
</p>
<p>>   | UniqNativeCodeGen<br>
</p>
<p>>   ...<br>
</p>
<p><br>
</p>
<p>and a public (i.e. exported) function:<br>
</p>
<p><br>
</p>
<p>> mkUnique :: UniqueClass -> Int -> Unique<br>
</p>
<p><br>
</p>
<p>? The benefit of this would be to have more (to my taste) self-documenting code and a greater chance that documentation is updated (the list of "unique supply characters" in the comments is currently outdated).<br>
</p>
<p><br>
</p>
<p>3) Is there a reason for having functions implementing class-methods to be exported? In the case of Unique, there is pprUnique and:<br>
</p>
<p><br>
</p>
<p>> instance Outputable Unique where<br>
</p>
<p>>   ppr = pprUnique<br>
</p>
<p><br>
</p>
<p>Here pprUnique is exported and it is used in quite a few places where it's argument is unambiguously a Unique (so it's not to force the type) *and* "ppr" is used for all kinds of other types. I'm assuming this is an old choice making things marginally faster,
 but I would say cleaning up the API / namespace would now outweigh this margin.<br>
</p>
<p>​<br>
</p>
<p>I will also be adding Haddock-comments, so when this is done, a review would be most welcome (I'll also be doing some similar transformations to other long-since-untouched-code).<br>
</p>
<p><br>
</p>
<p>Regards,<br>
</p>
<p>Philip<br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<div style="color:rgb(40,40,40)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Van:</b> Simon Peyton Jones <simonpj@microsoft.com><br>
<b>Verzonden:</b> maandag 18 augustus 2014 00:11<br>
<b>Aan:</b> Holzenspies, P.K.F. (EWI); ghc-devs@haskell.org<br>
<b>Onderwerp:</b> RE: Unique as special boxing type & hidden constructors</font>
<div> </div>
</div>
<div>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Re (1) I think this is a historical.  A newtype wrapping an Int should be fine.  I’d be ok with that change.
</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Re (2), I think your question is: why does module Unique export the data type Unique abstractly, rather than exporting both the data type and its constructor. 
 No deep reason here, but it guarantees that you can only *<b>make</b>* a unique from an Int by calling ‘mkUniqueGrimily’, which signals clearly that something fishy is going on.  And rightly so!</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Simon</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></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" style="font-size:11.0pt; font-family:"Calibri","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif""> ghc-devs [mailto:ghc-devs-bounces@haskell.org]
<b>On Behalf Of </b>p.k.f.holzenspies@utwente.nl<br>
<b>Sent:</b> 15 August 2014 11:53<br>
<b>To:</b> ghc-devs@haskell.org<br>
<b>Subject:</b> Unique as special boxing type & hidden constructors</span></p>
</div>
</div>
<p class="MsoNormal"> </p>
<div>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">Dear all,</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black"> </span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">I'm working with Alan to instantiate everything for Data.Data, so that we can do better SYB-traversals (which should also help newcomers significantly to get into the
 GHC code base). Alan's looking at the AST types, I'm looking at the basic types in the compiler.</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black"> </span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">Right now, I'm looking at Unique and two questions come up:</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black"> </span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">> data Unique = MkUnique FastInt</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black"> </span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">1) As someone already commented: Is there a specific reason (other than history) that this isn't simply a newtype around an Int? If we're boxing anyway, we may as well
 use the default Int boxing and newtype-coerce to the specific purpose of Unique, no?</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black"> </span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">2) As a general question for GHC hacking style; what is the reason for hiding the constructors in the first place?</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black"> </span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">I understand about abstraction and there are reasons for hiding, but there's a "public GHC API" and then there are all these modules that people can import at their own
 peril. Nothing is guaranteed about their consistency from version to version of GHC. I don't really see the point about hiding constructors (getting in the way of automatically deriving things) and then giving extra functions like (in the case of Unique):</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black"> </span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">> getKeyFastInt (MkUnique x) = x</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">> mkUniqueGrimily x = MkUnique (iUnbox x)</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black"> </span></p>
<p style="margin-bottom:12.0pt; background:white"><span style="font-family:"Calibri","sans-serif"; color:black">I would propose to just make Unique a newtype for an Int and making the constructor visible.</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">Regards,</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black">Philip</span></p>
<p style="background:white"><span style="font-family:"Calibri","sans-serif"; color:black"> </span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>