2008/1/21 Alexander Seliverstov <
seliverstov.a@gmail.com>:
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.
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?
Only if you make the function f a member of class A. 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. For example:
class A a where
f :: Integer -> a
... other functions...
instance A Integer where
f = id
instance A String where
f = show
and so on.
-Brent