<div dir="ltr"><div class="gmail_quote">On Wed, Aug 20, 2014 at 1:47 PM,  <span dir="ltr"><<a href="mailto:p.k.f.holzenspies@utwente.nl" target="_blank">p.k.f.holzenspies@utwente.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">






<div dir="ltr">
<div style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Methinks a lot of the former performance considerations in Unique are out-dated (as per earlier discussion; direct use of unboxed ints etc.).<br>
</p>
<p><br>
</p>
<p>An upside of using an ADT for the types of uniques is that we don't actually need to reserve 8 bits for a Char (which is committing to neither the actual number of classes, nor the "nature" of real Chars in Haskell). Instead, we can make a bitmask dependent
 on the number of classes that we actually use and stick the tag on the least-significant side of the Unique, as opposed to the most-significant (as we do now).</p>
<p><br>
</p>
<p>We want to keep things working on 32-bits, but maybe a future of parallel builds is only for 64-bits. In this case, I would suggest that the 64-bit-case looks like this:<br>
</p>
<p><br>
</p>
<p><thread_id_bits:8> <unique_id_bits:56-X> <tag_bits:X><br>
</p>
<p><br></p></div></div></blockquote><div><br></div><div>Is the thread id deterministic between runs?  If not, please do not use this layout.  I remember vaguely Unique being relevant to ghc not having deterministic builds, my most wanted ghc feature:<br>

<br><a href="https://ghc.haskell.org/trac/ghc/ticket/4012">https://ghc.haskell.org/trac/ghc/ticket/4012</a><br><br></div><div>Alexander<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<div dir="ltr"><div style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif"><p>
</p>
<p>whereas the 32-bit case simply has<br>
</p>
<p><br>
</p>
<p><unique_id_bits:32-X> <tag_bits:X></p>
<p><br>
</p>
<p>Where X is dependent on the size of the UniqueClass-sum-type (to be introduced). This would be CPP-magic'd using ​WORD_SIZE_IN_BITS.</p>
<p><br>
</p>
<p>Ph.</p>
<p><br>
</p>
<p><br>
<br>
</p>
<p><br>
</p>
<p><br>
</p>
<div style="color:rgb(40,40,40)">
<hr style="display:inline-block;width:98%">
<div dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><div class=""><b>From:</b> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>


</div><b>Sent:</b> 20 August 2014 13:01<div><div class="h5"><br>
<b>To:</b> Holzenspies, P.K.F. (EWI); <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> RE: Unique as special boxing type & hidden constructors</div></div></font>
<div> </div>
</div><div><div class="h5">
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:rgb(31,73,125)">Sounds like a good idea to me.   Would need to think about making sure that it all still worked, somehow, on 32 bit.</span></p>


<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:rgb(31,73,125)">S</span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span></p>
<div style="border-width:medium medium medium 1.5pt;border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color blue;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(225,225,225) -moz-use-text-color -moz-use-text-color;padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:11pt;font-family:"Calibri","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:11pt;font-family:"Calibri","sans-serif"" lang="EN-US"> <a href="mailto:p.k.f.holzenspies@utwente.nl" target="_blank">p.k.f.holzenspies@utwente.nl</a> [mailto:<a href="mailto:p.k.f.holzenspies@utwente.nl" target="_blank">p.k.f.holzenspies@utwente.nl</a>]
<br>
<b>Sent:</b> 20 August 2014 11:31<br>
<b>To:</b> Simon Peyton Jones; <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> RE: Unique as special boxing type & hidden constructors</span></p>
</div>
</div>
<p class="MsoNormal"> </p>
<div>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Dear Simon, et al,</span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">I seem to recall that the Unique(Supply) was an issue in parallelising GHC itself. There's a comment in the code (signed JSM) that there aren't any 64-bit bugs, if we
 have at least 32-bits for Ints and Chars fit in 8 characters. Then, there's bitmasks like 0x00FFFFFF to separate the "Int-part" from the "Char-part".</span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">I was wondering; if we move Uniques to 64 bits, but use the top 16 (instead of the current 8) for *both* the tag (currently a Char, soon an sum-type) and the threadId
 of the supplying thread of a Unique, would that help?</span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Regards,</span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Philip</span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span></p>
<div>
<div class="MsoNormal" style="text-align:center;background:none repeat scroll 0% 0% white" align="center">
<span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)">
<hr align="center" size="2" width="98%">
</span></div>
<div>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><b><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:black">From:</span></b><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:black"> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>


<b>Sent:</b> 18 August 2014 23:29<br>
<b>To:</b> Holzenspies, P.K.F. (EWI); <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> RE: Unique as special boxing type & hidden constructors</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)">
</span></p>
<div>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"> </span></p>
</div>
</div>
<div>
<div>
<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">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?</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">I think so, unless others yell to the contrary.</span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">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:</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">> data UniqueClass</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   = UniqDesugarer</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   | UniqAbsCFlattener</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   | UniqSimplStg</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   | UniqNativeCodeGen</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   ...</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">OK by me</span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">3) Is there a reason for having functions implementing class-methods to be exported? In the case of Unique, there is pprUnique and:</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">> instance Outputable Unique where</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-left:36pt;background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   ppr = pprUnique</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">Please don’t change this.  If you want to change how pretty-printing of uniques works, and want to find all the call sites of pprUnique,
 it’s FAR easier to grep for pprUnique than to search for  all calls of ppr, and work out which are at type Unique! 
</span><span style="color:rgb(40,40,40)"></span></p>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">(In my view) it’s usually much better not to use type classes unless you actually need overloading.</span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">Simon</span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<div style="border-width:medium medium medium 1.5pt;border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color blue;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(225,225,225) -moz-use-text-color -moz-use-text-color;padding:3pt 0cm 0cm">
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><b><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(40,40,40)" lang="EN-US">From:</span></b><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(40,40,40)" lang="EN-US">
<a href="mailto:p.k.f.holzenspies@utwente.nl" target="_blank">p.k.f.holzenspies@utwente.nl</a> [<a href="mailto:p.k.f.holzenspies@utwente.nl" target="_blank">mailto:p.k.f.holzenspies@utwente.nl</a>]
<br>
<b>Sent:</b> 18 August 2014 14:50<br>
<b>To:</b> Simon Peyton Jones; <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> RE: Unique as special boxing type & hidden constructors</span><span style="color:rgb(40,40,40)"></span></p>
</div>
</div>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="color:rgb(40,40,40)"> </span></p>
<div>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Dear Simon, et al,</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">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.</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">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?</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">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:</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">> data UniqueClass</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   = UniqDesugarer</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   | UniqAbsCFlattener</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   | UniqSimplStg</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   | UniqNativeCodeGen</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   ...</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">and a public (i.e. exported) function:</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">> mkUnique :: UniqueClass -> Int -> Unique</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">? 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).</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">3) Is there a reason for having functions implementing class-methods to be exported? In the case of Unique, there is pprUnique and:</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">> instance Outputable Unique where</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">>   ppr = pprUnique</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">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.</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">​</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">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).</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Regards,</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Philip</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<div>
<div class="MsoNormal" style="text-align:center;background:none repeat scroll 0% 0% white" align="center">
<span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)">
<hr align="center" size="3" width="98%">
</span></div>
<div>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><b><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:black">Van:</span></b><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:black"> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>


<b>Verzonden:</b> maandag 18 augustus 2014 00:11<br>
<b>Aan:</b> Holzenspies, P.K.F. (EWI); <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Onderwerp:</b> RE: Unique as special boxing type & hidden constructors</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)">
</span><span style="color:rgb(40,40,40)"></span></p>
<div>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"> </span><span style="color:rgb(40,40,40)"></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">Re (1) I think this is a historical.  A newtype wrapping an Int should be fine.  I’d be ok with that change.
</span><span style="color:rgb(40,40,40)"></span></p>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">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><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">Simon</span><span style="color:rgb(40,40,40)"></span></p>


<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)"> </span><span style="color:rgb(40,40,40)"></span></p>


<div style="border-width:medium medium medium 1.5pt;border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color blue;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(225,225,225) -moz-use-text-color -moz-use-text-color;padding:3pt 0cm 0cm">
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><b><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(40,40,40)" lang="EN-US">From:</span></b><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(40,40,40)" lang="EN-US"> ghc-devs
 [<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">mailto:ghc-devs-bounces@haskell.org</a>]
<b>On Behalf Of </b><a href="mailto:p.k.f.holzenspies@utwente.nl" target="_blank">p.k.f.holzenspies@utwente.nl</a><br>
<b>Sent:</b> 15 August 2014 11:53<br>
<b>To:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Unique as special boxing type & hidden constructors</span><span style="color:rgb(40,40,40)"></span></p>
</div>
</div>
<p class="MsoNormal" style="background:none repeat scroll 0% 0% white"><span style="color:rgb(40,40,40)"> </span></p>
<div>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Dear all,</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% 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><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Right now, I'm looking at Unique and two questions come up:</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">> data Unique = MkUnique FastInt</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% 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><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>
<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% 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><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% 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><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">> getKeyFastInt (MkUnique x) = x</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">> mkUniqueGrimily x = MkUnique (iUnbox x)</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="margin-bottom:12pt;background:none repeat scroll 0% 0% 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><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Regards,</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black">Philip</span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


<p style="background:none repeat scroll 0% 0% white"><span style="font-family:"Calibri","sans-serif";color:black"> </span><span style="font-family:"Calibri","sans-serif";color:rgb(40,40,40)"></span></p>


</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
</div>
</div>

<br>_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/ghc-devs" target="_blank">http://www.haskell.org/mailman/listinfo/ghc-devs</a><br>
<br></blockquote></div><div class="gmail_extra"><br></div></div>