<html v="urn:schemas-microsoft-com:vml" o="urn:schemas-microsoft-com:office:office" w="urn:schemas-microsoft-com:office:word" m="http://schemas.microsoft.com/office/2004/12/omml"><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /><meta name="Generator" content="Microsoft Word 14 (filtered medium)" /><style><!--
/* Font Definitions */
@font-face
 {font-family:"MS Mincho";
 panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
 {font-family:"MS Mincho";
 panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
 {font-family:Tahoma;
 panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
 {font-family:"\@MS Mincho";
 panose-1:2 2 6 9 4 2 5 8 3 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.MsoAcetate, li.MsoAcetate, div.MsoAcetate
 {mso-style-priority:99;
 mso-style-link:"Balloon Text Char";
 margin:0cm;
 margin-bottom:.0001pt;
 font-size:8.0pt;
 font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
 {mso-style-name:"Balloon Text Char";
 mso-style-priority:99;
 mso-style-link:"Balloon Text";
 font-family:"Tahoma","sans-serif";}
span.EmailStyle19
 {mso-style-type:personal;
 font-family:"Calibri","sans-serif";
 color:windowtext;}
span.EmailStyle20
 {mso-style-type:personal-reply;
 font-family:"Calibri","sans-serif";
 color:#1F497D;}
.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></head><body lang="EN-GB" link="blue" vlink="purple"><p dir="ltr">It sounds a bit like you're under the impression that * is some sort of wildcard for kinds, when you talk about "named kinds vs unnamed kinds". That's not correct; * IS a "named kind", and its name is *. Nat is distinct from * in exactly the same way that Bool is distinct from ().</p>
<p dir="ltr">Kind variables are exactly what you want, if you need to be able to handle both * -> * and Nat -> *.</p>
<p dir="ltr">The reasons for not always using (k -> *) -> Constraint rather than (* -> *) -> Constraint are the same as the reason for not making everything polymorphic at the type level; sometimes you need the assumption that your k really is *, and sometimes you just don't need the polymorphism and prefer to keep it simple (especially as kind variables require extensions).</p>
<br><br><div class="gmail_quote">On 6 May 2015 11:06:24 pm AEST, "Nicholls, Mark" <nicholls.mark@vimn.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">




<!--[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]-->


<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">lets try it the other way around
<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><p> </p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">> instance Foo' SNat1 where<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">>   type Bar' SNat1 = Z1<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">>   bar' = SZ1<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><p> </p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">that works!<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><p> </p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">(my language will be wrong here…but the jist is)<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><p> </p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">So in some something of kind <p>
</p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">“*->*” is substitutable for a parameter of kind “k -> *”<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">“Nat->*” is substitutable for a parameter of kind “k -> *”<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">“*->*” is substitutable for a parameter of kind “* -> *”<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">“Nat->*” is NOT substitutable for a parameter of kind “* -> *”<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><p> </p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Hmmmm<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><p> </p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">So why would I ever want to define a type class of kind<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">(* -> *) -> Constraint<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Instead of <p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">(k -> *) -> Constraint<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><p> </p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">?<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><p> </p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I think I don’t completely understand what’s going on.<p></p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><p> </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 #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Nicholls, Mark
<br />
<b>Sent:</b> 06 May 2015 1:02 PM<br />
<b>To:</b> haskell-cafe@haskell.org<br />
<b>Subject:</b> minor confusion over kinds....<p></p></span></p>
</div>
</div>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">And what “*” means as opposed to other things e.g. an explicit name "Nat" or a kind variable "k"</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> {-# LANGUAGE DataKinds #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE ExplicitForAll #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE FlexibleContexts #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE FlexibleInstances #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE GADTs #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE MultiParamTypeClasses #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE PolyKinds #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE StandaloneDeriving #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE TypeFamilies #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE TypeOperators #-}</p><p></p>
<p class="MsoNormal">> {-# LANGUAGE UndecidableInstances #-}</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">what I want is a typeclass with instances of type level Naturals</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">here's the class, the parameter is of kind (* -> *) i.e. a is some sort of wrapper that maps from types to values</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> class Foo (a :: * -> *) where</p><p></p>
<p class="MsoNormal">>   type Bar a</p><p></p>
<p class="MsoNormal">>   bar :: a (Bar a)</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">lets ignore DataKinds define Zero and Succ as distinct types</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">uninhabited...but of kind "*" and "k -> *"</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> data Z1</p><p></p>
<p class="MsoNormal">> data S1 nat</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">SNat1 :: * -> *</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> data SNat1 a where</p><p></p>
<p class="MsoNormal">>   SZ1 :: SNat1 Z1</p><p></p>
<p class="MsoNormal">>   SS1 :: SNat1 a -> SNat1 (S1 a)</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">off we go...</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> instance Foo SNat1 where</p><p></p>
<p class="MsoNormal">>   type Bar SNat1 = Z1</p><p></p>
<p class="MsoNormal">>   bar = SZ1</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">now lets do it the datakind route</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> data Nat where</p><p></p>
<p class="MsoNormal">>   Z :: Nat</p><p></p>
<p class="MsoNormal">>   S :: Nat -> Nat</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">ahhh...SNat is of kind "Nat -> *"</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> data SNat a where</p><p></p>
<p class="MsoNormal">>   SZ :: SNat 'Z</p><p></p>
<p class="MsoNormal">>   SS :: SNat a -> SNat ('S a)</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">so I cant make it an instance of the same type class</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">"The first argument of ‘Foo’ should have kind ‘* -> *’,</p><p></p>
<p class="MsoNormal">      but ‘SNat’ has kind ‘Nat -> *’</p><p></p>
<p class="MsoNormal">    In the instance declaration for ‘Foo SNat’"</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> --instance Foo SNat where</p><p></p>
<p class="MsoNormal">> --  type Bar SNat = 'Z</p><p></p>
<p class="MsoNormal">> --  bar = SZ</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">unless I redefine my class (which seems a bit silly)</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> class Foo' (a :: k -> *) where</p><p></p>
<p class="MsoNormal">>   type Bar' a :: k</p><p></p>
<p class="MsoNormal">>   bar' :: a (Bar' a)</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">now it works.</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">> instance Foo' SNat where</p><p></p>
<p class="MsoNormal">>   type Bar' SNat = 'Z</p><p></p>
<p class="MsoNormal">>   bar' = SZ</p><p></p>
<p class="MsoNormal"></p><p> </p>
<p class="MsoNormal">clearly named kinds (?) are somehow distinct from unnames ones?</p><p></p>
</div>
</div>
<p><br /><br />CONFIDENTIALITY NOTICE<br /><br />This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further use or dissemination is prohibited.<br /><br />While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data.<br /><br />Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take appropriate measures to minimise these risks when e-mailing us.<br /><br />MTV Networks International, MTV Networks UK & Ireland,
Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV Networks Europe.  MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc.  Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT.<br /></p>

<p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre class="k9mail"><hr /><br />Haskell-Cafe mailing list<br />Haskell-Cafe@haskell.org<br /><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br /></pre></blockquote></div></body></html>