<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;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 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;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
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;
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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 bgcolor="white" lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">Make sure you add the new wired in this to `TysWiredIn.wiredInTyCons`<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></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="color:windowtext">From:</span></b><span lang="EN-US" style="color:windowtext"> ghc-devs <ghc-devs-bounces@haskell.org>
<b>On Behalf Of </b>Jan van Brügge<br>
<b>Sent:</b> 03 April 2019 12:06<br>
<b>To:</b> ghc-devs@haskell.org<br>
<b>Subject:</b> Defining a wired-in type of a different kind<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<pre>Hi,<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>when trying to get familiar with the GHC code base for my Bachelor's<o:p></o:p></pre>
<pre>thesis. I followed the GHC Wiki, especially the case study about the<o:p></o:p></pre>
<pre>bool type.<o:p></o:p></pre>
<pre>Now I wanted to add a new kind and a new type inhabiting this kind<o:p></o:p></pre>
<pre>(without having to expose a data constructor, so without datatype<o:p></o:p></pre>
<pre>promotion).<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>So in TysWiredIn.hs I added the new TyCons and added them to the list of<o:p></o:p></pre>
<pre>wired-in types:<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>-- data Row a b<o:p></o:p></pre>
<pre>rowKindCon :: TyCon<o:p></o:p></pre>
<pre>rowKindCon = pcTyCon rowKindConName Nothing [alphaTyVar, betaTyVar] []<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>rowKind :: Kind<o:p></o:p></pre>
<pre>rowKind = mkTyConTy rowKindCon<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>-- data RNil :: Row a b<o:p></o:p></pre>
<pre>rnilTyCon :: TyCon<o:p></o:p></pre>
<pre>rnilTyCon = mkAlgTyCon rnilTyConName [] rowKind [] Nothing []<o:p></o:p></pre>
<pre>    (mkDataTyConRhs [])<o:p></o:p></pre>
<pre>    (VanillaAlgTyCon (mkPrelTyConRepName rnilTyConName))<o:p></o:p></pre>
<pre>    False<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>rnilTy :: Type<o:p></o:p></pre>
<pre>rnilTy = mkTyConTy rnilTyCon<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>I also added two new empty data decls to ghc-prim, but if I inspect the<o:p></o:p></pre>
<pre>kind of RNil it is not Row, but Type. So I think I am either<o:p></o:p></pre>
<pre>understanding res_kind wrong or I have to do something completely different.<o:p></o:p></pre>
<pre>I am also not sure how to verify that the code in TysWiredIn.hs is<o:p></o:p></pre>
<pre>working at all, from all what I can tell it could just be the<o:p></o:p></pre>
<pre>declarations in ghc-prim that result in what I see in ghci.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Thank you and sorry for my beginner question<o:p></o:p></pre>
<pre>Jan<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
</div>
</div>
</div>
</body>
</html>