<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=iso-8859-1">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@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;}
 /* Style Definitions */
 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
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
 /* List Definitions */
 @list l0
        {mso-list-id:1144201459;
        mso-list-type:hybrid;
        mso-list-template-ids:1217565398 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
</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=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I&#8217;ve been away.  I hope others will reply to this thread
too; whatever you decide will end up in TH indefinitely.  I know that Roman is
interested in this.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='font-size:11.0pt;font-family:Symbol;color:#1F497D'><span
style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>You focus just on type families in class declarations (which is
indeed where associated types started).  But I suggest you also allow them <b>at
top level</b>, as GHC does using the syntax<o:p></o:p></span></p>

<p class=MsoListParagraph style='margin-left:72.0pt'><span style='font-size:
11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>type family T a :: *<o:p></o:p></span></p>

<p class=MsoListParagraph><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Indeed, since you propose to add to Dec, that&#8217;ll happen
automatically.  But perhaps &#8220;</span>AssocTySynKindD&#8221; is not a good
name. Perhaps &#8220;TySynFamilyD&#8221;?<o:p></o:p></p>

<p class=MsoListParagraph><o:p>&nbsp;</o:p></p>

<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='font-family:Symbol'><span style='mso-list:Ignore'>·<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>GHC uses<o:p></o:p></p>

<p class=MsoListParagraph style='margin-left:72.0pt'>type instance T [a] = Tree
a<o:p></o:p></p>

<p class=MsoNormal style='margin-left:36.0pt'>as the way to add an equation to
the definition of T.  So perhaps &#8220;TySynInstance&#8221; rather than &#8220;AssocTySynD&#8221;?<o:p></o:p></p>

<p class=MsoListParagraph><o:p>&nbsp;</o:p></p>

<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='font-family:Symbol'><span style='mso-list:Ignore'>·<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>I agree that it&#8217;d be good to do data type/newtype
families at the same time.  Roman needs this.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='font-size:11.0pt;font-family:Symbol;color:#1F497D'><span
style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Your proposal for kinds looks fine.<o:p></o:p></span></p>

<p class=MsoListParagraph><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Simon<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</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 #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"'> haskell-cafe-bounces@haskell.org
[mailto:haskell-cafe-bounces@haskell.org] <b>On Behalf Of </b>José Pedro
Magalhães<br>
<b>Sent:</b> 11 November 2008 11:11<br>
<b>To:</b> Haskell Cafe<br>
<b>Subject:</b> Re: [Haskell-cafe] Proposal for associated type synonyms in
Template Haskell<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>Hello Thomas,<br>
<br>
I see this is a proposal for a partial implementation of #1673 (<a
href="http://hackage.haskell.org/trac/ghc/ticket/1673" target="_blank">http://hackage.haskell.org/trac/ghc/ticket/1673</a>).
Maybe it would be good if the remaining syntax (associated datatypes and type
families) would also be defined and implemented in TH. Or maybe there isn't
much demand for this?...<br>
<br>
<br>
Cheers,<br>
Pedro<o:p></o:p></p>

<div>

<p class=MsoNormal>On Wed, Nov 5, 2008 at 15:57, Thomas van Noort &lt;<a
href="mailto:thomas@cs.ru.nl" target="_blank">thomas@cs.ru.nl</a>&gt; wrote:<o:p></o:p></p>

<p class=MsoNormal>Hello,<br>
<br>
Recently, we released a library on Hackage for generic rewriting (package
&quot;rewriting&quot; if you are curious). The user of the library is expected
to define type class instances to enable rewriting on his or her own datatypes.
As these instances follow the datatype declarations closely, we tried to generate
the instances using Template Haskell. Unfortunately, associated type synonyms
are not yet supported by TH.<br>
<br>
After a presentation at the WGP'08, Simon encouraged us to write a proposal
about adding associated type synonyms to TH, so that it can be added to GHC.
So, here is our proposal.<br>
<br>
The TH AST must allow 1) kind declarations of associated type synonyms<br>
in class declarations and 2) their definitions in instance declarations. For
example,<br>
<br>
class Foo a where<br>
&nbsp;type Bar a :: *<br>
<br>
instance Foo Int where<br>
&nbsp;type Bar Int = String<br>
<br>
The TH library defines a datatype Dec which contains a constructor for class
declarations and instance declarations:<br>
<br>
data Dec<br>
= ...<br>
| ClassD Cxt Name [Name] [FunDep] [Dec]<br>
| InstanceD Cxt Type [Dec]<br>
&nbsp;...<br>
<br>
1) Associated type synonym kind declarations<br>
<br>
We suggest to add a constructor to the Dec type:<br>
<br>
&nbsp;...<br>
| AssocTySynKindD Name [Name] (Maybe Kind)<br>
&nbsp;...<br>
<br>
assocTySynKindD :: Name -&gt; [Name] -&gt; Maybe KindQ -&gt; DecQ<br>
<br>
The first field is the name of the associated type synonym, the second field is
a list of type variables, and the third field is an optional kind. Since kinds
are not yet defined in TH, we have to add some kind of kind definition (pun
intended):<br>
<br>
data Kind<br>
= StarK<br>
| ArrowK Kind Kind<br>
<br>
type KindQ = Q Kind<br>
starK :: KindQ<br>
arrowK :: KindQ -&gt; KindQ -&gt; KindQ<br>
<br>
We explicitly choose not to reuse the Type type to define kinds (i.e., type
Kind = Type as in GHC) since we think a separation between the two worlds is
much clearer to the users of TH.<br>
<br>
2) Associated type synonym definitions<br>
<br>
We suggest to add another constructor to the Dec type:<br>
<br>
&nbsp;...<br>
| AssocTySynD Name [Type] Type<br>
&nbsp;...<br>
<br>
assocTySynD :: Name -&gt; [TypeQ] -&gt; TypeQ -&gt; DecQ<br>
<br>
The first field is the name of the type synonym, the second field is a list of
type arguments, and the third field is the body of the type synonym.<br>
<br>
We would like to hear your comments to this proposal.<br>
<br>
Regards,<br>
Thomas<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</div>

</body>

</html>