So, the function type "(Num a)=>Integer->a" 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 "class A a" and want to write function like this "f:: (A a)=>Integer->a". Can I do it?
<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>> How does caller choose which particular instance of Num they want?<br><br>They specify the type... or just pass the result to
<br>something that specifies the type. Try it in ghci:<br><br>Prelude> let f:: Integral i => Integer -> i; f = fromIntegral<br>Prelude> let g :: Int -> Int; g = id<br>Prelude> :t g (f 5)<br>g (f 5) :: Int
<br>Prelude> let h :: Integer -> Integer; h = id<br>Prelude> :t h (f 5)<br>h (f 5) :: Integer<br>Prelude><br><br>> What the difference between haskell class and interface in object-oriented<br>> languge such Java or C#?
<br><br>Really they are completely different animals that look a lot<br>alike because they serve similar purposes -- convergent<br>evolution!<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>妊快抖我志快把扼找抉志 均抖快抗扼忘扶忱把