On 9/16/07, <b class="gmail_sendername">Mads Lindstrøm</b> &lt;<a href="mailto:mads_lindstroem@yahoo.dk">mads_lindstroem@yahoo.dk</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all<br><br>If I have this type:<br><br>&nbsp;&nbsp;data Foo a b = ...<br><br>and this class<br><br>&nbsp;&nbsp;class Bar (x :: * -&gt; *) where ...<br><br>I can imagine two ways to make Foo an instance of Bar. Either I must<br>&quot;apply&quot; the &#39;a&#39; or the &#39;b&#39; in (Foo a b). Otherwise it will not have the
<br>right kind. To &quot;apply&quot; the &#39;a&#39; I can do:<br><br>&nbsp;&nbsp;instance Bar (Foo a) where ...<br><br>But what if I want to &quot;apply&quot; the &#39;b&#39; ? How do I do that ?</blockquote><div><br>One easy way would be to create a newtype with the type parameters swapped:
<br><br>&nbsp; newtype Oof b a = Oof (Foo a b)<br>&nbsp; instance Bar (Oof b) where ...<br><br>Of course, if you want to partially apply the second parameter of a function, you use &#39;flip&#39;.&nbsp; I thought for a while about whether there&#39;s some sort of typeclass hackery which is directly parallel to the use of &#39;flip&#39;, but couldn&#39;t come up with anything.&nbsp; Anyone?
<br><br>-Brent<br></div><br></div>