Thanks. I get it.<br><br><br><br><div><span class="gmail_quote">2008/1/21, Jon Fairbairn &lt;<a href="mailto:jon.fairbairn@cl.cam.ac.uk">jon.fairbairn@cl.cam.ac.uk</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&quot;Alexander Seliverstov&quot; &lt;<a href="mailto:seliverstov.a@gmail.com">seliverstov.a@gmail.com</a>&gt; writes:<br><br>&gt; So, the function type &quot;(Num a)=&gt;Integer-&gt;a&quot; means that return value of<br>
&gt; this function can be cast to any particular instance of class Num.<br><br>For some meanings of the word &quot;cast&quot; yes. I&#39;d rather say<br>&quot;f:: Num a=&gt; Integer -&gt; a&quot; means that for any type a that is
<br>an instance of Num, given an integer f will return a member<br>of that type.<br><br>&gt; Ok. I have a my own class &quot;class A a&quot; and want to write function like<br>&gt; this&nbsp;&nbsp;&quot;f:: (A a)=&gt;Integer-&gt;a&quot;. Can I do it?
<br><br>You need to be a bit more specific about what f is supposed<br>to do without that, I can answer unequivocally yes, and give<br>you<br><br>f:: (A a) =&gt; Integer -&gt; a<br>f n = undefined<br><br>:-P<br><br>But in general you are going to want something a bit more
<br>useful, which means that you have to have a path from<br>Integer to a -- what the path can be is depends on what<br>&quot;methods&quot; you give class A. For example:<br><br>class A a where<br>&nbsp;&nbsp;first_a :: a<br>&nbsp;&nbsp;second_a :: a
<br><br>f :: A t =&gt; Integer -&gt; t<br>f n | odd n = first_a<br>&nbsp;&nbsp;&nbsp;&nbsp;| otherwise = second_a<br><br>--<br>J車n Fairbairn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="mailto:Jon.Fairbairn@cl.cam.ac.uk">Jon.Fairbairn@cl.cam.ac.uk
</a><br><br><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">
http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br><br clear="all"><br>-- <br>妊 批志忘忪快扶我快技,<br>妊快抖我志快把扼找抉志 均抖快抗扼忘扶忱把