<br><br><div class="gmail_quote">2008/1/21 Alexander Seliverstov &lt;<a href="mailto:seliverstov.a@gmail.com">seliverstov.a@gmail.com</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
So, the function type &quot;(Num a)=&gt;Integer-&gt;a&quot; means that return value of this function can be cast to any particular instance of class Num.<br><br>Ok. I have a my own class &quot;class A a&quot; and want to write function like this&nbsp; &quot;f:: (A a)=&gt;Integer-&gt;a&quot;. Can I do it?
<br><br></blockquote><br>Only if you make the function f a member of class A.&nbsp; Then it is the responsibility of each particular type which is an instance of A to define a way of converting an Integer into a value of that type.&nbsp; For example:<br>
<br>class A a where<br>&nbsp; f :: Integer -&gt; a<br>&nbsp; ... other functions...<br><br>instance A Integer where<br>&nbsp; f = id<br><br>instance A String where<br>&nbsp; f = show<br><br>and so on.<br><br>-Brent<br></div>