Thanks. I get it.<br><br><br><br><div><span class="gmail_quote">2008/1/21, Jon Fairbairn <<a href="mailto:jon.fairbairn@cl.cam.ac.uk">jon.fairbairn@cl.cam.ac.uk</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
"Alexander Seliverstov" <<a href="mailto:seliverstov.a@gmail.com">seliverstov.a@gmail.com</a>> writes:<br><br>> So, the function type "(Num a)=>Integer->a" means that return value of<br>
> this function can be cast to any particular instance of class Num.<br><br>For some meanings of the word "cast" yes. I'd rather say<br>"f:: Num a=> Integer -> a" 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>> Ok. I have a my own class "class A a" and want to write function like<br>> this "f:: (A a)=>Integer->a". 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) => Integer -> 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>"methods" you give class A. For example:<br><br>class A a where<br> first_a :: a<br> second_a :: a
<br><br>f :: A t => Integer -> t<br>f n | odd n = first_a<br> | otherwise = second_a<br><br>--<br>J車n Fairbairn <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>妊快抖我志快把扼找抉志 均抖快抗扼忘扶忱把